X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=zsh%2Frc;h=2712314b7d32840417b99dfe583b3f1b0cd9b923;hb=e696edbf63b5ba5727b8bd8037dfa690b298b6a2;hp=dea48042bb4ee6ff80c5bc56b1acbcad5e75e700;hpb=abffe4a5d42482508709c25797961e1760f3bcc3;p=config%2Fdotfiles.git diff --git a/zsh/rc b/zsh/rc index dea4804..2712314 100644 --- a/zsh/rc +++ b/zsh/rc @@ -19,6 +19,11 @@ source_debug '. ~/.zsh/rc' +# Warn when creating global variables from inside a function. Needs to be set +# before declaring a function. +setopt warn_create_global + + # HELPER FUNCTIONS # Return the name of the program which is called in the foreground with `fg`. @@ -444,10 +449,6 @@ if [[ $TERM == screen* || $TERM == xterm* || $TERM == rxvt* ]]; then # Is set to a non empty value to reset the window name in the next # precmd() call. zshrc_window_reset=yes - # Is set to a non empty value when the shell is running as root. - if [[ $UID -eq 0 ]]; then - zshrc_window_root=yes - fi zshrc_window_preexec() { # Get the program name with its arguments. @@ -492,7 +493,7 @@ if [[ $TERM == screen* || $TERM == xterm* || $TERM == rxvt* ]]; then # Add an exclamation mark at the beginning if running with sudo or if # running zsh as root. - if [[ -n $program_sudo || -n $zshrc_window_root ]]; then + if [[ -n $program_sudo || $UID -eq 0 ]]; then program_name=!$program_name fi @@ -531,7 +532,7 @@ if [[ $TERM == screen* || $TERM == xterm* || $TERM == rxvt* ]]; then fi # Prepend prefixes like in window_preexec(). - if [[ -n $zshrc_window_root ]]; then + if [[ $UID -eq 0 ]]; then name="!$name" fi if [[ -n $SSH_CONNECTION ]]; then