summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md13
-rwxr-xr-xgit-radar5
-rwxr-xr-xprompt.bash5
-rwxr-xr-xprompt.zsh5
-rwxr-xr-xradar-base.sh8
-rwxr-xr-xtest1
-rwxr-xr-xtest-radar-base.sh28
7 files changed, 61 insertions, 4 deletions
diff --git a/README.md b/README.md
index 0a90a6e..61ae983 100644
--- a/README.md
+++ b/README.md
@@ -115,6 +115,19 @@ Prompt | Meaning
![git:(m 4 → my-branch)] | There are 4 commits on `origin/master` that aren't on `origin/my-branch`
![git:(m 1 ⇄ 2 my-branch)] | `origin/master` and `origin/my-branch` have diverged, we'll need to rebase or merge
+If you don't rely on this status, you can always hide this part of the prompt by calling git-radar with `--no-remote-status`.
+
+**Bash**
+```bash
+export PS1="$PS1\$(git-radar --bash --fetch --no-remote-status) "
+```
+(note: the `\` escaping the `$` is important)
+
+**Zsh**
+```zsh
+export PROMPT="$PROMPT$(git-radar --zsh --fetch --no-remote-status) "
+```
+
### (Optional) Auto-fetch repos
Ensuring your refs are up to date I found can be a pain. To streamline this
diff --git a/git-radar b/git-radar
index a5cd3c1..67b8460 100755
--- a/git-radar
+++ b/git-radar
@@ -11,6 +11,7 @@ else
fi
dot="$(cd "$(dirname "$([ -L "$0" ] && $READLINK_CMD -f "$0" || echo "$0")")"; pwd)"
+args=$@
if [[ -z $@ ]]; then
_git="\033[1;30mgit:(\033[0m"
@@ -92,9 +93,9 @@ while [[ $# > 0 ]];do
nohup $dot/fetch.sh >/dev/null 2>&1 &
fi
if [[ "$command" == "--zsh" ]]; then
- $dot/prompt.zsh
+ $dot/prompt.zsh $args
fi
if [[ "$command" == "--bash" || "$command" == "--fish" ]]; then
- $dot/prompt.bash
+ $dot/prompt.bash $args
fi
done
diff --git a/prompt.bash b/prompt.bash
index a3fe420..429c88d 100755
--- a/prompt.bash
+++ b/prompt.bash
@@ -1,11 +1,14 @@
#! /usr/bin/env bash
dot="$(cd "$(dirname "$0")"; pwd)"
+args=$@
source "$dot/radar-base.sh"
if is_repo; then
printf " \x01\033[1;30m\x02git:(\x01\033[0m\x02"
- bash_color_remote_commits
+ if show_remote_status $args; then
+ bash_color_remote_commits
+ fi
readable_branch_name
bash_color_local_commits
printf "\x01\033[1;30m\x02)\x01\033[0m\x02"
diff --git a/prompt.zsh b/prompt.zsh
index cb1eb91..a5ccba5 100755
--- a/prompt.zsh
+++ b/prompt.zsh
@@ -1,12 +1,15 @@
#! /usr/bin/env zsh
dot="$(cd "$(dirname "$0")"; pwd)"
+args=$@
source "$dot/radar-base.sh"
if is_repo; then
autoload colors && colors
printf '%s' "%{$fg_bold[black]%} git:(%{$reset_color%}"
- zsh_color_remote_commits
+ if show_remote_status $args; then
+ zsh_color_remote_commits
+ fi
readable_branch_name
zsh_color_local_commits
printf '%s' "%{$fg_bold[black]%})%{$reset_color%}"
diff --git a/radar-base.sh b/radar-base.sh
index b7074d8..d019629 100755
--- a/radar-base.sh
+++ b/radar-base.sh
@@ -1,3 +1,5 @@
+NO_REMOTE_STATUS='--no-remote-status'
+
dot_git=""
cwd=""
remote=""
@@ -469,3 +471,9 @@ zsh_color_remote_commits() {
printf %s "$remote"
}
+show_remote_status() {
+ if [[ $@ == *$NO_REMOTE_STATUS* ]]; then
+ return 1 # don't show the git remote status
+ fi
+ return 0
+}
diff --git a/test b/test
index a6a8775..831e039 100755
--- a/test
+++ b/test
@@ -1,5 +1,6 @@
#!/bin/sh
+./test-radar-base.sh
./test-directories.sh
./test-commits.sh
./test-branches.sh
diff --git a/test-radar-base.sh b/test-radar-base.sh
new file mode 100755
index 0000000..9f7f8ee
--- /dev/null
+++ b/test-radar-base.sh
@@ -0,0 +1,28 @@
+scriptDir="$(cd "$(dirname "$0")"; pwd)"
+
+source "$scriptDir/radar-base.sh"
+
+test_show_remote_status() {
+ show_remote_status
+ assertTrue $?
+
+ show_remote_status --bash
+ assertTrue $?
+
+ show_remote_status --bash --fetch
+ assertTrue $?
+
+ show_remote_status --bash --no-remote-status --fetch
+ assertFalse $?
+
+ show_remote_status --bash --fetch --no-remote-status
+ assertFalse $?
+
+ show_remote_status --no-remote-status --bash --fetch
+ assertFalse $?
+
+ show_remote_status --bash --fetch --minimal --no-remote-status
+ assertFalse $?
+}
+
+. ./shunit/shunit2 \ No newline at end of file