diff options
author | Steven Hall <Hallzy.18@gmail.com> | 2015-10-18 16:27:32 -0700 |
---|---|---|
committer | Steven Hall <Hallzy.18@gmail.com> | 2015-10-18 16:27:32 -0700 |
commit | 8bef8d80648accd2806ad44e8db6e3aacd92d2e7 (patch) | |
tree | 7074e62288ed1baf19184b82c55e2026293fce59 | |
parent | 3bdb43d9dad5766c23a34e438ad3fbd05823b6bd (diff) | |
download | git-sonar-8bef8d80648accd2806ad44e8db6e3aacd92d2e7.tar.gz git-sonar-8bef8d80648accd2806ad44e8db6e3aacd92d2e7.zip |
Custom Fetch time now uses a variable
Set the variable GIT_RADAR_FETCH_TIME in a bashrc, zshrc or gitradarrc file to
customize the fetch time.
-rw-r--r-- | README.md | 20 | ||||
-rwxr-xr-x | fetch.sh | 6 | ||||
-rwxr-xr-x | git-radar | 21 | ||||
-rwxr-xr-x | radar-base.sh | 17 |
4 files changed, 32 insertions, 32 deletions
@@ -182,13 +182,23 @@ export PROMPT="$PROMPT\$(git-radar --zsh --fetch) " ``` [(note: the `\` escaping the `$` is important)](#ensuring-prompt-execution) -You may also choose to use the `--fetch_t` option to specify your own fetch -times. `--fetch` defaults to fetch automatically every 5 minutes. With -`--fetch_t <seconds>` you can choose how often to fetch. +You may also choose to fetch at a customized interval of time. To do so, add +this to your .bashrc, .zshrc: -eg. ```bash -export PS1="$PS1\$(git-radar --bash --fetch_t 30)" +export GIT_RADAR_FETCH_TIME=<seconds> +``` + +For example, to fetch every 30 seconds (instead of the default 5 minutes): + +```bash +export GIT_RADAR_FETCH_TIME=30 +``` + +You can also do this in the gitradarrc file: + +```bash +GIT_RADAR_FETCH_TIME=30 ``` ## Customise your prompt @@ -10,8 +10,4 @@ dot="$(cd "$(dirname "$([ -L "$0" ] && $READLINK_CMD -f "$0" || echo "$0")")"; p source $dot/radar-base.sh -if [[ -z "$@" ]]; then - fetch; -else - fetch $1; -fi +fetch; @@ -84,37 +84,16 @@ if [[ -z $@ ]]; then echo " end" echo "" echo " Same as the Bash but for fish." - echo "" - echo "Fetch_t example:" - echo " export PS1=\"\\W\\\$(git-radar --bash --fetch_t 45) \"" exit fi while [[ $# > 0 ]];do command="$1" shift - # Default fetch of 5 min if [[ "$command" == "--fetch" ]]; then nohup $dot/fetch.sh >/dev/null 2>&1 & fi - # Custom fetch of whatever time interval the user wants - if [[ "$command" == "--fetch_t" ]]; then - # Now $1 is the value for fetch_t - # If value is not a number produce an error - if ! [[ $1 =~ ^[0-9]+$ ]] ; then - echo "" - echo "Error: fetch_t did not receive a number" - echo "Defaulting to 5 min." - echo " " - nohup $dot/fetch.sh >/dev/null 2>&1 & - else - command="$1" - shift - nohup $dot/fetch.sh $command >/dev/null 2>&1 & - fi - fi - if [[ "$command" == "--zsh" ]]; then $dot/prompt.zsh $args fi diff --git a/radar-base.sh b/radar-base.sh index d639fa0..f9d834a 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -13,6 +13,20 @@ timethis() { echo "$1 - $dur" >> $HOME/duration.dat } +get_fetch_time() { + if [ -f "$rcfile_path/.gitradarrc.bash" ]; then + source "$rcfile_path/.gitradarrc.bash" + elif [ -f "$rcfile_path/.gitradarrc.zsh" ]; then + source "$rcfile_path/.gitradarrc.zsh" + elif [ -f "$rcfile_path/.gitradarrc" ]; then + source "$rcfile_path/.gitradarrc" + fi + + FETCH_TIME="${GIT_RADAR_FETCH_TIME:-"$((5 * 60))"}" + echo $FETCH_TIME + +} + prepare_bash_colors() { if [ -f "$rcfile_path/.gitradarrc.bash" ]; then source "$rcfile_path/.gitradarrc.bash" @@ -167,7 +181,8 @@ time_to_update() { } fetch() { - local timeToUpdate=${1:-"$((5 * 60))"} + get_fetch_time + local timeToUpdate=${1:-$FETCH_TIME} if time_to_update $timeToUpdate; then record_timestamp |