mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
Updated Examples (markdown)
11
Examples.md
11
Examples.md
@@ -180,17 +180,16 @@ Replacing `eval` with `print -z` will push the arguments onto the editing buffer
|
||||
These have been tested in bash.
|
||||
|
||||
```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
|
||||
runcmd (){ perl -e 'ioctl STDOUT, 0x5412, $_ for split //, <>' }
|
||||
|
||||
fh() {
|
||||
([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed -re 's/^\s*[0-9]+\s*//' | writecmd -run
|
||||
([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed -re 's/^\s*[0-9]+\s*//' | runcmd
|
||||
}
|
||||
|
||||
# fhe - repeat history edit
|
||||
writecmd (){ perl -e 'ioctl STDOUT, 0x5412, $_ for split //, do{ chomp($_ = <>); $_ }' }
|
||||
|
||||
fhe() {
|
||||
([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed -re 's/^\s*[0-9]+\s*//' | writecmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user