Preserve cursor position with `sudo-command-line' [Closes: issue980]
[grml-etc-core.git] / etc / zsh / zshrc
index 43f2608..8643fae 100644 (file)
@@ -938,7 +938,10 @@ bindkey '^z' grml-zsh-fg
 # run command line as user root via sudo:
 sudo-command-line() {
     [[ -z $BUFFER ]] && zle up-history
-    [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
+    if [[ $BUFFER != sudo\ * ]]; then
+        BUFFER="sudo $BUFFER"
+        CURSOR=$(( CURSOR+5 ))
+    fi
 }
 zle -N sudo-command-line
 
@@ -2052,9 +2055,7 @@ function info_print () {
     esc_end="$2"
     shift 2
     printf '%s' ${esc_begin}
-    for item in "$@" ; do
-        printf '%s ' "$item"
-    done
+    printf '%s' "$*"
     printf '%s' "${esc_end}"
 }
 
@@ -3079,14 +3080,14 @@ exit 0;
 ssl_hashes=( sha512 sha256 sha1 md5 )
 
 for sh in ${ssl_hashes}; do
-    ssl-cert-${sh}() {
+    eval 'ssl-cert-'${sh}'() {
         emulate -L zsh
         if [[ -z $1 ]] ; then
-            printf 'usage: %s <file>\n' "ssh-cert-${sh}"
+            printf '\''usage: %s <file>\n'\'' "ssh-cert-'${sh}'"
             return 1
         fi
-        openssl x509 -noout -fingerprint -${sh} -in $1
-    }
+        openssl x509 -noout -fingerprint -'${sh}' -in $1
+    }'
 done; unset sh
 
 ssl-cert-fingerprints() {
@@ -3124,6 +3125,9 @@ if [[ -r ~/.important_commands ]] ; then
 fi
 # }}}
 
+# load the lookup subsystem if it's available on the system
+zrcautoload lookupinit && lookupinit
+
 #:grep:marker:for:mika: :-)
 ### non-root (EUID != 0) code below
 ###
@@ -3133,8 +3137,6 @@ if (( GRML_ALWAYS_LOAD_ALL == 0 )) && (( $EUID == 0 )) ; then
     return 0
 fi
 
-zrcautoload lookupinit && lookupinit
-
 # variables {{{
 
 # set terminal property (used e.g. by msgid-chooser)