Cleanups: Make code more compact.

Drop useless spaces, backslashes, return codes, unused arguments etc.
master
Igor Murzov 2011-11-20 17:00:03 +03:00
parent 03c2fe9301
commit f0283e1c1b
17 changed files with 154 additions and 159 deletions

View File

@ -1625,7 +1625,7 @@ _command_offset()
for (( i; i <= COMP_CWORD; i++ )); do for (( i; i <= COMP_CWORD; i++ )); do
unset COMP_WORDS[i] unset COMP_WORDS[i]
done done
COMP_CWORD=$(( $COMP_CWORD - $word_offset )) ((COMP_CWORD -= $word_offset))
COMPREPLY=() COMPREPLY=()
local cur local cur
@ -1696,7 +1696,7 @@ _root_command()
{ {
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
local root_command=$1 local root_command=$1
_command $1 $2 $3 _command
} }
complete -F _root_command fakeroot gksu gksudo kdesudo really sudo complete -F _root_command fakeroot gksu gksudo kdesudo really sudo

View File

@ -8,17 +8,17 @@ _fbgs()
case "$prev" in case "$prev" in
-f) -f)
local IFS=$'\n' local IFS=$'\n'
COMPREPLY=( $( compgen -W '$( fc-list 2>/dev/null )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") )
return return
;; ;;
-m) -m)
COMPREPLY=( $( compgen -W '$( sed \ COMPREPLY=( $(compgen -W '$(sed \
-n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \
/etc/fb.modes 2> /dev/null )' -- "$cur" ) ) /etc/fb.modes 2> /dev/null)' -- "$cur") )
return return
;; ;;
-d) -d)
COMPREPLY=( $( compgen -f -d -- "${cur:-/dev/}" ) ) COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") )
return return
;; ;;
-t|-g|-p) -t|-g|-p)
@ -28,7 +28,7 @@ _fbgs()
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W '-l -xl -xxl -a --fitwidth -d -m -t -g -f -p \ COMPREPLY=( $(compgen -W '-l -xl -xxl -a --fitwidth -d -m -t -g -f -p
-h -c' -- "$cur") ) -h -c' -- "$cur") )
[[ $COMPREPLY ]] && return [[ $COMPREPLY ]] && return
fi fi

View File

@ -16,17 +16,17 @@ _fbi()
;; ;;
-f|--font) -f|--font)
local IFS=$'\n' local IFS=$'\n'
COMPREPLY=( $( compgen -W '$( fc-list 2>/dev/null )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$(fc-list 2> /dev/null)' -- "$cur") )
return return
;; ;;
-m|--mode) -m|--mode)
COMPREPLY=( $( compgen -W '$( sed \ COMPREPLY=( $(compgen -W '$(sed \
-n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \
/etc/fb.modes 2> /dev/null )' -- "$cur" ) ) /etc/fb.modes 2> /dev/null)' -- "$cur") )
return return
;; ;;
-d|--device) -d|--device)
COMPREPLY=( $( compgen -f -d -- "${cur:-/dev/}" ) ) COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") )
return return
;; ;;
--cachemem|--blend|-T|--vt|-s|--scroll|-t|--timeout|-g|--gamma) --cachemem|--blend|-T|--vt|-s|--scroll|-t|--timeout|-g|--gamma)
@ -36,12 +36,11 @@ _fbi()
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W '--help --version --store --list --text \ COMPREPLY=( $(compgen -W '--help --version --store --list --text
--autozoom --autoup --noautoup --autodown --noautodown --fitwidth \ --autozoom --{,no}autoup --{,no}autodown --{,no}fitwidth
--nofitwidth --verbose --noverbose --random --norandom --comments \ --{,no}verbose --{,no}random --{,no}comments --{,no}edit
--nocomments --edit --noedit --backup --nobackup --preserve \ --{,no}backup --{,no}preserve --{,no}readahead --cachemem --blend
--nopreserve --readahead --noreadahead --cachemem --blend --vt \ --vt --scroll --timeout --{,no}once --resolution --gamma --font
--scroll --timeout --once --noonce --resolution --gamma --font \
--device --mode' -- "$cur") ) --device --mode' -- "$cur") )
[[ $COMPREPLY ]] && return [[ $COMPREPLY ]] && return
fi fi

View File

@ -7,11 +7,11 @@ _feh()
case "$prev" in case "$prev" in
-B|--image-bg) -B|--image-bg)
COMPREPLY=( $( compgen -W 'default white black' -- "$cur" ) ) COMPREPLY=( $(compgen -W 'default white black' -- "$cur") )
return return
;; ;;
--index-dim|--index-name|--index-size) --index-dim|--index-name|--index-size)
COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) ) COMPREPLY=( $(compgen -W '0 1' -- "$cur") )
return return
;; ;;
-f|--filelist|-o|--output|-O|--output-only|-\||--start-at) -f|--filelist|-o|--output|-O|--output-only|-\||--start-at)
@ -51,13 +51,13 @@ _feh()
if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then
continue continue
fi fi
COMPREPLY+=( $( compgen -W "$theme_name" -- "$cur" ) ) COMPREPLY+=( $(compgen -W "$theme_name" -- "$cur") )
done < "$conf_path" done < "$conf_path"
return return
;; ;;
-S|--sort) -S|--sort)
COMPREPLY=( $( compgen -W 'name filename width height pixels size COMPREPLY=( $(compgen -W 'name filename width height pixels size
format' -- "$cur" ) ) format' -- "$cur") )
return return
;; ;;
-R|--reload|-H|--limit-height|-W|--limit-width|-E|--thumb-height|\ -R|--reload|-H|--limit-height|-W|--limit-width|-E|--thumb-height|\
@ -78,16 +78,16 @@ _feh()
;; ;;
-0|--reload-button|-1|--pan-button|-2|--zoom-button|-3|--menu-button|\ -0|--reload-button|-1|--pan-button|-2|--zoom-button|-3|--menu-button|\
-4|--prev-button|-5|--next-button|-8|--rotate-button|-9|--blur-button) -4|--prev-button|-5|--next-button|-8|--rotate-button|-9|--blur-button)
COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") )
return return
;; ;;
-a|--alpha) -a|--alpha)
COMPREPLY=( $( compgen -W '{0..255}' -- "$cur" ) ) COMPREPLY=( $(compgen -W '{0..255}' -- "$cur") )
return return
;; ;;
-b|--bg) -b|--bg)
_filedir _filedir
COMPREPLY+=( $( compgen -W 'trans' -- "$cur" ) ) COMPREPLY+=( $(compgen -W 'trans' -- "$cur") )
return return
;; ;;
-g|--geometry) -g|--geometry)
@ -108,7 +108,7 @@ _feh()
$split && return $split && return
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace
[[ $COMPREPLY ]] && return [[ $COMPREPLY ]] && return
fi fi

View File

@ -8,29 +8,29 @@ _kcov()
case "$prev" in case "$prev" in
--pid|-p) --pid|-p)
_pids _pids
return 0 return
;; ;;
--sort-type|-s) --sort-type|-s)
COMPREPLY=( $( compgen -W 'filename percentage' -- "$cur" ) ) COMPREPLY=( $(compgen -W 'filename percentage' -- "$cur") )
return 0 return
;; ;;
--include-path|--exclude-path) --include-path|--exclude-path)
_filedir _filedir
return 0 return
;; ;;
--limits|-l|--title|-t|--include-pattern|--exclude-pattern|\ --limits|-l|--title|-t|--include-pattern|--exclude-pattern|\
--path-strip-level) --path-strip-level)
# argument required but no completions available # argument required but no completions available
return 0 return
;; ;;
esac esac
$split && return 0 $split && return
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return
fi fi
_filedir _filedir

View File

@ -24,7 +24,7 @@ _pgrep()
esac esac
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$( _parse_usage "$1" )' -- "$cur") )
return return
fi fi

View File

@ -4,20 +4,19 @@ _removepkg()
{ {
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ $cur == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-copy -keep -preserve -warn' \ COMPREPLY=( $(compgen -W '-copy -keep -preserve -warn' -- "$cur") )
-- "$cur" ) ) return
return 0
fi fi
if [[ $cur == */* ]]; then if [[ "$cur" == */* ]]; then
_filedir _filedir
return 0 return
fi fi
local root=${ROOT:-/} local root=${ROOT:-/}
COMPREPLY=( $( cd "$root/var/log/packages" 2> /dev/null || return 1 ; \ COMPREPLY=( $(cd "$root/var/log/packages" 2> /dev/null || return 1; \
compgen -f -- "$cur" ) ) compgen -f -- "$cur") )
} && } &&
complete -F _removepkg removepkg complete -F _removepkg removepkg

View File

@ -6,11 +6,11 @@ _rpm2tgz()
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-s -S -n -r -d -c' -- "$cur" ) ) COMPREPLY=( $(compgen -W '-s -S -n -r -d -c' -- "$cur") )
return 0 return
fi fi
COMPREPLY=( $(compgen -f -X "!*.rpm" -- "$cur") ) _filedir "rpm"
} && complete -F _rpm2tgz -o plusdirs rpm2tgz rpm2txz rpm2targz } && complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz
# ex: ts=4 sw=4 et filetype=sh # ex: ts=4 sw=4 et filetype=sh

View File

@ -6,33 +6,33 @@ _sbopkg()
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b -c -d -e -f -g -h -i -k -l \ COMPREPLY=( $(compgen -W '-b -c -d -e -f -g -h -i -k -l -o
-o -P -p -q -R -r -s -u -V -v' -- "$cur" ) ) -P -p -q -R -r -s -u -V -v' -- "$cur") )
return 0 return
fi fi
case "$prev" in case "$prev" in
-e) -e)
COMPREPLY=( $( compgen -W 'ask continue stop' -- "$cur" ) ) COMPREPLY=( $(compgen -W 'ask continue stop' -- "$cur") )
return 0 return
;; ;;
-f) -f)
_filedir _filedir
return 0 return
;; ;;
-d) -d)
_filedir -d _filedir -d
return 0 return
;; ;;
-V) -V)
COMPREPLY=( $( compgen -W "? \ COMPREPLY=( $(compgen -W "? \
$(sbopkg -V ? 2>&1 | cut -s -f1)" -- "$cur" ) ) $(sbopkg -V ? 2>&1 | cut -s -f1)" -- "$cur") )
return 0 return
;; ;;
-i|-b) -i|-b)
;; ;;
*) *)
return 0 return
;; ;;
esac esac
@ -45,8 +45,8 @@ _sbopkg()
fi fi
done done
if [[ ! -r $config ]]; then if [[ ! -r "$config" ]]; then
return 0 return
fi fi
. $config . $config
@ -64,11 +64,11 @@ _sbopkg()
done done
if [[ ! -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]]; then if [[ ! -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]]; then
return 0 return
fi fi
COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ COMPREPLY=( $(sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\
$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ) $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT)
$( cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur" ) ) $(cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur") )
} && complete -F _sbopkg sbopkg } && complete -F _sbopkg sbopkg
# ex: ts=4 sw=4 et filetype=sh # ex: ts=4 sw=4 et filetype=sh

View File

@ -16,35 +16,35 @@ _slackpkg()
case "$prev" in case "$prev" in
-delall|-checkmd5|-checkgpg|-checksize|-postinst|-onoff|-download_all|\ -delall|-checkmd5|-checkgpg|-checksize|-postinst|-onoff|-download_all|\
-dialog|-batch|-only_new_dotnew|-use_includes|-spinning) -dialog|-batch|-only_new_dotnew|-use_includes|-spinning)
COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
return 0 return
;; ;;
-default_answer) -default_answer)
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) ) COMPREPLY=( $(compgen -W 'yes no' -- "$cur") )
return 0 return
;; ;;
-dialog_maxargs|-mirror) -dialog_maxargs|-mirror)
# argument required but no completions available # argument required but no completions available
return 0 return
;; ;;
esac esac
$split && return 0 $split && return
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
compopt -o nospace compopt -o nospace
COMPREPLY=( $( compgen -W '-delall= -checkmd5= -checkgpg= \ COMPREPLY=( $(compgen -W '-delall= -checkmd5= -checkgpg=
-checksize= -postinst= -onoff= -download_all= -dialog= \ -checksize= -postinst= -onoff= -download_all= -dialog=
-dialog_maxargs= -batch= -only_new_dotnew= -use_includes= \ -dialog_maxargs= -batch= -only_new_dotnew= -use_includes=
-spinning= -default_answer= -mirror=' -- "$cur" ) ) -spinning= -default_answer= -mirror=' -- "$cur") )
return 0 return
fi fi
local confdir="/etc/slackpkg" local confdir="/etc/slackpkg"
local config="$confdir/slackpkg.conf" local config="$confdir/slackpkg.conf"
if [[ ! -r $config ]]; then if [[ ! -r "$config" ]]; then
return 0 return
fi fi
. "$config" . "$config"
@ -59,47 +59,47 @@ _slackpkg()
case "$action" in case "$action" in
generate-template|search|file-search) generate-template|search|file-search)
# argument required but no completions available # argument required but no completions available
return 0 return
;; ;;
install-template|remove-template) install-template|remove-template)
if [[ -e $confdir/templates ]]; then if [[ -e $confdir/templates ]]; then
COMPREPLY=( $( cd "$confdir/templates"; \ COMPREPLY=( $(cd "$confdir/templates"; \
compgen -f -X "!*.template" -- "$cur" ) ) compgen -f -X "!*.template" -- "$cur") )
COMPREPLY=( ${COMPREPLY[@]%.template} ) COMPREPLY=( ${COMPREPLY[@]%.template} )
fi fi
return 0 return
;; ;;
remove) remove)
_filedir _filedir
COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \ COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x
xap y' -- "$cur" ) ) xap y' -- "$cur") )
COMPREPLY+=( $( cd /var/log/packages; compgen -f -- "$cur" ) ) COMPREPLY+=( $(cd /var/log/packages; compgen -f -- "$cur") )
return 0 return
;; ;;
install|reinstall|upgrade|blacklist|download) install|reinstall|upgrade|blacklist|download)
_filedir _filedir
COMPREPLY+=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \ COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x
xap y' -- "$cur" ) ) xap y' -- "$cur") )
COMPREPLY+=( $( cut -f 6 -d\ ${WORKDIR}/pkglist 2> /dev/null | \ COMPREPLY+=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2> /dev/null | \
grep "^$cur" ) ) grep "^$cur") )
return 0 return
;; ;;
info) info)
COMPREPLY+=( $( cut -f 6 -d\ ${WORKDIR}/pkglist 2> /dev/null | \ COMPREPLY=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2> /dev/null | \
grep "^$cur" ) ) grep "^$cur") )
return 0 return
;; ;;
update) update)
# we should complete the same as the next `list` + "gpg" # we should complete the same as the next `list` + "gpg"
COMPREPLY=( $( compgen -W 'gpg' -- "$cur" ) ) COMPREPLY=( $(compgen -W 'gpg' -- "$cur") )
;& ;&
*) *)
COMPREPLY+=( $( compgen -W 'install reinstall upgrade remove \ COMPREPLY+=( $(compgen -W 'install reinstall upgrade remove
blacklist download update install-new upgrade-all \ blacklist download update install-new upgrade-all
clean-system new-config check-updates help generate-template \ clean-system new-config check-updates help generate-template
install-template remove-template search file-search info' -- \ install-template remove-template search file-search info' -- \
"$cur" ) ) "$cur") )
return 0 return
;; ;;
esac esac

View File

@ -8,18 +8,18 @@ _slapt_get()
case "$prev" in case "$prev" in
--config|-c) --config|-c)
_filedir _filedir
return 0 return
;; ;;
--retry|--search) --retry|--search)
# argument required but no completions available # argument required but no completions available
return 0 return
;; ;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace
[[ $COMPREPLY ]] && return 0 [[ $COMPREPLY ]] && return
fi fi
local i t local i t
@ -48,7 +48,7 @@ _slapt_get()
break break
fi fi
done done
if [[ ! -r $config ]]; then if [[ ! -r "$config" ]]; then
return return
fi fi
@ -57,23 +57,23 @@ _slapt_get()
# slapt-get will fail to search for "^name-version" # slapt-get will fail to search for "^name-version"
# it can search for names only # it can search for names only
local name=${cur%%-*} local name=${cur%%-*}
COMPREPLY=( $( slapt-get -c $config --search "^$name" 2>/dev/null |\ COMPREPLY=( $(slapt-get -c $config --search "^$name" 2>/dev/null |\
sed -ne "/^$cur/{s/ .*$//;p}" ) ) sed -ne "/^$cur/{s/ .*$//;p}") )
return 0 return
;; ;;
avl) # --install|-i| avl) # --install|-i|
COMPREPLY=( $( slapt-get -c $config --available 2>/dev/null | \ COMPREPLY=( $(slapt-get -c $config --available 2>/dev/null | \
sed -ne "/^$cur/{s/ .*$//;p}") ) sed -ne "/^$cur/{s/ .*$//;p}") )
return 0 return
;; ;;
ins) # --remove|--filelist ins) # --remove|--filelist
COMPREPLY=( $( cd /var/log/packages; compgen -f -- "$cur" ) ) COMPREPLY=( $(cd /var/log/packages; compgen -f -- "$cur") )
return 0 return
;; ;;
set) # --install-set set) # --install-set
COMPREPLY=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \ COMPREPLY=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x
xap y' -- "$cur" ) ) xap y' -- "$cur") )
return 0 return
;; ;;
esac esac
} && complete -F _slapt_get slapt-get } && complete -F _slapt_get slapt-get

View File

@ -8,18 +8,18 @@ _slapt_src()
case "$prev" in case "$prev" in
--config|-c) --config|-c)
_filedir _filedir
return 0 return
;; ;;
--search|-s|--postprocess|-p) --search|-s|--postprocess|-p)
# argument required but no completions available # argument required but no completions available
return 0 return
;; ;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace
[[ $COMPREPLY ]] && return 0 [[ $COMPREPLY ]] && return
fi fi
local i t local i t
@ -31,7 +31,7 @@ _slapt_src()
fi fi
done done
if [[ $t != all ]]; then if [[ $t != all ]]; then
return 0 return
fi fi
local config="/etc/slapt-get/slapt-srcrc" # default config location local config="/etc/slapt-get/slapt-srcrc" # default config location
@ -42,18 +42,18 @@ _slapt_src()
break break
fi fi
done done
if [[ ! -r $config ]]; then if [[ ! -r "$config" ]]; then
return 0 return
fi fi
if [[ "$cur" == *:* ]]; then if [[ "$cur" == *:* ]]; then
local name=${cur%:*} local name=${cur%:*}
local version=${cur##*:} local version=${cur##*:}
COMPREPLY=( $( slapt-src --config $config --search "^$name" 2> \ COMPREPLY=( $(slapt-src --config "$config" --search "^$name" 2> \
/dev/null | sed -ne "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}" ) ) /dev/null | sed -ne "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}") )
else else
COMPREPLY=( $( slapt-src --config $config --search "^$cur" 2>/dev/null \ COMPREPLY=( $(slapt-src --config "$config" --search "^$cur" 2> \
| sed -ne "/^$cur/{s/ .*$//;p}" ) ) /dev/null | sed -ne "/^$cur/{s/ .*$//;p}") )
fi fi
} && complete -F _slapt_src slapt-src } && complete -F _slapt_src slapt-src

View File

@ -6,9 +6,9 @@ _upgradepkg()
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--dry-run --install-new --reinstall \ COMPREPLY=( $(compgen -W '--dry-run --install-new --reinstall
--verbose' -- "$cur") ) --verbose' -- "$cur") )
return 0 return
fi fi
if [[ "$cur" == ?*%* ]]; then if [[ "$cur" == ?*%* ]]; then
@ -16,11 +16,11 @@ _upgradepkg()
cur="${cur#*%}" cur="${cur#*%}"
local nofiles IFS=$'\n' local nofiles IFS=$'\n'
compopt -o filenames compopt -o filenames
COMPREPLY=( $( compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur" ) ) COMPREPLY=( $(compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur") )
[[ $COMPREPLY ]] || nofiles=1 [[ $COMPREPLY ]] || nofiles=1
COMPREPLY+=( $( compgen -P "$prev%" -S '/' -d -- "$cur" ) ) COMPREPLY+=( $(compgen -P "$prev%" -S '/' -d -- "$cur") )
[[ $nofiles ]] && compopt -o nospace [[ $nofiles ]] && compopt -o nospace
return 0 return
fi fi
_filedir "t[bglx]z" _filedir "t[bglx]z"

View File

@ -5,7 +5,7 @@ _wine()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cword" -eq 1 ]]; then if [[ $cword -eq 1 ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) COMPREPLY=( $(compgen -W '--help --version' -- "$cur") )
[[ $COMPREPLY ]] && return [[ $COMPREPLY ]] && return

View File

@ -9,7 +9,7 @@ _xgamma()
-screen) -screen)
local screens=$(xrandr --query 2>/dev/null | \ local screens=$(xrandr --query 2>/dev/null | \
sed -n '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null) sed -n '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null)
COMPREPLY=( $(compgen -W "$screens" -- "$cur")) COMPREPLY=( $(compgen -W "$screens" -- "$cur") )
return return
;; ;;
-gamma|-rgamma|-ggamma|-bgamma) -gamma|-rgamma|-ggamma|-bgamma)
@ -33,7 +33,8 @@ _xgamma()
local t screens=$(xrandr --query 2>/dev/null | sed -n \ local t screens=$(xrandr --query 2>/dev/null | sed -n \
-e '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null) -e '/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null)
t="${cur#:}" t="${cur#:}"
COMPREPLY=( $(compgen -P "${t%.*}." -W "$screens" -- "${cur##*.}")) COMPREPLY=( $(compgen -P "${t%.*}." -W "$screens" -- \
"${cur##*.}") )
elif [[ "$cur" != *:* ]]; then elif [[ "$cur" != *:* ]]; then
# complete hostnames # complete hostnames
_known_hosts_real -c "$cur" _known_hosts_real -c "$cur"
@ -48,7 +49,7 @@ _xgamma()
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) ) COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace
[[ $COMPREPLY ]] && return [[ $COMPREPLY ]] && return
fi fi

View File

@ -10,8 +10,6 @@ _xhost ()
-*) _known_hosts_real -p- "${cur:1}" ;; -*) _known_hosts_real -p- "${cur:1}" ;;
*) _known_hosts_real "$cur" ;; *) _known_hosts_real "$cur" ;;
esac esac
return 0
} && } &&
complete -F _xhost xhost complete -F _xhost xhost

View File

@ -7,52 +7,50 @@ _xrandr()
local output modes local output modes
case $prev in case "$prev" in
--output|--left-of|--right-of|--above|--below|--same-as) --output|--left-of|--right-of|--above|--below|--same-as)
local outputs=$(xrandr|awk '/connected/ {print $1}') local outputs=$(xrandr|awk '/connected/ {print $1}')
COMPREPLY=( $(compgen -W "$outputs" -- "$cur")) COMPREPLY=( $(compgen -W "$outputs" -- "$cur") )
return 0 return
;; ;;
--mode) --mode)
for(( i = 1; i < cword; i++ )); do for(( i = 1; i < cword; i++ )); do
if [[ "${words[i]}" == "--output" ]]; then if [[ "${words[i]}" == --output ]]; then
output=${words[i+1]} output=${words[i+1]}
break break
fi fi
done done
modes=$(xrandr|sed -e "1,/$output/ d" \ modes=$(xrandr|sed -e "1,/$output/ d" \
-e "/connected/,$ d"|awk '{print $1}') -e "/connected/,$ d"|awk '{print $1}')
COMPREPLY=( $( compgen -W "$modes" -- "$cur")) COMPREPLY=( $(compgen -W "$modes" -- "$cur") )
return 0 return
;; ;;
-o|--orientation) -o|--orientation)
COMPREPLY=( $( compgen -W 'normal inverted left right 0 1 2 3' -- \ COMPREPLY=( $(compgen -W 'normal inverted left right 0 1 2 3' -- \
"$cur" ) ) "$cur") )
return 0 return
;; ;;
--reflect) --reflect)
COMPREPLY=( $( compgen -W 'normal x y xy' -- \ COMPREPLY=( $(compgen -W 'normal x y xy' -- "$cur") )
"$cur" ) ) return
return 0
;; ;;
--rotate) --rotate)
COMPREPLY=( $( compgen -W 'normal inverted left right' -- \ COMPREPLY=( $(compgen -W 'normal inverted left right' -- "$cur") )
"$cur" ) ) return
return 0
;; ;;
esac esac
case $cur in case $cur in
*) *)
COMPREPLY=( $(compgen -W '-display -help --orientation --query \ COMPREPLY=( $(compgen -W '-display -help --orientation --query
--size --rate --version -x -y --screen --verbose --dryrun \ --size --rate --version -x -y --screen --verbose --dryrun
--q1 --q12 --nograb --prop --properties --fb --fbmm --dpi \ --q1 --q12 --nograb --prop --properties --fb --fbmm --dpi
--output --auto --mode --preferred --pos --rate --refresh \ --output --auto --mode --preferred --pos --rate --refresh
--reflect --rotate --left-of --right-of --above --below \ --reflect --rotate --left-of --right-of --above --below
--same-as --set --scale --transform --off --crtc --panning \ --same-as --set --scale --transform --off --crtc --panning
--gamma --brightness --primary --noprimary --newmode --rmmode \ --gamma --brightness --primary --noprimary --newmode --rmmode
--addmode --delmode' -- "$cur") ) --addmode --delmode' -- "$cur") )
return 0 return
;; ;;
esac esac
} && } &&