Skip to content

Instantly share code, notes, and snippets.

@pSub
Created August 21, 2011 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pSub/1160638 to your computer and use it in GitHub Desktop.
Save pSub/1160638 to your computer and use it in GitHub Desktop.
Keybindings zum ändern von pacman Kommandos für die ZSH
# 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