From e0d19586c4a0b53108c3e3656d4b03bc05bfd096 Mon Sep 17 00:00:00 2001 From: brettanomyces Date: Sun, 29 Jun 2014 21:21:21 -0700 Subject: [PATCH] Improve repeat history for zsh --- examples.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples.md b/examples.md index 0e0156e..6b719fe 100644 --- a/examples.md +++ b/examples.md @@ -59,6 +59,15 @@ fh() { } ``` +```sh +# fh - repeat history +fh() { + print -z $(([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s | sed 's/ *[0-9]* *//') +} +``` + +Replacing `eval` with `print -z` will push the arguments onto the editing buffer stack, allowing you to edit the command before running it. It also means the command you run will appear in your history rather than just `fh`. Unfortunately this only works for zsh. + Processes ---------