diff --git a/share/completions/unrar.fish b/share/completions/unrar.fish new file mode 100644 index 000000000..8bf24190b --- /dev/null +++ b/share/completions/unrar.fish @@ -0,0 +1,15 @@ + +# Peek inside of archives and list all files +complete -c unrar -a "(__fish_complete_unrar)" + +complete -x -c unrar -n '__fish_use_subcommand' -a e -d (N_ "Extract files to current directory") +complete -x -c unrar -n '__fish_use_subcommand' -a l -d (N_ "List archive" ) +complete -x -c unrar -n '__fish_use_subcommand' -a lt -d (N_ "List archive (technical)" ) +complete -x -c unrar -n '__fish_use_subcommand' -a lb -d (N_ "List archive (bare)" ) +complete -x -c unrar -n '__fish_use_subcommand' -a p -d (N_ "Print file to stdout") +complete -x -c unrar -n '__fish_use_subcommand' -a t -d (N_ "Test archive files") +complete -x -c unrar -n '__fish_use_subcommand' -a v -d (N_ "Verbosely list archive") +complete -x -c unrar -n '__fish_use_subcommand' -a vt -d (N_ "Verbosely list archive (technical)") +complete -x -c unrar -n '__fish_use_subcommand' -a vb -d (N_ "Verbosely list archive (bare)") +complete -x -c unrar -n '__fish_use_subcommand' -a x -d (N_ "Extract files with full path") + diff --git a/share/functions/__fish_complete_unrar.fish b/share/functions/__fish_complete_unrar.fish new file mode 100644 index 000000000..b9a0fda16 --- /dev/null +++ b/share/functions/__fish_complete_unrar.fish @@ -0,0 +1,21 @@ + +function __fish_complete_unrar -d "Peek inside of archives and list all files" + + set -l cmd (commandline -poc) + set -e cmd[1] + for i in $cmd + switch $i + case '-*' + continue + + case '*.rar' + if test -f $i + set -l file_list (unrar vb $i) + printf (_ "%s\tArchived file\n") $file_list + end + return + end + end +end + +