1e7c6743a7b221cb2069a84c70890014597672d8

Author
Giel van Schijndel <giel.van.schijndel@sioux.eu>
Committer
Giel van Schijndel <giel.van.schijndel@sioux.eu>
Date

Message

sudo: maintain cursor position

I.e. when prefixing the current command-line with 'sudo ' maintain the
current cursor position instead of jumping to the end of the line.

Diff

 1diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
 2index d12e068530e70ca2dc8e55d21e628214ecadbf29..e3ba39918af9345bb04801bb2c5dc5c6704d99b0 100644
 3--- a/plugins/sudo/sudo.plugin.zsh
 4+++ b/plugins/sudo/sudo.plugin.zsh
 5@@ -13,9 +13,8 @@
 6 # ------------------------------------------------------------------------------
 7 
 8 sudo-command-line() {
 9-[[ -z $BUFFER ]] && zle up-history
10-[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
11-zle end-of-line 
12+    [[ -z $BUFFER ]] && zle up-history
13+    [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
14 }
15 zle -N sudo-command-line
16 # Defined shortcut keys: [Esc] [Esc]