From 00f2a8c908e299d08e2efad038da25b2d5446976 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Mon, 28 Sep 2015 22:13:18 -0700 Subject: Added feature that let's you specify how often to fetch with --fetch_t you can specify how many seconds to wait before auto fetching. using the --fetch option gives you the default of 5 minutes still. "--fetch_t 45" for example would fetch every 45 seconds. --- git-radar | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'git-radar') diff --git a/git-radar b/git-radar index 67b8460..c3f7aa3 100755 --- a/git-radar +++ b/git-radar @@ -56,10 +56,11 @@ if [[ -z $@ ]]; then echo "usage:" echo " git-radar [--zsh|--bash|--fish] [--fetch]" echo "" - echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" - echo " --zsh # Output prompt using Zsh style color characters" - echo " --bash # Output prompt using Bash style color characters" - echo " --fish # Output prompt using fish style color characters" + echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" + echo " --fetch_t # Fetches your repo asynchronously in the background every seconds" + echo " --zsh # Output prompt using Zsh style color characters" + echo " --bash # Output prompt using Bash style color characters" + echo " --fish # Output prompt using fish style color characters" echo "" echo "Bash example:" echo " export PS1=\"\\W\\\$(git-radar --bash --fetch) \"" @@ -83,18 +84,30 @@ 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 of fetch_t + nohup $dot/fetch.sh $1 >/dev/null 2>&1 & + fi + if [[ "$command" == "--zsh" ]]; then $dot/prompt.zsh $args fi + if [[ "$command" == "--bash" || "$command" == "--fish" ]]; then $dot/prompt.bash $args fi -- cgit v1.2.3 From b8797284031edbfd4c22f19f4878418cf4b2ec10 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Fri, 16 Oct 2015 11:31:21 -0700 Subject: Made changes recommeneded by @michaeldfallen in fetch.sh "if" now checks for $@ instead of just $1 in radar-base.sh there is now a parameter expansion on line 170 instead of the if statements. in git-radar, now there is a shift, and a regex check that the next value is a number. If the next value after --fetch_t is not a number, an error is echo'd and it resorts to the default behaviour of 5 minutes. --- git-radar | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'git-radar') diff --git a/git-radar b/git-radar index c3f7aa3..a38f00f 100755 --- a/git-radar +++ b/git-radar @@ -100,8 +100,19 @@ while [[ $# > 0 ]];do # Custom fetch of whatever time interval the user wants if [[ "$command" == "--fetch_t" ]]; then - # Now $1 is the value of fetch_t - nohup $dot/fetch.sh $1 >/dev/null 2>&1 & + # 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 -- cgit v1.2.3 From 8bef8d80648accd2806ad44e8db6e3aacd92d2e7 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sun, 18 Oct 2015 16:27:32 -0700 Subject: 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. --- git-radar | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'git-radar') diff --git a/git-radar b/git-radar index a38f00f..07f0a0a 100755 --- a/git-radar +++ b/git-radar @@ -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 -- cgit v1.2.3 From f52ce6c1b35edf7f35f20b6c10811ff6d978a688 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sun, 18 Oct 2015 16:30:17 -0700 Subject: Missed a fetch_t in the git_radar file to remove. --- git-radar | 1 - 1 file changed, 1 deletion(-) (limited to 'git-radar') diff --git a/git-radar b/git-radar index 07f0a0a..ce11945 100755 --- a/git-radar +++ b/git-radar @@ -57,7 +57,6 @@ if [[ -z $@ ]]; then echo " git-radar [--zsh|--bash|--fish] [--fetch]" echo "" echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" - echo " --fetch_t # Fetches your repo asynchronously in the background every seconds" echo " --zsh # Output prompt using Zsh style color characters" echo " --bash # Output prompt using Bash style color characters" echo " --fish # Output prompt using fish style color characters" -- cgit v1.2.3 From 51000c4213983fc2a72b039858112b3bb4c2b592 Mon Sep 17 00:00:00 2001 From: Steven Hall Date: Sun, 18 Oct 2015 16:31:52 -0700 Subject: Moved comments back to original position. --- git-radar | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git-radar') diff --git a/git-radar b/git-radar index ce11945..9c8565f 100755 --- a/git-radar +++ b/git-radar @@ -56,10 +56,10 @@ if [[ -z $@ ]]; then echo "usage:" echo " git-radar [--zsh|--bash|--fish] [--fetch]" echo "" - echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" - echo " --zsh # Output prompt using Zsh style color characters" - echo " --bash # Output prompt using Bash style color characters" - echo " --fish # Output prompt using fish style color characters" + echo " --fetch # Fetches your repo asynchronously in the background every 5 mins" + echo " --zsh # Output prompt using Zsh style color characters" + echo " --bash # Output prompt using Bash style color characters" + echo " --fish # Output prompt using fish style color characters" echo "" echo "Bash example:" echo " export PS1=\"\\W\\\$(git-radar --bash --fetch) \"" -- cgit v1.2.3