From: Simon Ruderich Date: Wed, 25 Mar 2009 13:25:40 +0000 (+0100) Subject: zsh: Also add ! to command name when running zsh as root. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=a30049ee61b45c14a9d0ad53f03b76cfb95a239c;p=config%2Fdotfiles.git zsh: Also add ! to command name when running zsh as root. --- diff --git a/zsh/rc b/zsh/rc index 278b660..26271b3 100644 --- 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