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 ---------