diff options
author | Oliver Kiddle <opk@zsh.org> | 2021-11-24 23:07:18 +0100 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2021-11-24 23:09:38 +0100 |
commit | 16d5d6a9dae526355caf16f2de9d57d84b5d9993 (patch) | |
tree | 6ab30a2ad2596523b85aa553ffa8a4544632fd7a /Completion/Unix/Command/_tail | |
parent | 138f5bf144589a59ef009f26332652291cd0a944 (diff) | |
download | zsh-16d5d6a9dae526355caf16f2de9d57d84b5d9993.tar.gz zsh-16d5d6a9dae526355caf16f2de9d57d84b5d9993.zip |
49597: add a helper for completing numbers with unit suffixes and separate out defaults, ranges and units in completion descriptions
Diffstat (limited to 'Completion/Unix/Command/_tail')
-rw-r--r-- | Completion/Unix/Command/_tail | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/Completion/Unix/Command/_tail b/Completion/Unix/Command/_tail index 6d6e9b2d5..e54a0b06e 100644 --- a/Completion/Unix/Command/_tail +++ b/Completion/Unix/Command/_tail @@ -53,20 +53,14 @@ _arguments -C -s -S $opts : $args '*:file:_files' && return case $state in (number) - local mlt sign digit - mlt='multipliers:multiplier:((b\:512 K\:1024 KB\:1000 M\:1024\^2' - mlt+=' MB\:1000\^2 G\:1024\^3 GB\:1000\^3 T\:1024\^4 TB\:1000\^4))' - sign='signs:sign:((+\:"start at the specified byte/line"' - sign+=' -\:"output the last specified bytes/lines (default)"))' - digit='digits:digit:(0 1 2 3 4 5 6 7 8 9)' - if compset -P '(-|+|)[0-9]##'; then - _alternative $mlt $digit && ret=0 - elif [[ -z $PREFIX ]]; then - _alternative $sign $digit && ret=0 - elif compset -P '(+|-)'; then - _alternative $digit && ret=0 - fi - ;; + local alts + [[ -z $PREFIX ]] && alts=( + 'sign:sign:((-\:"print all but the last specified bytes/lines" +\:"print the first specified bytes/lines (default)"))' + ) + compset -P '+' + alts+=( 'numbers: :_numbers -N $state_descr b\:512 K\:1024 KB\:1000 M\:1024\^2 MB\:1000\^2 G\:1024\^3 GB\:1000\^3 T\:1024\^4 TB\:1000\^4' ) + _alternative $alts && ret=0 + ;; esac return ret |