浏览代码

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.
Giel van Schijndel 10 年之前
父节点
当前提交
1e7c6743a7
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      plugins/sudo/sudo.plugin.zsh

+ 2 - 3
plugins/sudo/sudo.plugin.zsh

@@ -13,9 +13,8 @@
 # ------------------------------------------------------------------------------
 
 sudo-command-line() {
-[[ -z $BUFFER ]] && zle up-history
-[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
-zle end-of-line 
+    [[ -z $BUFFER ]] && zle up-history
+    [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
 }
 zle -N sudo-command-line
 # Defined shortcut keys: [Esc] [Esc]