diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2012-06-08 13:48:46 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2012-06-08 13:48:46 +1200 |
commit | 7e145b04d3f8092bd8e6911815313a23e94f3482 (patch) | |
tree | bebc719bf9cfe6c2dc1464e65300f6098eeb5577 /bash | |
parent | Surround updates (diff) | |
download | dotfiles-7e145b04d3f8092bd8e6911815313a23e94f3482.tar.gz dotfiles-7e145b04d3f8092bd8e6911815313a23e94f3482.zip |
Optimise call a bit
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/bash/bashrc b/bash/bashrc index 32666088..c0dd8e2f 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -94,19 +94,12 @@ function prompt_git { STATUS="!" fi echo -n "(git:${BRANCH##*/}${STATUS})" + return 0 fi -} - -# Function to display branch of a Mercurial repository. -function prompt_hg { - BRANCH="$(hg branch 2>/dev/null)" - if [[ -n "$BRANCH" ]]; then - echo -n "(hg:${BRANCH})" - fi + return 1 } # Function to display branch of an SVN working copy. - function prompt_svn { URL="$(svn info 2>/dev/null | awk -F': ' '$1 == "URL" {print $2}')" if [[ -n "$URL" ]]; then @@ -116,11 +109,29 @@ function prompt_svn { STATUS="!" fi echo -n "(svn:${URL/$ROOT}${STATUS})" + return 0 fi + return 1 +} + +# Function to display branch of a Mercurial repository. +function prompt_hg { + BRANCH="$(hg branch 2>/dev/null)" + if [[ -n "$BRANCH" ]]; then + echo -n "(hg:${BRANCH})" + return 0 + fi + return 1 +} + +# Function that calls each of the above in order of how likely I am to be +# using that kind of repository, to save some cycles. +function prompt_vcs { + prompt_git || prompt_svn || prompt_hg } # Uncolored bits of my prompt, we'll color them if appropriate shortly. -PS1='[\u@\h:\w]$(prompt_git)$(prompt_hg)$(prompt_svn)\$' +PS1='[\u@\h:\w]$(prompt_vcs)\$' # Save some color codes based on our colour space. if [[ $COLORS -ge 256 ]]; then |