aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/prompt.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-21 15:15:22 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-21 15:15:22 +1200
commit229b941b07317a44d5e63a518da24e20682f5d32 (patch)
treeac794cd42bebe4117ce4f8900cd885c2e8782fb8 /bash/bashrc.d/prompt.bash
parentAdd la(), ll() (diff)
downloaddotfiles-229b941b07317a44d5e63a518da24e20682f5d32.tar.gz
dotfiles-229b941b07317a44d5e63a518da24e20682f5d32.zip
Slightly quicker git/svn detection
Diffstat (limited to 'bash/bashrc.d/prompt.bash')
-rw-r--r--bash/bashrc.d/prompt.bash21
1 files changed, 6 insertions, 15 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 1e8c568d..5907f8ed 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -99,12 +99,8 @@ prompt() {
# Git prompt function
git)
- # Bail if we have no git(1)
- if ! hash git 2>/dev/null ; then
- return 1
- fi
-
- # Bail if we're not in a work tree
+ # Bail if we're not in a work tree--or, implicitly, if we don't
+ # have git(1).
local iswt
iswt=$(git rev-parse --is-inside-work-tree 2>/dev/null)
if [[ $iswt != true ]] ; then
@@ -159,11 +155,6 @@ prompt() {
# Subversion prompt function
svn)
- # Bail if we have no svn(1)
- if ! hash svn 2>/dev/null ; then
- return 1
- fi
-
# Determine the repository URL and root directory
local key value url root
while IFS=: read -r key value ; do
@@ -177,10 +168,10 @@ prompt() {
esac
done < <(svn info 2>/dev/null)
- # Exit if we couldn't get either
- if [[ ! -n $url || ! -n $root ]] ; then
- return 1
- fi
+ # Exit if we couldn't get either--or, implicitly, if we don't have
+ # svn(1).
+ [[ -n $url ]] || return
+ [[ -n $root ]] || return
# Remove the root from the URL to get what's hopefully the branch
# name, removing leading slashes and the 'branches' prefix, and any