]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
zsh: Also add ! to command name when running zsh as root.
authorSimon Ruderich <simon@ruderich.org>
Wed, 25 Mar 2009 13:25:40 +0000 (14:25 +0100)
committerSimon Ruderich <simon@ruderich.org>
Wed, 25 Mar 2009 13:25:40 +0000 (14:25 +0100)
zsh/rc

diff --git a/zsh/rc b/zsh/rc
index 278b66003dc58ed3217bd509787bd6612bc2136a..26271b3b44ca5c3d9892abd302ad4df613c4a155 100644 (file)
--- a/zsh/rc
+++ b/zsh/rc
@@ -144,6 +144,10 @@ if [[ $TERM == screen* || $TERM == xterm* ]]; then
     if [[ $? -eq 0 ]]; then
         window_stumpwm=yes
     fi
+    # Set to a non empty value when the shell is running as root.
+    if [[ $(id -u) -eq 0 ]]; then
+        window_root=yes
+    fi
 
     window_preexec() {
         # Get the program name with its arguments.
@@ -180,8 +184,9 @@ if [[ $TERM == screen* || $TERM == xterm* ]]; then
                 ;;
         esac
 
-        # Add an exclamation mark at the beginning if running with sudo.
-        if [[ $program_sudo == yes ]]; then
+        # Add an exclamation mark at the beginning if running with sudo or if
+        # running zsh as root.
+        if [[ $program_sudo == yes || $window_root == yes ]]; then
             program_name=!$program_name
         fi
 
@@ -205,6 +210,8 @@ if [[ $TERM == screen* || $TERM == xterm* ]]; then
         # Reset the window name to 'zsh'.
         if [[ -n $SSH_CONNECTION ]]; then
             window_title "@zsh"
+        elif [[ $window_root == yes ]]; then
+            window_title "!zsh"
         else
             window_title "zsh"
         fi