This repository was archived by the owner on May 1, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ you can have grb auto-completion by using the {git-remote-branch plugin}[https:/
37
37
# ~/.zshrc
38
38
plugins=(git git-remote-branch ...)
39
39
40
+ If you use bash, you can have grb auto-completion by souring `etc/grb-completion.bash`
41
+
42
+ # ~/.bash_profile
43
+ source `gem contents git_remote_branch | grep grb-completion.bash`
44
+
45
+ or copy it to your desired destination and source it.
46
+
40
47
== Usage
41
48
42
49
Notes:
Original file line number Diff line number Diff line change
1
+ _grb ()
2
+ {
3
+ local cur=${COMP_WORDS[COMP_CWORD]}
4
+ local verb=${COMP_WORDS[1]}
5
+
6
+ local position=${COMP_CWORD}
7
+
8
+ if [[ " $verb " == " explain" ]]; then
9
+ let " position = $position - 1"
10
+ fi
11
+
12
+ case " $position " in
13
+ 1)
14
+ COMPREPLY=( $( compgen -W " help explain create new delete destroy kill remove rm rename rn mv move track follow grab fetch" -- $cur ) )
15
+ ;;
16
+ 2)
17
+
18
+ COMPREPLY=( $( compgen -W " $( _grb_branch) " -- $cur ) )
19
+ ;;
20
+ 3)
21
+
22
+ COMPREPLY=( $( compgen -W " $( _grb_remotes) " -- $cur ) )
23
+ ;;
24
+ esac
25
+ }
26
+
27
+ _grb_branch ()
28
+ {
29
+ {
30
+ git for-each-ref refs/remotes --format=" %(refname:short)" |
31
+ grep -v HEAD |
32
+ sed ' s/^.*\///g' ;
33
+ git for-each-ref refs/heads --format=" %(refname:short)" ;
34
+ } | sort | uniq
35
+ }
36
+
37
+ _grb_remotes ()
38
+ {
39
+ local i IFS=$' \n '
40
+ for i in $( git config --get-regexp ' remote\..*\.url' 2> /dev/null) ; do
41
+ i=" ${i# remote.} "
42
+ echo " ${i/ .url*/ } "
43
+ done
44
+ }
45
+
46
+ complete -F _grb grb
47
+
You can’t perform that action at this time.
0 commit comments