2019-05-05 18:53:09 +08:00
|
|
|
complete -c unzip -s p -d "extract files to pipe, no messages"
|
|
|
|
complete -c unzip -s f -d "freshen existing files, create none"
|
|
|
|
complete -c unzip -s u -d "update files, create if necessary"
|
|
|
|
complete -c unzip -s v -d "list verbosely/show version info"
|
|
|
|
complete -c unzip -s x -d "exclude files that follow (in xlist)"
|
|
|
|
complete -c unzip -s l -d "list files (short format)"
|
|
|
|
complete -c unzip -s t -d "test compressed archive datamodifiers:"
|
|
|
|
complete -c unzip -s z -d "display archive comment only"
|
|
|
|
complete -c unzip -s T -d "timestamp archive to latest"
|
|
|
|
complete -c unzip -s d -d "extract files into dir" -xa '(__fish_complete_directories)'
|
|
|
|
complete -c unzip -s n -d "never overwrite existing files"
|
|
|
|
complete -c unzip -s o -d "overwrite files WITHOUT prompting"
|
|
|
|
complete -c unzip -s q -d "quiet mode"
|
2018-05-20 14:22:16 +08:00
|
|
|
complete -c unzip -o qq -d "quieter mode"
|
2019-05-05 18:53:09 +08:00
|
|
|
complete -c unzip -s a -d "auto-convert any text files"
|
|
|
|
complete -c unzip -s U -d "use escapes for all non-ASCII Unicode"
|
2018-05-20 14:22:16 +08:00
|
|
|
complete -c unzip -o UU -d "ignore any Unicode fields"
|
2019-05-05 18:53:09 +08:00
|
|
|
complete -c unzip -s j -d "junk paths (do not make directories)"
|
2018-05-20 14:22:16 +08:00
|
|
|
complete -c unzip -s aa -d "treat ALL files as text"
|
2019-05-05 18:53:09 +08:00
|
|
|
complete -c unzip -s C -d "match filenames case-insensitively"
|
|
|
|
complete -c unzip -s L -d "make (some) names lowercase"
|
|
|
|
complete -c unzip -s X -d "restore UID/GID info"
|
|
|
|
complete -c unzip -s V -d "retain VMS version numbers"
|
|
|
|
complete -c unzip -s K -d "keep setuid/setgid/tacky permissions"
|
|
|
|
complete -c unzip -s M -d "pipe through `more` pager"
|
2023-06-19 03:27:29 +08:00
|
|
|
# Some distros have -O and -I, some don't.
|
|
|
|
# Even "-h" might not be available.
|
|
|
|
if unzip -h 2>/dev/null | string match -rq -- -O
|
2023-06-19 03:04:43 +08:00
|
|
|
complete -c unzip -s O -d "specify a character encoding for DOS, Windows and OS/2 archives" -x -a "(__fish_print_encodings)"
|
|
|
|
end
|
2023-06-19 03:27:29 +08:00
|
|
|
if unzip -h 2>/dev/null | string match -rq -- -I
|
2023-06-19 03:04:43 +08:00
|
|
|
complete -c unzip -s I -d "specify a character encoding for UNIX and other archives" -x -a "(__fish_print_encodings)"
|
|
|
|
end
|
2018-05-20 14:22:16 +08:00
|
|
|
|
2018-05-21 01:04:22 +08:00
|
|
|
# Debian version of unzip
|
2018-06-04 03:53:13 +08:00
|
|
|
if unzip -v 2>/dev/null | string match -eq Debian
|
2020-12-13 14:28:53 +08:00
|
|
|
|
|
|
|
# the first non-switch argument should be the zipfile
|
2023-02-24 10:18:08 +08:00
|
|
|
complete -c unzip -n "__fish_is_nth_token 1" -k -xa '(__fish_complete_suffix .zip .jar .aar)'
|
2020-12-13 14:28:53 +08:00
|
|
|
|
|
|
|
# Files thereafter are either files to include or exclude from the operation
|
2019-05-05 18:53:09 +08:00
|
|
|
set -l zipfile
|
2022-10-21 10:45:49 +08:00
|
|
|
complete -c unzip -n 'not __fish_is_nth_token 1' -xa '(unzip -l (eval set zipfile (__fish_first_token); echo $zipfile) 2>/dev/null | string replace -r --filter ".*:\S+\s+(.*)" "\$1")'
|
2020-12-13 14:28:53 +08:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# all tokens should be zip files
|
2023-02-24 10:18:08 +08:00
|
|
|
complete -c unzip -k -xa '(__fish_complete_suffix .zip .jar .aar)'
|
2020-12-13 14:28:53 +08:00
|
|
|
|
2018-05-21 01:04:22 +08:00
|
|
|
end
|