This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fzf_history() { | |
local selected | |
setopt localoptions pipefail no_aliases 2> /dev/null | |
selected=$(fc -l -n -t "%s" 1 | awk '{cmd=$0; sub(/^[0-9]+ /, "", cmd); print $1 "|" cmd}' | awk -F '|' '!seen[$2]++ {print $0}' | cut -d '|' -f2- | \ | |
fzf --tac --tiebreak=index --height 50% --layout=reverse --preview 'echo {}' --preview-window=up:3:wrap \ | |
--bind 'ctrl-y:execute-silent(echo -n {+} | pbcopy)' \ | |
--header 'Press CTRL-Y to copy command into clipboard') | |
if [[ -n "$selected" ]]; then | |
BUFFER=${selected} |