File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,6 +190,25 @@ export PROMPT="$PROMPT\$(git-radar --zsh --fetch) "
190190```
191191[ (note: the ` \ ` escaping the ` $ ` is important)] ( #ensuring-prompt-execution )
192192
193+ You may also choose to fetch at a customized interval of time. To do so, add
194+ this to your .bashrc, .zshrc:
195+
196+ ``` bash
197+ export GIT_RADAR_FETCH_TIME=< seconds>
198+ ```
199+
200+ For example, to fetch every 30 seconds (instead of the default 5 minutes):
201+
202+ ``` bash
203+ export GIT_RADAR_FETCH_TIME=30
204+ ```
205+
206+ You can also do this in the gitradarrc file:
207+
208+ ``` bash
209+ GIT_RADAR_FETCH_TIME=30
210+ ```
211+
193212## Customise your prompt
194213
195214Git Radar is highly customisable using a prompt format string. The 4 features
@@ -235,6 +254,7 @@ The default prompt format uses this to add spaces only if the feature would
235254render. In that way the prompt always looks well spaced out no matter how many
236255features are rendering.
237256
257+
238258## Support
239259
240260### Ensuring prompt execution
Original file line number Diff line number Diff line change @@ -95,9 +95,11 @@ while [[ $# > 0 ]];do
9595 if [[ " $command " == " --fetch" ]]; then
9696 nohup $dot /fetch.sh > /dev/null 2>&1 &
9797 fi
98+
9899 if [[ " $command " == " --zsh" ]]; then
99100 $dot /prompt.zsh $args
100101 fi
102+
101103 if [[ " $command " == " --bash" || " $command " == " --fish" ]]; then
102104 $dot /prompt.bash $args
103105 fi
Original file line number Diff line number Diff line change @@ -14,6 +14,20 @@ timethis() {
1414 echo " $1 - $dur " >> $HOME /duration.dat
1515}
1616
17+ get_fetch_time () {
18+ if [ -f " $rcfile_path /.gitradarrc.bash" ]; then
19+ source " $rcfile_path /.gitradarrc.bash"
20+ elif [ -f " $rcfile_path /.gitradarrc.zsh" ]; then
21+ source " $rcfile_path /.gitradarrc.zsh"
22+ elif [ -f " $rcfile_path /.gitradarrc" ]; then
23+ source " $rcfile_path /.gitradarrc"
24+ fi
25+
26+ FETCH_TIME=" ${GIT_RADAR_FETCH_TIME:- " $(( 5 * 60 )) " } "
27+ echo $FETCH_TIME
28+
29+ }
30+
1731prepare_bash_colors () {
1832 if [ -f " $rcfile_path /.gitradarrc.bash" ]; then
1933 source " $rcfile_path /.gitradarrc.bash"
@@ -169,10 +183,10 @@ time_now() {
169183}
170184
171185time_to_update () {
186+ last_time_updated=" ${1:- $FETCH_TIME } "
172187 if is_repo; then
173188 local timesincelastupdate=" $(( $(time_now) - $(timestamp)) )"
174- local fiveminutes=" $(( 5 * 60 )) "
175- if (( $timesincelastupdate > $fiveminutes )) ; then
189+ if (( $timesincelastupdate > $last_time_updated )) ; then
176190 # time to update return 0 (which is true)
177191 return 0
178192 else
@@ -185,7 +199,10 @@ time_to_update() {
185199}
186200
187201fetch () {
188- if time_to_update; then
202+ # Gives $FETCH_TIME a value
203+ get_fetch_time
204+
205+ if time_to_update $FETCH_TIME ; then
189206 record_timestamp
190207 git fetch --quiet > /dev/null 2>&1
191208 fi
Original file line number Diff line number Diff line change @@ -63,12 +63,14 @@ test_record_timestamp_in_repo() {
6363
6464test_time_to_update_when_timestamp_is_old () {
6565 cd $scriptDir
66+ FETCH_TIME=" $(( 5 * 60 )) " # Fetch every 5 mins
6667 touch -A " -010000" " $( dot_git) /lastupdatetime"
6768 assertTrue time_to_update
6869}
6970
7071test_not_time_to_update_when_just_recorded () {
7172 cd $scriptDir
73+ FETCH_TIME=" $(( 5 * 60 )) " # Fetch every 5 mins
7274 record_timestamp
7375 assertFalse time_to_update
7476}
@@ -77,6 +79,7 @@ test_time_to_update_when_no_timestamp() {
7779 cd_to_tmp
7880 git init --quiet
7981
82+ FETCH_TIME=" $(( 5 * 60 )) " # Fetch every 5 mins
8083 time_to_update
8184 assertTrue time_to_update
8285
You can’t perform that action at this time.
0 commit comments