m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 16:45:38 -05:00

Changed history selection so that acutal selected command will appear in the history instead of "fh". fhe is the same but allows to edit the command before executing it. I'll leave both versions so you can decide which version you want to keep

hcraT
2014-08-26 01:39:38 -07:00
parent 53a04fe194
commit 3006fe397b

@@ -75,6 +75,27 @@ fh() {
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.
### With write to terminal capabilities
```sh
# utility function used to write the command in the shell
writecmd() {
perl -e '$TIOCSTI = 0x5412; $l = <STDIN>; $lc = $ARGV[0] eq "-run" ? "\n" : ""; $l =~ s/\s*$/$lc/; map { ioctl STDOUT, $TIOCSTI, $_; } split "", $l;' -- $1
}
# fh - repeat history
fh() {
([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s | sed -re 's/^\s*[0-9]+\s*//' | writecmd -run
}
# fhe - repeat history edit
fhe() {
([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s | sed -re 's/^\s*[0-9]+\s*//' | writecmd
}
```
This have been tested in bash and works.
Processes
---------