Created
August 21, 2011 13:52
-
-
Save pSub/1160638 to your computer and use it in GitHub Desktop.
Keybindings zum ändern von pacman Kommandos für die 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
# Mit diesen Widgets für die zsh kann man pacman Befehle | |
# "on the fly" ändern. Wenn man z.B. "pacman -Si weechat" ausgeführt hat, | |
# und möchte nun weechat installieren, muss man nur in der History zurück | |
# gehen und Meta-i drücken. Damit ändert sich der Befehl zu "pacman -S weechat". | |
# Konfiguration der Keybindings und Komandos | |
pacman_bindings=("^[i" "S" # Meta-i → install | |
"^[f" "Ss" # Meta-f → search | |
"^[r" "Rs" # Meta-r → remove | |
"^[p" "Si" # Meta-p → info / properties | |
) | |
replace-pacman-command() { | |
if [[ $LBUFFER = "pacman"* ]]; then | |
CURSOR=0 | |
zle forward-word | |
zle delete-word | |
LBUFFER+="$*" | |
zle end-of-line | |
fi | |
} | |
local i | |
i=1 | |
while [ $i -le ${#pacman_bindings} ]; do | |
function "replace-pacman-command-"$i { | |
number=${WIDGET//[^[:digit:]]/} | |
replace-pacman-command "-"$pacman_bindings[$number+1] | |
} | |
zle -N "replace-pacman-command-"$i | |
bindkey $pacman_bindings[$i] "replace-pacman-command-"$i | |
i=$((i+2)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment