From: martin f. krafft Date: Tue, 6 May 2008 07:19:28 +0000 (+0100) Subject: cleanup and prevent running as root X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/0a2c5ed047d6c57887b1c4275a59cbc96d76ae92?ds=inline cleanup and prevent running as root --- diff --git a/.zsh/zshrc/85_git_prompt b/.zsh/zshrc/85_vcs_prompt similarity index 79% rename from .zsh/zshrc/85_git_prompt rename to .zsh/zshrc/85_vcs_prompt index 32d0e4f..63ccb65 100644 --- a/.zsh/zshrc/85_git_prompt +++ b/.zsh/zshrc/85_vcs_prompt @@ -89,21 +89,25 @@ __vcs_set_prompt_variables() psvar[3]="$post" } -update_git_vars_if_git_ran() { - local vcs="$(__vcs_get_repo_type)" - case "$(history $(($HISTCMD - 1)))" in - # $vcs appeared in last command, so be sure to update - *${vcs}*) __vcs_set_prompt_variables - esac -} -precmd_functions+=update_git_vars_if_git_ran +if ! is_root; then + # too dangerous to be run as root -update_git_vars() { - __vcs_set_prompt_variables -} -chpwd_functions+=update_git_vars + _update_vcs_prompt_vars_if_vcs_ran() { + local vcs="$(__vcs_get_repo_type)" + case "$(history $(($HISTCMD - 1)))" in + # $vcs appeared in last command, so be sure to update + *${vcs}*) __vcs_set_prompt_variables + esac + } + precmd_functions+=_update_vcs prompt_vars_if_vcs_ran + + _update_vcs_prompt_vars() { + __vcs_set_prompt_variables + } + chpwd_functions+=_update_vcs_prompt_vars +fi # call it once -update_git_vars +_update_vcs_prompt_vars # vim:ft=zsh