remove dependency of hostname[ctl]
[grml-etc-core.git] / etc / zsh / zshrc
index 5a74fee..a992e3f 100644 (file)
@@ -432,10 +432,6 @@ is4 && setopt share_history
 # save each command's beginning timestamp and the duration to the history file
 setopt extended_history
 
-# If a new command line being added to the history list duplicates an older
-# one, the older command is removed from the list
-is4 && setopt histignorealldups
-
 # remove command lines from the history list when the first character on the
 # line is a space
 setopt histignorespace
@@ -905,14 +901,7 @@ function grmlcomp () {
     fi
 
     local localname
-    if check_com hostname ; then
-      localname=$(hostname)
-    elif check_com hostnamectl ; then
-      localname=$(hostnamectl --static)
-    else
-      localname="$(uname -n)"
-    fi
-
+    localname="$(uname -n)"
     hosts=(
         "${localname}"
         "$_ssh_config_hosts[@]"
@@ -1200,10 +1189,15 @@ zle -N grml-zsh-fg
 # run command line as user root via sudo:
 function sudo-command-line () {
     [[ -z $BUFFER ]] && zle up-history
-    if [[ $BUFFER != sudo\ * ]]; then
-        BUFFER="sudo $BUFFER"
-        CURSOR=$(( CURSOR+5 ))
+    local cmd="sudo "
+    if [[ ${BUFFER} == ${cmd}* ]]; then
+        CURSOR=$(( CURSOR-${#cmd} ))
+        BUFFER="${BUFFER#$cmd}"
+    else
+        BUFFER="${cmd}${BUFFER}"
+        CURSOR=$(( CURSOR+${#cmd} ))
     fi
+    zle reset-prompt
 }
 zle -N sudo-command-line