-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add completion for bash and fish shells
- Loading branch information
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
_dotref() | ||
{ | ||
local cur | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
|
||
if [ $COMP_CWORD -eq 1 ]; then | ||
COMPREPLY=($(compgen -W '-h --help init sync unlink status profiles version' -- $cur)) | ||
else | ||
case ${COMP_WORDS[1]} in | ||
init|sync|unlink|status|profiles) | ||
_dotref_opt_complete | ||
;; | ||
esac | ||
|
||
fi | ||
} | ||
|
||
_dotref_opt_complete() | ||
{ | ||
local cur | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
|
||
if [ $COMP_CWORD -ge 2 ]; then | ||
case ${COMP_WORDS[COMP_CWORD-1]} in | ||
-d|--dotdir) | ||
COMPREPLY=($(compgen -d -- $cur)) | ||
;; | ||
-s|--statefile|-p|--profile) | ||
COMPREPLY=($(compgen -f -- $cur)) | ||
;; | ||
*) | ||
COMPREPLY=($(compgen -W '-v --verbose -s --statefile -d --dotdir -p --profile' -- $cur)) | ||
;; | ||
esac | ||
fi | ||
} | ||
|
||
complete -o bashdefault -o default -F _dotref dotref |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
set -l commands -h --help init sync unlink status profiles version | ||
|
||
set -l h -s h -l help -d 'Print help message and exit' | ||
set -l v -s v -l verbose -d 'Produce more verbose output' | ||
set -l d -s d -l dotdir -d 'Directory containing profiles' -rF | ||
set -l s -s s -l statefile -d 'Dotref state file' -rF | ||
set -l p -s p -l profile -d 'Name of the profile to use' -rF | ||
|
||
complete -c dotref -f | ||
|
||
complete -c dotref -n "not __fish_seen_subcommand_from $commands" -a "$commands" | ||
|
||
for line in 'init: p d s v' \ | ||
'sync: d s v' \ | ||
'unlink: d s v' \ | ||
'status: d s v' \ | ||
'profiles: p d v' | ||
set -l command (echo "$line" | cut -d: -f1) | ||
|
||
for opt in (echo "$line" | cut -d: -f2 | string split -n ' ') | ||
complete -c dotref -n "__fish_seen_subcommand_from $command" $$opt | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters