Last active
August 29, 2015 14:25
-
-
Save Gordin/7514816a29760686ab88 to your computer and use it in GitHub Desktop.
Selecta history widget for zsh
This file contains 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
if [[ -n $(which selecta) ]]; then | |
# CTRL-R - Paste the selected command from history into the command line | |
selecta-history-widget() { | |
local selected restore_no_bang_hist | |
if [[ -z "$LBUFFER" ]]; then | |
selected=( $(fc -l 1 | selecta) ) | |
else | |
selected=( $(fc -l 1 | selecta -s "$LBUFFER") ) | |
fi | |
if $selected; then | |
num=$selected[1] | |
if [ -n "$num" ]; then | |
zle vi-fetch-history -n $num | |
fi | |
fi | |
zle redisplay | |
} | |
zle -N selecta-history-widget | |
bindkey '^R' selecta-history-widget | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment