_cdremote_complete and _git_open are mostly the same -
refactor common code.
- # completion for cdremote - list remotes with directories as URLs
- _cdremote_complete() {
+ # completion for cdremote and git-open - list remotes with a pattern
+ _list_remotes_completion() {
local cur="${COMP_WORDS[COMP_CWORD]}";
local cur="${COMP_WORDS[COMP_CWORD]}";
- _list_remotes '^\(/\|\.\./\)' # (/ or ../ at the beginning)
COMPREPLY=(`compgen -W "$GIT_REMOTES" -- "$cur"`)
unset GIT_REMOTES
}
COMPREPLY=(`compgen -W "$GIT_REMOTES" -- "$cur"`)
unset GIT_REMOTES
}
+ # completion for cdremote - list remotes with directories as URLs
+ _cdremote_complete() {
+ _list_remotes_completion '^\(/\|\.\./\)' # (/ or ../ at the beginning)
+ }
+
complete -F _cdremote_complete cdremote
# completion for git-open - list remotes with http(s) URLs
_git_open() {
complete -F _cdremote_complete cdremote
# completion for git-open - list remotes with http(s) URLs
_git_open() {
- local cur="${COMP_WORDS[COMP_CWORD]}";
- _list_remotes '^http\(s\)\?://'
- COMPREPLY=(`compgen -W "$GIT_REMOTES" -- "$cur"`)
- unset GIT_REMOTES
+ _list_remotes_completion '^http\(s\)\?://'
}
complete -F _git_open git-open
}
complete -F _git_open git-open