From a30049ee61b45c14a9d0ad53f03b76cfb95a239c Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Wed, 25 Mar 2009 14:25:40 +0100 Subject: [PATCH] zsh: Also add ! to command name when running zsh as root. --- zsh/rc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 -- 2.44.2