forked from resurrecting-open-source-projects/scrot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 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
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,29 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2024 NRK <nrk@disroot.org> | ||
# | ||
# This is free and unencumbered software released into the public domain. | ||
# For more information, please refer to <https://unlicense.org/> | ||
|
||
_scrot_autocomp() { | ||
local -a _scrot_opt_list | ||
IFS=$'\n' _scrot_opt_list=( $(scrot --list-options=tsv) ) 2>/dev/null | ||
local _scrot_opts="" | ||
for ln in "${_scrot_opt_list[@]}"; do | ||
local -a tokens | ||
IFS=$'\t' tokens=( ${ln} ) | ||
|
||
local sopt="${tokens[0]}" | ||
local lopt="${tokens[1]}" | ||
# TODO: better support for flags that accept argument | ||
# local argtype=${tokens[2]%%:*} | ||
# local argdesc=${tokens[2]#*:} | ||
# local desc="[${tokens[3]}]" | ||
_scrot_opts+="--${lopt} " | ||
if [[ "$sopt" = [[:alnum:]]* ]]; then | ||
_scrot_opts+="-${sopt} " | ||
fi | ||
done | ||
printf "%s" "${_scrot_opts% }" | ||
} | ||
complete -W "$(_scrot_autocomp)" scrot |
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,30 @@ | ||
#compdef scrot | ||
# | ||
# Copyright 2024 NRK <nrk@disroot.org> | ||
# | ||
# This is free and unencumbered software released into the public domain. | ||
# For more information, please refer to <https://unlicense.org/> | ||
|
||
local -a args | ||
local list=$($~words[1] --list-options=tsv) 2>/dev/null | ||
for ln in ${(f)list}; do | ||
IFS=$'\t' local tokens=( ${=ln} ) | ||
|
||
local sopt="${tokens[1]}" | ||
local lopt="${tokens[2]}" | ||
local argtype=${tokens[3]%%:*} | ||
local argdesc=${tokens[3]#*:} | ||
local desc="[${tokens[4]}]" | ||
|
||
case "$argtype" in | ||
R) desc+=":$argdesc" ;; # Required | ||
O) sopt+="+"; lopt+="=" ;; # Optional | ||
N) ;; # None | ||
esac | ||
|
||
if [[ "${sopt}" = [[:alnum:]]* ]]; then | ||
args+=( "-${sopt}${desc}" ) | ||
fi | ||
args+=( "--${lopt}${desc}" ) | ||
done | ||
_arguments "${args[@]}" |