diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-10 14:15:15 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-09-10 14:15:15 +1200 |
commit | eb63f48e136e1e36f57f47c83e15d74ab4cbcc65 (patch) | |
tree | 834d53099e6e61b4238e54f54fbcb4556971e3c5 | |
parent | Use builtins only for prompt job count (diff) | |
download | dotfiles-eb63f48e136e1e36f57f47c83e15d74ab4cbcc65.tar.gz dotfiles-eb63f48e136e1e36f57f47c83e15d74ab4cbcc65.zip |
Fail early if VCS binaries not found
-rw-r--r-- | bash/bashrc.d/prompt.bash | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 8927e732..6864ce19 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -40,6 +40,11 @@ prompt() { # Git prompt function git) + # Bail if we have no git(1) + if ! hash git 2>/dev/null; then + return 1 + fi + # Exit if inside a .git directory local gitdir=$(git rev-parse --is-inside-git-dir 2>/dev/null) if [[ $gitdir == true ]]; then @@ -99,6 +104,11 @@ prompt() { # Mercurial prompt function hg) + # Bail if we have no hg(1) + if ! hash hg 2>/dev/null; then + return 1 + fi + # Exit if not inside a Mercurial tree local branch if ! branch=$(hg branch 2>/dev/null); then @@ -121,6 +131,11 @@ prompt() { # Subversion prompt function svn) + # Bail if we have no svn(1) + if ! hash svn 2>/dev/null; then + return 1 + fi + # Exit if not inside a Subversion working copy if ! svn info >/dev/null 2>&1; then return 1 |