Add bunch of tar option completions.
This commit is contained in:
parent
87227ceccd
commit
4f4c7f2d1f
@ -3,17 +3,17 @@
|
|||||||
have tar && {
|
have tar && {
|
||||||
_tar()
|
_tar()
|
||||||
{
|
{
|
||||||
local cur ext regex tar untar
|
local cur prev words ext regex tar untar
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
_get_comp_words_by_ref cur
|
_get_comp_words_by_ref cur prev words
|
||||||
|
|
||||||
if [ $COMP_CWORD -eq 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) )
|
COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case ${COMP_WORDS[1]} in
|
case ${words[1]} in
|
||||||
?(-)[cr]*f)
|
?(-)[cr]*f)
|
||||||
_filedir
|
_filedir
|
||||||
return 0
|
return 0
|
||||||
@ -40,19 +40,74 @@ _tar()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "$COMP_LINE" == *$ext' ' ]]; then
|
local split=false
|
||||||
# complete on files in tar file
|
_split_longopt && split=true
|
||||||
#
|
|
||||||
# get name of tar file from command line
|
|
||||||
tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"$COMP_LINE" )
|
|
||||||
# devise how to untar and list it
|
|
||||||
untar=t${COMP_WORDS[1]//[^IJzjyf]/}
|
|
||||||
|
|
||||||
local IFS=$'\n'
|
case $prev in
|
||||||
COMPREPLY=( $( compgen -W "$( printf '%s\n' $( tar $untar $tar \
|
*$ext)
|
||||||
2>/dev/null ) )" -- "$cur" ) )
|
# complete on files in tar file
|
||||||
return 0
|
#
|
||||||
fi
|
# get name of tar file from command line
|
||||||
|
tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"$COMP_LINE" )
|
||||||
|
# devise how to untar and list it
|
||||||
|
untar=t${words[1]//[^IJzjyf]/}
|
||||||
|
|
||||||
|
local IFS=$'\n'
|
||||||
|
COMPREPLY=( $( compgen -W "$( printf '%s\n' $( tar $untar $tar \
|
||||||
|
2>/dev/null ) )" -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-C|--directory)
|
||||||
|
_filedir -d
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--atime-preserve)
|
||||||
|
COMPREPLY=( $( compgen -W 'replace system' -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--group)
|
||||||
|
COMPREPLY=( $( compgen -g -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--owner)
|
||||||
|
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-F|--info-script|--new-volume-script|--rmt-command|--rsh-command|\
|
||||||
|
-I|--use-compress-program)
|
||||||
|
_compopt_o_filenames
|
||||||
|
COMPREPLY=( $( compgen -c -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--volno-file|--add-file|-T|--files-from|-X|--exclude-from|--index-file)
|
||||||
|
_filedir
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-H|--format)
|
||||||
|
COMPREPLY=( $( compgen -W 'gnu oldgnu pax posix ustar v7' \
|
||||||
|
-- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--quoting-style)
|
||||||
|
COMPREPLY=( $( compgen -W 'literal shell shell-always c c-maybe
|
||||||
|
escape locale clocale' -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--totals)
|
||||||
|
COMPREPLY=( $( compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \
|
||||||
|
-- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--occurrence|--sparse-version|--to-command|--mode|--mtime|\
|
||||||
|
--tape-length|-b|--blocking-factor|--record-size|-V|--text|--backup|\
|
||||||
|
--exclude|--exclude-tag*|-K|--starting-file|-N|--newer|--after-date|\
|
||||||
|
--suffix|--strip-components|--transform|--xform|--checkpoint|\
|
||||||
|
--checkpoint-action|--no-quote-chars|--quote-chars|--warnings)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$split && return 0
|
||||||
|
|
||||||
# file completion on relevant files
|
# file completion on relevant files
|
||||||
_filedir "$ext"
|
_filedir "$ext"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user