From 8555378a6a9967c59b3a819eb3a36d95bfe2d40d Mon Sep 17 00:00:00 2001 From: Nadim Khemir Date: Tue, 4 Oct 2016 09:37:46 +0200 Subject: [PATCH] Updated Examples (markdown) --- Examples.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Examples.md b/Examples.md index a112fed..b6b1d76 100644 --- a/Examples.md +++ b/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 = ; $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 }