From 5bd121bd6dc3aaaa3d2a5a00aef1660f05bfcf07 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 20 May 2018 12:04:22 -0500 Subject: [PATCH] Fix unzip completions for non-Linux platforms --- share/completions/unzip.fish | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/share/completions/unzip.fish b/share/completions/unzip.fish index 4baf381c8..3973947f6 100644 --- a/share/completions/unzip.fish +++ b/share/completions/unzip.fish @@ -7,7 +7,7 @@ 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 exdir" +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" @@ -24,8 +24,19 @@ 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" -# the first non-switch argument should be the zipfile -complete -c unzip -n '__fish_is_first_token' -xa '(__fish_complete_suffix .zip)' -# files thereafter are either files to include or exclude from the operation -set -l zipfile -complete -c unzip -n 'not __fish_is_first_token' -xa '(unzip -l (eval set zipfile (__fish_first_token); echo $zipfile) | string replace -r --filter ".*:\S+\s+(.*)" "\$1")' +# Debian version of unzip +if unzip -h | string match -eq Debian + + # the first non-switch argument should be the zipfile + complete -c unzip -n '__fish_is_first_token' -xa '(__fish_complete_suffix .zip)' + + # Files thereafter are either files to include or exclude from the operation + set -l zipfile + complete -c unzip -n 'not __fish_is_first_token' -xa '(unzip -l (eval set zipfile (__fish_first_token); echo $zipfile) | string replace -r --filter ".*:\S+\s+(.*)" "\$1")' + +else + + # all tokens should be zip files + complete -c unzip -xa '(__fish_complete_suffix .zip)' + +end