-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: add --list-options and zsh completion
- Loading branch information
Showing
2 changed files
with
96 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#compdef _scrot scrot | ||
|
||
function _scrot() { | ||
local -a args | ||
local list=$($~words[1] --list-options) 2>/dev/null | ||
for ln in ${(f)list}; do | ||
IFS=$'\t' local tokens=( ${=ln} ) | ||
|
||
local desc="[${tokens[4]}]" | ||
|
||
# TODO: complete argument as well | ||
# local argtype=${tokens[3]%%:*} | ||
# local argdesc=${tokens[3]#*:} | ||
# case "$argtype" in | ||
# R) ;; # Required | ||
# O) ;; # Optional | ||
# N) ;; # None | ||
# esac | ||
|
||
if [ "${tokens[1]}" != " " ]; then | ||
args+=( "-${tokens[1]}${desc}" ) | ||
fi | ||
args+=( "--${tokens[2]}${desc}" ) | ||
done | ||
_arguments "${args[@]}" | ||
} |
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