Skip to content

Instantly share code, notes, and snippets.

@utdemir
Created January 16, 2020 02:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utdemir/3eddb8bafdc0b5b2a2e5a7efdc380724 to your computer and use it in GitHub Desktop.
Save utdemir/3eddb8bafdc0b5b2a2e5a7efdc380724 to your computer and use it in GitHub Desktop.
fzf-history-uniq() {
selected=$(
history 0 \
| awk '{
match($0, /^ *([0-9]+) *(.*)$/, r);
num=r[1]; cmd=r[2];
if(s[cmd]=="") { print cmd; s[cmd]=1; } }' \
| fzf --tac )
BUFFER="$selected"
zle end-of-line
}
zle -N fzf-history-uniq
bindkey '^E' fzf-history-uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment