-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gm: New completion, commands only for now
- Loading branch information
Showing
5 changed files
with
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ bashcomp_DATA = 2to3 \ | |
genisoimage \ | ||
getent \ | ||
gkrellm \ | ||
gm \ | ||
gnatmake \ | ||
gnokii \ | ||
gnome-mplayer \ | ||
|
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,40 @@ | ||
# bash completion for gm(1) -*- shell-script -*- | ||
|
||
_gm_commands() | ||
{ | ||
COMPREPLY+=( $( compgen -W '$( "$1" help | | ||
awk "/^ +[^ ]+ +- / { print \$1 }" )' -- "$cur" ) ) | ||
} | ||
|
||
_gm() | ||
{ | ||
local cur prev words cword | ||
_init_completion || return | ||
|
||
if [[ $cword -eq 1 ]]; then | ||
_gm_commands "$1" | ||
return | ||
elif [[ $cword -eq 2 && ${words[1]} == time ]]; then | ||
_gm_commands "$1" | ||
return | ||
fi | ||
|
||
local gmcmd=${words[1]} | ||
[[ $gmcmd == time ]] && gmcmd=${words[2]} | ||
|
||
case $gmcmd in | ||
help) | ||
[[ $prev == help ]] && _gm_commands "$1" | ||
return | ||
;; | ||
version) | ||
return | ||
;; | ||
esac | ||
|
||
# TODO... defer some commnds to the imagemagick "gm"less completions etc? | ||
compopt -o default | ||
} && | ||
complete -F _gm gm | ||
|
||
# ex: filetype=sh |
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 @@ | ||
assert_source_completions gm |
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,27 @@ | ||
proc setup {} { | ||
save_env | ||
} | ||
|
||
|
||
proc teardown {} { | ||
assert_env_unmodified | ||
} | ||
|
||
|
||
setup | ||
|
||
|
||
assert_complete_any "gm " | ||
sync_after_int | ||
|
||
assert_complete_any "gm help " | ||
sync_after_int | ||
|
||
assert_complete_any "gm time " | ||
sync_after_int | ||
|
||
assert_no_complete "gm version " | ||
sync_after_int | ||
|
||
|
||
teardown |