completions: add xxd

Closes #10137
This commit is contained in:
Amy Grace 2023-12-05 12:08:33 -07:00 committed by Johannes Altmanninger
parent 03198b7fd3
commit 36ed2b79c2
2 changed files with 35 additions and 0 deletions

View File

@ -77,6 +77,7 @@ Completions
- ``userdel`` (:issue:`10056`)
- ``watchexec`` (:issue:`10027`)
- ``wpctl`` (:issue:`10043`)
- ``xxd`` (:issue:`10137`)
- ``zabbix`` (:issue:`9647`)
- The ``zfs`` completions no longer print errors about setting a read-only variable (:issue:`9705`).
- The ``kitty`` completions have been removed in favor of keeping them upstream (:issue:`9750`).

View File

@ -0,0 +1,34 @@
function __fish_seen_any_argument
# Returns true if none of the switch names appear in the command line.
for arg in $argv
switch (string length $arg)
case 2
__fish_seen_argument -o $arg; and return 1
case 1
__fish_seen_argument -s $arg; and return 1
case '*'
__fish_seen_argument -l $arg; and return 1
end
end
end
set -l xxd_exclusive_args b e i ps r
complete -c xxd -s a -d 'Toggle autoskip'
complete -c xxd -s b -n "__fish_seen_any_argument $xxd_exclusive_args" -d 'Binary digit dump'
complete -c xxd -s C -n '__fish_seen_argument -s i' -d 'Capitalize variable names'
complete -c xxd -s c -xa '(seq 8 8 64)' -d 'Format COLS octets per line, default 16'
complete -c xxd -s E -d 'Show characters in EBCDIC'
complete -c xxd -s e -n "__fish_seen_any_argument $xxd_exclusive_args" -d 'Little-endian dump'
complete -c xxd -s g -xa '1 2 4' -d 'Octets per group in normal output, default 2'
complete -c xxd -s h -d 'Print help summary'
complete -c xxd -s i -n "__fish_seen_any_argument $xxd_exclusive_args" -d 'Output C-include file style'
complete -c xxd -s l -d 'Stop after NUM octets'
complete -c xxd -s o -x -d 'Add OFFSET to the displayed file position'
complete -c xxd -o ps -n "__fish_seen_any_argument $xxd_exclusive_args" -d 'Output PostScript/plain hexdump style'
complete -c xxd -s r -d 'Reverse operation: convert hexdump into binary'
complete -c xxd -s s -xa '-32 -8 +8 +32' -n 'not __fish_seen_argument -s r' -d 'Start at SEEK bytes offset in file'
complete -c xxd -s s -xa '-32 -8 +8 +32' -n '__fish_seen_argument -s r' -d 'Add OFFSET to file positions in hexdump'
complete -c xxd -s d -d 'Show offset in decimal, not hex'
complete -c xxd -s u -d 'Use uppercase hex letters'
complete -c xxd -s v -d 'Show version'