Created
October 12, 2014 05:50
-
-
Save jemiam/5178426e980c2647502c to your computer and use it in GitHub Desktop.
peco-select-history
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
function peco-select-history() { | |
local tac | |
if which tac > /dev/null; then | |
tac="tac" | |
else | |
tac="tail -r" | |
fi | |
if [ -n "$LBUFFER" ]; then | |
BUFFER=$(history -n 1 | \ | |
eval $tac | \ | |
peco --query "$LBUFFER") | |
else | |
BUFFER=$(history -n 1 | \ | |
eval $tac | \ | |
peco) | |
fi | |
CURSOR=$#BUFFER | |
zle clear-screen | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment