Gestionnaire de fichiers - Editer - /home/wwgoat/public_html/blog/bash-completion.tar
Arrière
helpers/perl 0000644 00000004356 14720751124 0007106 0 ustar 00 # -*- perl -*- use strict; use Config; use File::Spec::Functions; my %seen; sub print_modules_real { my ($base, $dir, $word) = @_; # return immediately if potential completion doesn't match current word # a double comparison is used to avoid dealing with string lengths # (the shorter being the pattern to be used as the regexp) # word 'Fi', base 'File' -> match 'File' against 'Fi' # word 'File::Sp', base 'File' -> match 'File::Sp' against 'File' return if $base && $word && $base !~ /^\Q$word/ && $word !~ /^\Q$base/; chdir($dir) or return; # print each file foreach my $file (glob('*.pm')) { $file =~ s/\.pm$//; my $module = $base . $file; next if $module !~ /^\Q$word/; next if $seen{$module}++; print $module . "\n"; } # recurse in each subdirectory foreach my $directory (grep { -d } glob('*')) { my $subdir = $dir . '/' . $directory; if ($directory =~ /^(?:[.\d]+|$Config{archname}|auto)$/) { # exclude subdirectory name from base print_modules_real(undef, $subdir, $word); } else { # add subdirectory name to base print_modules_real($base . $directory . '::', $subdir, $word); } } } sub print_modules { my ($word) = @_; foreach my $directory (@INC) { print_modules_real(undef, $directory, $word); } } sub print_functions { my ($word) = @_; my $perlfunc; for ( @INC, undef ) { return if not defined; $perlfunc = catfile $_, qw( pod perlfunc.pod ); last if -r $perlfunc; } open my $fh, '<', $perlfunc or return; my $nest_level = -1; while ( <$fh> ) { next if 1 .. /^=head2 Alphabetical Listing of Perl Functions$/; ++$nest_level if /^=over/; --$nest_level if /^=back/; next if $nest_level; next unless /^=item (-?\w+)/; my $function = $1; next if $function !~ /^\Q$word/; next if $seen{$function}++; print $function . "\n"; } } my $type = shift; my $word = shift; if ($type eq 'functions') { print_functions($word); } elsif ($type eq 'modules') { print_modules($word); } bash_completion 0000644 00000202501 14720751124 0007640 0 ustar 00 # -*- shell-script -*- # # bash_completion - programmable completion functions for bash 4.1+ # # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org> # © 2009-2013, Bash Completion Maintainers # <bash-completion-devel@lists.alioth.debian.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # The latest version of this software can be obtained here: # # http://bash-completion.alioth.debian.org/ # # RELEASE: 2.1 if [[ $- == *v* ]]; then BASH_COMPLETION_ORIGINAL_V_VALUE="-v" else BASH_COMPLETION_ORIGINAL_V_VALUE="+v" fi if [[ ${BASH_COMPLETION_DEBUG-} ]]; then set -v else set +v fi # Set the following to the location of the backwards compat completion dir. # : ${BASH_COMPLETION_COMPAT_DIR:=/etc/bash_completion.d} readonly BASH_COMPLETION_COMPAT_DIR # Blacklisted completions, causing problems with our code. # _blacklist_glob='@()' # Turn on extended globbing and programmable completion shopt -s extglob progcomp # A lot of the following one-liners were taken directly from the # completion examples provided with the bash 2.04 source distribution # Make directory commands see only directories complete -d pushd # start of section containing compspecs that can be handled within bash # user commands see only users complete -u groups slay w sux # bg completes with stopped jobs complete -A stopped -P '"%' -S '"' bg # other job commands complete -j -P '"%' -S '"' fg jobs disown # readonly and unset complete with shell variables complete -v readonly unset # set completes with set options complete -A setopt set # shopt completes with shopt options complete -A shopt shopt # helptopics complete -A helptopic help # unalias completes with aliases complete -a unalias # bind completes with readline bindings (make this more intelligent) complete -A binding bind # type and which complete on commands complete -c command type which # builtin completes on builtins complete -b builtin # start of section containing completion functions called by other functions # Check if we're running on the given userland # @param $1 userland to check for _userland() { local userland=$( uname -s ) [[ $userland == @(Linux|GNU/*) ]] && userland=GNU [[ $userland == $1 ]] } # This function sets correct SysV init directories # _sysvdirs() { sysvdirs=( ) [[ -d /etc/rc.d/init.d ]] && sysvdirs+=( /etc/rc.d/init.d ) [[ -d /etc/init.d ]] && sysvdirs+=( /etc/init.d ) # Slackware uses /etc/rc.d [[ -f /etc/slackware-version ]] && sysvdirs=( /etc/rc.d ) } # This function checks whether we have a given program on the system. # _have() { # Completions for system administrator commands are installed as well in # case completion is attempted via `sudo command ...'. PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin type $1 &>/dev/null } # Backwards compatibility for compat completions that use have(). # @deprecated should no longer be used; generally not needed with dynamically # loaded completions, and _have is suitable for runtime use. have() { unset -v have _have $1 && have=yes } # This function checks whether a given readline variable # is `on'. # _rl_enabled() { [[ "$( bind -v )" = *$1+([[:space:]])on* ]] } # This function shell-quotes the argument quote() { local quoted=${1//\'/\'\\\'\'} printf "'%s'" "$quoted" } # @see _quote_readline_by_ref() quote_readline() { local quoted _quote_readline_by_ref "$1" ret printf %s "$ret" } # quote_readline() # This function shell-dequotes the argument dequote() { eval printf %s "$1" 2> /dev/null } # Assign variable one scope above the caller # Usage: local "$1" && _upvar $1 "value(s)" # Param: $1 Variable name to assign value to # Param: $* Value(s) to assign. If multiple values, an array is # assigned, otherwise a single value is assigned. # NOTE: For assigning multiple variables, use '_upvars'. Do NOT # use multiple '_upvar' calls, since one '_upvar' call might # reassign a variable to be used by another '_upvar' call. # See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference _upvar() { if unset -v "$1"; then # Unset & validate varname if (( $# == 2 )); then eval $1=\"\$2\" # Return single value else eval $1=\(\"\${@:2}\"\) # Return array fi fi } # Assign variables one scope above the caller # Usage: local varname [varname ...] && # _upvars [-v varname value] | [-aN varname [value ...]] ... # Available OPTIONS: # -aN Assign next N values to varname as array # -v Assign single value to varname # Return: 1 if error occurs # See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference _upvars() { if ! (( $# )); then echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname"\ "value] | [-aN varname [value ...]] ..." 1>&2 return 2 fi while (( $# )); do case $1 in -a*) # Error checking [[ ${1#-a} ]] || { echo "bash: ${FUNCNAME[0]}: \`$1': missing"\ "number specifier" 1>&2; return 1; } printf %d "${1#-a}" &> /dev/null || { echo "bash:"\ "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2 return 1; } # Assign array of -aN elements [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && shift $((${1#-a} + 2)) || { echo "bash: ${FUNCNAME[0]}:"\ "\`$1${2+ }$2': missing argument(s)" 1>&2; return 1; } ;; -v) # Assign single value [[ "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && shift 3 || { echo "bash: ${FUNCNAME[0]}: $1: missing"\ "argument(s)" 1>&2; return 1; } ;; *) echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2 return 1 ;; esac done } # Reassemble command line words, excluding specified characters from the # list of word completion separators (COMP_WORDBREAKS). # @param $1 chars Characters out of $COMP_WORDBREAKS which should # NOT be considered word breaks. This is useful for things like scp where # we want to return host:path and not only path, so we would pass the # colon (:) as $1 here. # @param $2 words Name of variable to return words to # @param $3 cword Name of variable to return cword to # __reassemble_comp_words_by_ref() { local exclude i j line ref # Exclude word separator characters? if [[ $1 ]]; then # Yes, exclude word separator characters; # Exclude only those characters, which were really included exclude="${1//[^$COMP_WORDBREAKS]}" fi # Default to cword unchanged eval $3=$COMP_CWORD # Are characters excluded which were former included? if [[ $exclude ]]; then # Yes, list of word completion separators has shrunk; line=$COMP_LINE # Re-assemble words to complete for (( i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do # Is current word not word 0 (the command itself) and is word not # empty and is word made up of just word separator characters to # be excluded and is current word not preceded by whitespace in # original line? while [[ $i -gt 0 && ${COMP_WORDS[$i]} == +([$exclude]) ]]; do # Is word separator not preceded by whitespace in original line # and are we not going to append to word 0 (the command # itself), then append to current word. [[ $line != [$' \t']* ]] && (( j >= 2 )) && ((j--)) # Append word separator to current or new word ref="$2[$j]" eval $2[$j]=\${!ref}\${COMP_WORDS[i]} # Indicate new cword [[ $i == $COMP_CWORD ]] && eval $3=$j # Remove optional whitespace + word separator from line copy line=${line#*"${COMP_WORDS[$i]}"} # Start new word if word separator in original line is # followed by whitespace. [[ $line == [$' \t']* ]] && ((j++)) # Indicate next word if available, else end *both* while and # for loop (( $i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2 done # Append word to current word ref="$2[$j]" eval $2[$j]=\${!ref}\${COMP_WORDS[i]} # Remove optional whitespace + word from line copy line=${line#*"${COMP_WORDS[i]}"} # Indicate new cword [[ $i == $COMP_CWORD ]] && eval $3=$j done [[ $i == $COMP_CWORD ]] && eval $3=$j else # No, list of word completions separators hasn't changed; eval $2=\( \"\${COMP_WORDS[@]}\" \) fi } # __reassemble_comp_words_by_ref() # @param $1 exclude Characters out of $COMP_WORDBREAKS which should NOT be # considered word breaks. This is useful for things like scp where # we want to return host:path and not only path, so we would pass the # colon (:) as $1 in this case. # @param $2 words Name of variable to return words to # @param $3 cword Name of variable to return cword to # @param $4 cur Name of variable to return current word to complete to # @see __reassemble_comp_words_by_ref() __get_cword_at_cursor_by_ref() { local cword words=() __reassemble_comp_words_by_ref "$1" words cword local i cur index=$COMP_POINT lead=${COMP_LINE:0:$COMP_POINT} # Cursor not at position 0 and not leaded by just space(s)? if [[ $index -gt 0 && ( $lead && ${lead//[[:space:]]} ) ]]; then cur=$COMP_LINE for (( i = 0; i <= cword; ++i )); do while [[ # Current word fits in $cur? ${#cur} -ge ${#words[i]} && # $cur doesn't match cword? "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do # Strip first character cur="${cur:1}" # Decrease cursor position ((index--)) done # Does found word match cword? if [[ $i -lt $cword ]]; then # No, cword lies further; local old_size=${#cur} cur="${cur#"${words[i]}"}" local new_size=${#cur} index=$(( index - old_size + new_size )) fi done # Clear $cur if just space(s) [[ $cur && ! ${cur//[[:space:]]} ]] && cur= # Zero $index if negative [[ $index -lt 0 ]] && index=0 fi local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 "${words[@]}" \ -v $3 "$cword" -v $4 "${cur:0:$index}" } # Get the word to complete and optional previous words. # This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases # where the user is completing in the middle of a word. # (For example, if the line is "ls foobar", # and the cursor is here --------> ^ # Also one is able to cross over possible wordbreak characters. # Usage: _get_comp_words_by_ref [OPTIONS] [VARNAMES] # Available VARNAMES: # cur Return cur via $cur # prev Return prev via $prev # words Return words via $words # cword Return cword via $cword # # Available OPTIONS: # -n EXCLUDE Characters out of $COMP_WORDBREAKS which should NOT be # considered word breaks. This is useful for things like scp # where we want to return host:path and not only path, so we # would pass the colon (:) as -n option in this case. # -c VARNAME Return cur via $VARNAME # -p VARNAME Return prev via $VARNAME # -w VARNAME Return words via $VARNAME # -i VARNAME Return cword via $VARNAME # # Example usage: # # $ _get_comp_words_by_ref -n : cur prev # _get_comp_words_by_ref() { local exclude flag i OPTIND=1 local cur cword words=() local upargs=() upvars=() vcur vcword vprev vwords while getopts "c:i:n:p:w:" flag "$@"; do case $flag in c) vcur=$OPTARG ;; i) vcword=$OPTARG ;; n) exclude=$OPTARG ;; p) vprev=$OPTARG ;; w) vwords=$OPTARG ;; esac done while [[ $# -ge $OPTIND ]]; do case ${!OPTIND} in cur) vcur=cur ;; prev) vprev=prev ;; cword) vcword=cword ;; words) vwords=words ;; *) echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" \ 1>&2; return 1 esac let "OPTIND += 1" done __get_cword_at_cursor_by_ref "$exclude" words cword cur [[ $vcur ]] && { upvars+=("$vcur" ); upargs+=(-v $vcur "$cur" ); } [[ $vcword ]] && { upvars+=("$vcword"); upargs+=(-v $vcword "$cword"); } [[ $vprev && $cword -ge 1 ]] && { upvars+=("$vprev" ); upargs+=(-v $vprev "${words[cword - 1]}"); } [[ $vwords ]] && { upvars+=("$vwords"); upargs+=(-a${#words[@]} $vwords "${words[@]}"); } (( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}" } # Get the word to complete. # This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases # where the user is completing in the middle of a word. # (For example, if the line is "ls foobar", # and the cursor is here --------> ^ # @param $1 string Characters out of $COMP_WORDBREAKS which should NOT be # considered word breaks. This is useful for things like scp where # we want to return host:path and not only path, so we would pass the # colon (:) as $1 in this case. # @param $2 integer Index number of word to return, negatively offset to the # current word (default is 0, previous is 1), respecting the exclusions # given at $1. For example, `_get_cword "=:" 1' returns the word left of # the current word, respecting the exclusions "=:". # @deprecated Use `_get_comp_words_by_ref cur' instead # @see _get_comp_words_by_ref() _get_cword() { local LC_CTYPE=C local cword words __reassemble_comp_words_by_ref "$1" words cword # return previous word offset by $2 if [[ ${2//[^0-9]/} ]]; then printf "%s" "${words[cword-$2]}" elif [[ "${#words[cword]}" -eq 0 || "$COMP_POINT" == "${#COMP_LINE}" ]]; then printf "%s" "${words[cword]}" else local i local cur="$COMP_LINE" local index="$COMP_POINT" for (( i = 0; i <= cword; ++i )); do while [[ # Current word fits in $cur? "${#cur}" -ge ${#words[i]} && # $cur doesn't match cword? "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do # Strip first character cur="${cur:1}" # Decrease cursor position ((index--)) done # Does found word matches cword? if [[ "$i" -lt "$cword" ]]; then # No, cword lies further; local old_size="${#cur}" cur="${cur#${words[i]}}" local new_size="${#cur}" index=$(( index - old_size + new_size )) fi done if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then # We messed up! At least return the whole word so things # keep working printf "%s" "${words[cword]}" else printf "%s" "${cur:0:$index}" fi fi } # _get_cword() # Get word previous to the current word. # This is a good alternative to `prev=${COMP_WORDS[COMP_CWORD-1]}' because bash4 # will properly return the previous word with respect to any given exclusions to # COMP_WORDBREAKS. # @deprecated Use `_get_comp_words_by_ref cur prev' instead # @see _get_comp_words_by_ref() # _get_pword() { if [[ $COMP_CWORD -ge 1 ]]; then _get_cword "${@:-}" 1 fi } # If the word-to-complete contains a colon (:), left-trim COMPREPLY items with # word-to-complete. # With a colon in COMP_WORDBREAKS, words containing # colons are always completed as entire words if the word to complete contains # a colon. This function fixes this, by removing the colon-containing-prefix # from COMPREPLY items. # The preferred solution is to remove the colon (:) from COMP_WORDBREAKS in # your .bashrc: # # # Remove colon (:) from list of word completion separators # COMP_WORDBREAKS=${COMP_WORDBREAKS//:} # # See also: Bash FAQ - E13) Why does filename completion misbehave if a colon # appears in the filename? - http://tiswww.case.edu/php/chet/bash/FAQ # @param $1 current word to complete (cur) # @modifies global array $COMPREPLY # __ltrim_colon_completions() { if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then # Remove colon-word prefix from COMPREPLY items local colon_word=${1%"${1##*:}"} local i=${#COMPREPLY[*]} while [[ $((--i)) -ge 0 ]]; do COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} done fi } # __ltrim_colon_completions() # This function quotes the argument in a way so that readline dequoting # results in the original argument. This is necessary for at least # `compgen' which requires its arguments quoted/escaped: # # $ ls "a'b/" # c # $ compgen -f "a'b/" # Wrong, doesn't return output # $ compgen -f "a\'b/" # Good # a\'b/c # # See also: # - http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html # - http://www.mail-archive.com/bash-completion-devel@lists.alioth.\ # debian.org/msg01944.html # @param $1 Argument to quote # @param $2 Name of variable to return result to _quote_readline_by_ref() { if [[ $1 == \'* ]]; then # Leave out first character printf -v $2 %s "${1:1}" else printf -v $2 %q "$1" fi # If result becomes quoted like this: $'string', re-evaluate in order to # drop the additional quoting. See also: http://www.mail-archive.com/ # bash-completion-devel@lists.alioth.debian.org/msg01942.html [[ ${!2} == \$* ]] && eval $2=${!2} } # _quote_readline_by_ref() # This function performs file and directory completion. It's better than # simply using 'compgen -f', because it honours spaces in filenames. # @param $1 If `-d', complete only on directories. Otherwise filter/pick only # completions with `.$1' and the uppercase version of it as file # extension. # _filedir() { local i IFS=$'\n' xspec _tilde "$cur" || return 0 local -a toks local quoted x tmp _quote_readline_by_ref "$cur" quoted x=$( compgen -d -- "$quoted" ) && while read -r tmp; do toks+=( "$tmp" ) done <<< "$x" if [[ "$1" != -d ]]; then # Munge xspec to contain uppercase version too # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306 xspec=${1:+"!*.@($1|${1^^})"} x=$( compgen -f -X "$xspec" -- $quoted ) && while read -r tmp; do toks+=( "$tmp" ) done <<< "$x" fi # If the filter failed to produce anything, try without it if configured to [[ -n ${COMP_FILEDIR_FALLBACK:-} && \ -n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \ x=$( compgen -f -- $quoted ) && while read -r tmp; do toks+=( "$tmp" ) done <<< "$x" if [[ ${#toks[@]} -ne 0 ]]; then # 2>/dev/null for direct invocation, e.g. in the _filedir unit test compopt -o filenames 2>/dev/null COMPREPLY+=( "${toks[@]}" ) fi } # _filedir() # This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it # easier to support both "--foo bar" and "--foo=bar" style completions. # `=' should have been removed from COMP_WORDBREAKS when setting $cur for # this to be useful. # Returns 0 if current option was split, 1 otherwise. # _split_longopt() { if [[ "$cur" == --?*=* ]]; then # Cut also backslash before '=' in case it ended up there # for some reason. prev="${cur%%?(\\)=*}" cur="${cur#*=}" return 0 fi return 1 } # Complete variables. # @return True (0) if variables were completed, # False (> 0) if not. _variables() { if [[ $cur =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]; then [[ $cur == *{* ]] && local suffix=} || local suffix= COMPREPLY+=( $( compgen -P ${BASH_REMATCH[1]} -S "$suffix" -v -- \ "${BASH_REMATCH[2]}" ) ) return 0 fi return 1 } # Initialize completion and deal with various general things: do file # and variable completion where appropriate, and adjust prev, words, # and cword as if no redirections exist so that completions do not # need to deal with them. Before calling this function, make sure # cur, prev, words, and cword are local, ditto split if you use -s. # # Options: # -n EXCLUDE Passed to _get_comp_words_by_ref -n with redirection chars # -e XSPEC Passed to _filedir as first arg for stderr redirections # -o XSPEC Passed to _filedir as first arg for other output redirections # -i XSPEC Passed to _filedir as first arg for stdin redirections # -s Split long options with _split_longopt, implies -n = # @return True (0) if completion needs further processing, # False (> 0) no further processing is necessary. # _init_completion() { local exclude= flag outx errx inx OPTIND=1 while getopts "n:e:o:i:s" flag "$@"; do case $flag in n) exclude+=$OPTARG ;; e) errx=$OPTARG ;; o) outx=$OPTARG ;; i) inx=$OPTARG ;; s) split=false ; exclude+== ;; esac done # For some reason completion functions are not invoked at all by # bash (at least as of 4.1.7) after the command line contains an # ampersand so we don't get a chance to deal with redirections # containing them, but if we did, hopefully the below would also # do the right thing with them... COMPREPLY=() local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)" _get_comp_words_by_ref -n "$exclude<>&" cur prev words cword # Complete variable names. _variables && return 1 # Complete on files if current is a redirect possibly followed by a # filename, e.g. ">foo", or previous is a "bare" redirect, e.g. ">". if [[ $cur == $redir* || $prev == $redir ]]; then local xspec case $cur in 2'>'*) xspec=$errx ;; *'>'*) xspec=$outx ;; *'<'*) xspec=$inx ;; *) case $prev in 2'>'*) xspec=$errx ;; *'>'*) xspec=$outx ;; *'<'*) xspec=$inx ;; esac ;; esac cur="${cur##$redir}" _filedir $xspec return 1 fi # Remove all redirections so completions don't have to deal with them. local i skip for (( i=1; i < ${#words[@]}; )); do if [[ ${words[i]} == $redir* ]]; then # If "bare" redirect, remove also the next word (skip=2). [[ ${words[i]} == $redir ]] && skip=2 || skip=1 words=( "${words[@]:0:i}" "${words[@]:i+skip}" ) [[ $i -le $cword ]] && cword=$(( cword - skip )) else i=$(( ++i )) fi done [[ $cword -eq 0 ]] && return 1 prev=${words[cword-1]} [[ ${split-} ]] && _split_longopt && split=true return 0 } # Helper function for _parse_help and _parse_usage. __parse_options() { local option option2 i IFS=$' \t\n,/|' # Take first found long option, or first one (short) if not found. option= for i in $1; do case $i in ---*) break ;; --?*) option=$i ; break ;; -?*) [[ $option ]] || option=$i ;; *) break ;; esac done [[ $option ]] || return 0 IFS=$' \t\n' # affects parsing of the regexps below... # Expand --[no]foo to --foo and --nofoo etc if [[ $option =~ (\[((no|dont)-?)\]). ]]; then option2=${option/"${BASH_REMATCH[1]}"/} option2=${option2%%[<{().[]*} printf '%s\n' "${option2/=*/=}" option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"} fi option=${option%%[<{().[]*} printf '%s\n' "${option/=*/=}" } # Parse GNU style help output of the given command. # @param $1 command; if "-", read from stdin and ignore rest of args # @param $2 command options (default: --help) # _parse_help() { eval local cmd=$( quote "$1" ) local line { case $cmd in -) cat ;; *) LC_ALL=C "$( dequote "$cmd" )" ${2:---help} 2>&1 ;; esac } \ | while read -r line; do [[ $line == *([ $'\t'])-* ]] || continue # transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc while [[ $line =~ \ ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+\]? ]]; do line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"} done __parse_options "${line// or /, }" done } # Parse BSD style usage output (options in brackets) of the given command. # @param $1 command; if "-", read from stdin and ignore rest of args # @param $2 command options (default: --usage) # _parse_usage() { eval local cmd=$( quote "$1" ) local line match option i char { case $cmd in -) cat ;; *) LC_ALL=C "$( dequote "$cmd" )" ${2:---usage} 2>&1 ;; esac } \ | while read -r line; do while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do match=${BASH_REMATCH[0]} option=${BASH_REMATCH[1]} case $option in -?(\[)+([a-zA-Z0-9?])) # Treat as bundled short options for (( i=1; i < ${#option}; i++ )); do char=${option:i:1} [[ $char != '[' ]] && printf '%s\n' -$char done ;; *) __parse_options "$option" ;; esac line=${line#*"$match"} done done } # This function completes on signal names (minus the SIG prefix) # @param $1 prefix _signals() { local -a sigs=( $( compgen -P "$1" -A signal "SIG${cur#$1}" ) ) COMPREPLY+=( "${sigs[@]/#${1}SIG/${1}}" ) } # This function completes on known mac addresses # _mac_addresses() { local re='\([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}' local PATH="$PATH:/sbin:/usr/sbin" # Local interfaces # - ifconfig on Linux: HWaddr or ether # - ifconfig on FreeBSD: ether # - ip link: link/ether COMPREPLY+=( $( { ifconfig -a || ip link show; } 2>/dev/null | sed -ne \ "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne \ "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne \ "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]].*|\2|p" -ne \ "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$|\2|p" ) ) # ARP cache COMPREPLY+=( $( { arp -an || ip neigh show; } 2>/dev/null | sed -ne \ "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne \ "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" ) ) # /etc/ethers COMPREPLY+=( $( sed -ne \ "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) __ltrim_colon_completions "$cur" } # This function completes on configured network interfaces # _configured_interfaces() { if [[ -f /etc/debian_version ]]; then # Debian system COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\ /etc/network/interfaces )" -- "$cur" ) ) elif [[ -f /etc/SuSE-release ]]; then # SuSE system COMPREPLY=( $( compgen -W "$( printf '%s\n' \ /etc/sysconfig/network/ifcfg-* | \ sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) ) elif [[ -f /etc/pld-release ]]; then # PLD Linux COMPREPLY=( $( compgen -W "$( command ls -B \ /etc/sysconfig/interfaces | \ sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) ) else # Assume Red Hat COMPREPLY=( $( compgen -W "$( printf '%s\n' \ /etc/sysconfig/network-scripts/ifcfg-* | \ sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) ) fi } # Local IP addresses. # _ip_addresses() { local PATH=$PATH:/sbin COMPREPLY+=( $( compgen -W \ "$( { LC_ALL=C ifconfig -a || ip addr show; } 2>/dev/null | sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \ -ne 's|.*inet[[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p' )" \ -- "$cur" ) ) } # This function completes on available kernels # _kernel_versions() { COMPREPLY=( $( compgen -W '$( command ls /lib/modules )' -- "$cur" ) ) } # This function completes on all available network interfaces # -a: restrict to active interfaces only # -w: restrict to wireless interfaces only # _available_interfaces() { local cmd PATH=$PATH:/sbin if [[ ${1:-} == -w ]]; then cmd="iwconfig" elif [[ ${1:-} == -a ]]; then cmd="{ ifconfig || ip link show up; }" else cmd="{ ifconfig -a || ip link show; }" fi COMPREPLY=( $( eval $cmd 2>/dev/null | awk \ '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }' ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) ) } # Echo number of CPUs, falling back to 1 on failure. _ncpus() { local var=NPROCESSORS_ONLN [[ $OSTYPE == *linux* ]] && var=_$var local n=$( getconf $var 2>/dev/null ) printf %s ${n:-1} } # Perform tilde (~) completion # @return True (0) if completion needs further processing, # False (> 0) if tilde is followed by a valid username, completions # are put in COMPREPLY and no further processing is necessary. _tilde() { local result=0 if [[ $1 == \~* && $1 != */* ]]; then # Try generate ~username completions COMPREPLY=( $( compgen -P '~' -u "${1#\~}" ) ) result=${#COMPREPLY[@]} # 2>/dev/null for direct invocation, e.g. in the _tilde unit test [[ $result -gt 0 ]] && compopt -o filenames 2>/dev/null fi return $result } # Expand variable starting with tilde (~) # We want to expand ~foo/... to /home/foo/... to avoid problems when # word-to-complete starting with a tilde is fed to commands and ending up # quoted instead of expanded. # Only the first portion of the variable from the tilde up to the first slash # (~../) is expanded. The remainder of the variable, containing for example # a dollar sign variable ($) or asterisk (*) is not expanded. # Example usage: # # $ v="~"; __expand_tilde_by_ref v; echo "$v" # # Example output: # # v output # -------- ---------------- # ~ /home/user # ~foo/bar /home/foo/bar # ~foo/$HOME /home/foo/$HOME # ~foo/a b /home/foo/a b # ~foo/* /home/foo/* # # @param $1 Name of variable (not the value of the variable) to expand __expand_tilde_by_ref() { # Does $1 start with tilde (~)? if [[ ${!1} == \~* ]]; then # Does $1 contain slash (/)? if [[ ${!1} == */* ]]; then # Yes, $1 contains slash; # 1: Remove * including and after first slash (/), i.e. "~a/b" # becomes "~a". Double quotes allow eval. # 2: Remove * before the first slash (/), i.e. "~a/b" # becomes "b". Single quotes prevent eval. # +-----1----+ +---2----+ eval $1="${!1/%\/*}"/'${!1#*/}' else # No, $1 doesn't contain slash eval $1="${!1}" fi fi } # __expand_tilde_by_ref() # This function expands tildes in pathnames # _expand() { # FIXME: Why was this here? #[ "$cur" != "${cur%\\}" ] && cur+="\\" # Expand ~username type directory specifications. We want to expand # ~foo/... to /home/foo/... to avoid problems when $cur starting with # a tilde is fed to commands and ending up quoted instead of expanded. if [[ "$cur" == \~*/* ]]; then eval cur=$cur 2>/dev/null elif [[ "$cur" == \~* ]]; then cur=${cur#\~} COMPREPLY=( $( compgen -P '~' -u "$cur" ) ) [[ ${#COMPREPLY[@]} -eq 1 ]] && eval COMPREPLY[0]=${COMPREPLY[0]} return ${#COMPREPLY[@]} fi } # This function completes on process IDs. # AIX and Solaris ps prefers X/Open syntax. [[ $OSTYPE == *@(solaris|aix)* ]] && _pids() { COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- "$cur" )) } || _pids() { COMPREPLY=( $( compgen -W '$( command ps axo pid= )' -- "$cur" ) ) } # This function completes on process group IDs. # AIX and SunOS prefer X/Open, all else should be BSD. [[ $OSTYPE == *@(solaris|aix)* ]] && _pgids() { COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- "$cur" )) } || _pgids() { COMPREPLY=( $( compgen -W '$( command ps axo pgid= )' -- "$cur" )) } # This function completes on process names. # AIX and SunOS prefer X/Open, all else should be BSD. [[ $OSTYPE == *@(solaris|aix)* ]] && _pnames() { COMPREPLY=( $( compgen -X '<defunct>' -W '$( command ps -efo comm | \ sed -e 1d -e "s:.*/::" -e "s/^-//" | sort -u )' -- "$cur" ) ) } || _pnames() { # FIXME: completes "[kblockd/0]" to "0". Previously it was completed # to "kblockd" which isn't correct either. "kblockd/0" would be # arguably most correct, but killall from psmisc 22 treats arguments # containing "/" specially unless -r is given so that wouldn't quite # work either. Perhaps it'd be best to not complete these to anything # for now. # Not using "ps axo comm" because under some Linux kernels, it # truncates command names (see e.g. http://bugs.debian.org/497540#19) COMPREPLY=( $( compgen -X '<defunct>' -W '$( command ps axo command= | \ sed -e "s/ .*//" -e "s:.*/::" -e "s/:$//" -e "s/^[[(-]//" \ -e "s/[])]$//" | sort -u )' -- "$cur" ) ) } # This function completes on user IDs # _uids() { if type getent &>/dev/null; then COMPREPLY=( $( compgen -W '$( getent passwd | cut -d: -f3 )' -- "$cur" ) ) elif type perl &>/dev/null; then COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- "$cur" ) ) else # make do with /etc/passwd COMPREPLY=( $( compgen -W '$( cut -d: -f3 /etc/passwd )' -- "$cur" ) ) fi } # This function completes on group IDs # _gids() { if type getent &>/dev/null; then COMPREPLY=( $( compgen -W '$( getent group | cut -d: -f3 )' \ -- "$cur" ) ) elif type perl &>/dev/null; then COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- "$cur" ) ) else # make do with /etc/group COMPREPLY=( $( compgen -W '$( cut -d: -f3 /etc/group )' -- "$cur" ) ) fi } # Glob for matching various backup files. # _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))' # Complete on xinetd services # _xinetd_services() { local xinetddir=/etc/xinetd.d if [[ -d $xinetddir ]]; then local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob local -a svcs=( $( printf '%s\n' $xinetddir/!($_backup_glob) ) ) $restore_nullglob COMPREPLY+=( $( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" ) ) fi } # This function completes on services # _services() { local sysvdirs _sysvdirs local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob COMPREPLY=( $( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions) ) ) $restore_nullglob COMPREPLY+=( $( systemctl list-units --full --all 2>/dev/null | \ awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur" ) ) } # This completes on a list of all available service scripts for the # 'service' command and/or the SysV init.d directory, followed by # that script's available commands # _service() { local cur prev words cword _init_completion || return # don't complete past 2nd token [[ $cword -gt 2 ]] && return 0 if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then _services [[ -e /etc/mandrake-release ]] && _xinetd_services else local sysvdirs _sysvdirs COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \ -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) ) fi } && complete -F _service service _sysvdirs for svcdir in ${sysvdirs[@]}; do for svc in $svcdir/!($_backup_glob); do [[ -x $svc ]] && complete -F _service $svc done done unset svc svcdir sysvdirs # This function completes on modules # _modules() { local modpath modpath=/lib/modules/$1 COMPREPLY=( $( compgen -W "$( command ls -RL $modpath 2>/dev/null | \ sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.[gx]z\)\{0,1\}$/\1/p' )" -- "$cur" ) ) } # This function completes on installed modules # _installed_modules() { COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" lsmod | \ awk '{if (NR != 1) print $1}' )" -- "$1" ) ) } # This function completes on user or user:group format; as for chown and cpio. # # The : must be added manually; it will only complete usernames initially. # The legacy user.group format is not supported. # # @param $1 If -u, only return users/groups the user has access to in # context of current completion. _usergroup() { if [[ $cur = *\\\\* || $cur = *:*:* ]]; then # Give up early on if something seems horribly wrong. return elif [[ $cur = *\\:* ]]; then # Completing group after 'user\:gr<TAB>'. # Reply with a list of groups prefixed with 'user:', readline will # escape to the colon. local prefix prefix=${cur%%*([^:])} prefix=${prefix//\\} local mycur="${cur#*[:]}" if [[ $1 == -u ]]; then _allowed_groups "$mycur" else local IFS=$'\n' COMPREPLY=( $( compgen -g -- "$mycur" ) ) fi COMPREPLY=( $( compgen -P "$prefix" -W "${COMPREPLY[@]}" ) ) elif [[ $cur = *:* ]]; then # Completing group after 'user:gr<TAB>'. # Reply with a list of unprefixed groups since readline with split on : # and only replace the 'gr' part local mycur="${cur#*:}" if [[ $1 == -u ]]; then _allowed_groups "$mycur" else local IFS=$'\n' COMPREPLY=( $( compgen -g -- "$mycur" ) ) fi else # Completing a partial 'usernam<TAB>'. # # Don't suffix with a : because readline will escape it and add a # slash. It's better to complete into 'chown username ' than 'chown # username\:'. if [[ $1 == -u ]]; then _allowed_users "$cur" else local IFS=$'\n' COMPREPLY=( $( compgen -u -- "$cur" ) ) fi fi } _allowed_users() { if _complete_as_root; then local IFS=$'\n' COMPREPLY=( $( compgen -u -- "${1:-$cur}" ) ) else local IFS=$'\n ' COMPREPLY=( $( compgen -W \ "$( id -un 2>/dev/null || whoami 2>/dev/null )" -- "${1:-$cur}" ) ) fi } _allowed_groups() { if _complete_as_root; then local IFS=$'\n' COMPREPLY=( $( compgen -g -- "$1" ) ) else local IFS=$'\n ' COMPREPLY=( $( compgen -W \ "$( id -Gn 2>/dev/null || groups 2>/dev/null )" -- "$1" ) ) fi } # This function completes on valid shells # _shells() { local shell rest while read -r shell rest; do [[ $shell == /* && $shell == "$cur"* ]] && COMPREPLY+=( $shell ) done 2>/dev/null < /etc/shells } # This function completes on valid filesystem types # _fstypes() { local fss if [[ -e /proc/filesystems ]]; then # Linux fss="$( cut -d$'\t' -f2 /proc/filesystems ) $( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )" else # Generic fss="$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null ) $( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null ) $( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null ) $( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null ) $( [[ -d /etc/fs ]] && command ls /etc/fs )" fi [[ -n $fss ]] && COMPREPLY+=( $( compgen -W "$fss" -- "$cur" ) ) } # Get real command. # - arg: $1 Command # - stdout: Filename of command in PATH with possible symbolic links resolved. # Empty string if command not found. # - return: True (0) if command found, False (> 0) if not. _realcommand() { type -P "$1" > /dev/null && { if type -p realpath > /dev/null; then realpath "$(type -P "$1")" elif type -p greadlink > /dev/null; then greadlink -f "$(type -P "$1")" elif type -p readlink > /dev/null; then readlink -f "$(type -P "$1")" else type -P "$1" fi } } # This function returns the first argument, excluding options # @param $1 chars Characters out of $COMP_WORDBREAKS which should # NOT be considered word breaks. See __reassemble_comp_words_by_ref. _get_first_arg() { local i arg= for (( i=1; i < COMP_CWORD; i++ )); do if [[ "${COMP_WORDS[i]}" != -* ]]; then arg=${COMP_WORDS[i]} break fi done } # This function counts the number of args, excluding options # @param $1 chars Characters out of $COMP_WORDBREAKS which should # NOT be considered word breaks. See __reassemble_comp_words_by_ref. _count_args() { local i cword words __reassemble_comp_words_by_ref "$1" words cword args=1 for i in "${words[@]:1:cword-1}"; do [[ "$i" != -* ]] && args=$(($args+1)) done } # This function completes on PCI IDs # _pci_ids() { COMPREPLY+=( $( compgen -W \ "$( PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur" ) ) } # This function completes on USB IDs # _usb_ids() { COMPREPLY+=( $( compgen -W \ "$( PATH="$PATH:/sbin" lsusb | awk '{print $6}' )" -- "$cur" ) ) } # CD device names _cd_devices() { COMPREPLY+=( $( compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}" ) ) } # DVD device names _dvd_devices() { COMPREPLY+=( $( compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}" ) ) } # TERM environment variable values _terms() { COMPREPLY+=( $( compgen -W \ "$( sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap \ 2>/dev/null )" -- "$cur" ) ) COMPREPLY+=( $( compgen -W "$( { toe -a 2>/dev/null || toe 2>/dev/null; } \ | awk '{ print $1 }' | sort -u )" -- "$cur" ) ) } # a little help for FreeBSD ports users [[ $OSTYPE == *freebsd* ]] && complete -W 'index search fetch fetch-list extract patch configure build install reinstall deinstall clean clean-depends kernel buildworld' make # This function provides simple user@host completion # _user_at_host() { local cur prev words cword _init_completion -n : || return if [[ $cur == *@* ]]; then _known_hosts_real "$cur" else COMPREPLY=( $( compgen -u -- "$cur" ) ) fi return 0 } shopt -u hostcomplete && complete -F _user_at_host -o nospace talk ytalk finger # NOTE: Using this function as a helper function is deprecated. Use # `_known_hosts_real' instead. _known_hosts() { local cur prev words cword _init_completion -n : || return # NOTE: Using `_known_hosts' as a helper function and passing options # to `_known_hosts' is deprecated: Use `_known_hosts_real' instead. local options [[ "$1" == -a || "$2" == -a ]] && options=-a [[ "$1" == -c || "$2" == -c ]] && options+=" -c" _known_hosts_real $options -- "$cur" } # _known_hosts() # Helper function for completing _known_hosts. # This function performs host completion based on ssh's config and known_hosts # files, as well as hostnames reported by avahi-browse if # COMP_KNOWN_HOSTS_WITH_AVAHI is set to a non-empty value. Also hosts from # HOSTFILE (compgen -A hostname) are added, unless # COMP_KNOWN_HOSTS_WITH_HOSTFILE is set to an empty value. # Usage: _known_hosts_real [OPTIONS] CWORD # Options: -a Use aliases # -c Use `:' suffix # -F configfile Use `configfile' for configuration settings # -p PREFIX Use PREFIX # Return: Completions, starting with CWORD, are added to COMPREPLY[] _known_hosts_real() { local configfile flag prefix local cur curd awkcur user suffix aliases i host local -a kh khd config local OPTIND=1 while getopts "acF:p:" flag "$@"; do case $flag in a) aliases='yes' ;; c) suffix=':' ;; F) configfile=$OPTARG ;; p) prefix=$OPTARG ;; esac done [[ $# -lt $OPTIND ]] && echo "error: $FUNCNAME: missing mandatory argument CWORD" cur=${!OPTIND}; let "OPTIND += 1" [[ $# -ge $OPTIND ]] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\ $(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done) [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@} kh=() # ssh config files if [[ -n $configfile ]]; then [[ -r $configfile ]] && config+=( "$configfile" ) else for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do [[ -r $i ]] && config+=( "$i" ) done fi # Known hosts files from configs if [[ ${#config[@]} -gt 0 ]]; then local OIFS=$IFS IFS=$'\n' j local -a tmpkh # expand paths (if present) to global and user known hosts files # TODO(?): try to make known hosts files with more than one consecutive # spaces in their name work (watch out for ~ expansion # breakage! Alioth#311595) tmpkh=( $( awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u ) ) IFS=$OIFS for i in "${tmpkh[@]}"; do # First deal with quoted entries... while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do i=${BASH_REMATCH[1]}${BASH_REMATCH[3]} j=${BASH_REMATCH[2]} __expand_tilde_by_ref j # Eval/expand possible `~' or `~user' [[ -r $j ]] && kh+=( "$j" ) done # ...and then the rest. for j in $i; do __expand_tilde_by_ref j # Eval/expand possible `~' or `~user' [[ -r $j ]] && kh+=( "$j" ) done done fi if [[ -z $configfile ]]; then # Global and user known_hosts files for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \ /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \ ~/.ssh/known_hosts2; do [[ -r $i ]] && kh+=( "$i" ) done for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do [[ -d $i ]] && khd+=( "$i"/*pub ) done fi # If we have known_hosts files to use if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 ]]; then # Escape slashes and dots in paths for awk awkcur=${cur//\//\\\/} awkcur=${awkcur//\./\\\.} curd=$awkcur if [[ "$awkcur" == [0-9]*[.:]* ]]; then # Digits followed by a dot or a colon - just search for that awkcur="^$awkcur[.:]*" elif [[ "$awkcur" == [0-9]* ]]; then # Digits followed by no dot or colon - search for digits followed # by a dot or a colon awkcur="^$awkcur.*[.:]" elif [[ -z $awkcur ]]; then # A blank - search for a dot, a colon, or an alpha character awkcur="[a-z.:]" else awkcur="^$awkcur" fi if [[ ${#kh[@]} -gt 0 ]]; then # FS needs to look for a comma separated list COMPREPLY+=( $( awk 'BEGIN {FS=","} /^\s*[^|\#]/ { sub("^@[^ ]+ +", ""); \ sub(" .*$", ""); \ for (i=1; i<=NF; ++i) { \ sub("^\\[", "", $i); sub("\\](:[0-9]+)?$", "", $i); \ if ($i !~ /[*?]/ && $i ~ /'"$awkcur"'/) {print $i} \ }}' "${kh[@]}" 2>/dev/null ) ) fi if [[ ${#khd[@]} -gt 0 ]]; then # Needs to look for files called # .../.ssh2/key_22_<hostname>.pub # dont fork any processes, because in a cluster environment, # there can be hundreds of hostkeys for i in "${khd[@]}" ; do if [[ "$i" == *key_22_$curd*.pub && -r "$i" ]]; then host=${i/#*key_22_/} host=${host/%.pub/} COMPREPLY+=( $host ) fi done fi # apply suffix and prefix for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix done fi # append any available aliases from config files if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" ) COMPREPLY+=( $( compgen -P "$prefix$user" \ -S "$suffix" -W "$hosts" -- "$cur" ) ) fi # Add hosts reported by avahi-browse, if desired and it's available. if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && \ type avahi-browse &>/dev/null; then # The original call to avahi-browse also had "-k", to avoid lookups # into avahi's services DB. We don't need the name of the service, and # if it contains ";", it may mistify the result. But on Gentoo (at # least), -k wasn't available (even if mentioned in the manpage) some # time ago, so... COMPREPLY+=( $( compgen -P "$prefix$user" -S "$suffix" -W \ "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \ awk -F';' '/^=/ { print $7 }' | sort -u )" -- "$cur" ) ) fi # Add hosts reported by ruptime. COMPREPLY+=( $( compgen -W \ "$( ruptime 2>/dev/null | awk '!/^ruptime:/ { print $1 }' )" \ -- "$cur" ) ) # Add results of normal hostname completion, unless # `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value. if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then COMPREPLY+=( $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ) ) fi __ltrim_colon_completions "$prefix$user$cur" return 0 } # _known_hosts_real() complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \ fping fping6 telnet rsh rlogin ftp dig mtr ssh-installkeys showmount # This meta-cd function observes the CDPATH variable, so that cd additionally # completes on directories under those specified in CDPATH. # _cd() { local cur prev words cword _init_completion || return local IFS=$'\n' i j k compopt -o filenames # Use standard dir completion if no CDPATH or parameter starts with /, # ./ or ../ if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then _filedir -d return 0 fi local -r mark_dirs=$(_rl_enabled mark-directories && echo y) local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y) # we have a CDPATH, so loop on its contents for i in ${CDPATH//:/$'\n'}; do # create an array of matched subdirs k="${#COMPREPLY[@]}" for j in $( compgen -d $i/$cur ); do if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then j+="/" fi COMPREPLY[k++]=${j#$i/} done done _filedir -d if [[ ${#COMPREPLY[@]} -eq 1 ]]; then i=${COMPREPLY[0]} if [[ "$i" == "$cur" && $i != "*/" ]]; then COMPREPLY[0]="${i}/" fi fi return 0 } if shopt -q cdable_vars; then complete -v -F _cd -o nospace cd else complete -F _cd -o nospace cd fi # a wrapper method for the next one, when the offset is unknown _command() { local offset i # find actual offset, as position of the first non-option offset=1 for (( i=1; i <= COMP_CWORD; i++ )); do if [[ "${COMP_WORDS[i]}" != -* ]]; then offset=$i break fi done _command_offset $offset } # A meta-command completion function for commands like sudo(8), which need to # first complete on a command, then complete according to that command's own # completion definition. # _command_offset() { # rewrite current completion context before invoking # actual command completion # find new first word position, then # rewrite COMP_LINE and adjust COMP_POINT local word_offset=$1 i j for (( i=0; i < $word_offset; i++ )); do for (( j=0; j <= ${#COMP_LINE}; j++ )); do [[ "$COMP_LINE" == "${COMP_WORDS[i]}"* ]] && break COMP_LINE=${COMP_LINE:1} ((COMP_POINT--)) done COMP_LINE=${COMP_LINE#"${COMP_WORDS[i]}"} ((COMP_POINT-=${#COMP_WORDS[i]})) done # shift COMP_WORDS elements and adjust COMP_CWORD for (( i=0; i <= COMP_CWORD - $word_offset; i++ )); do COMP_WORDS[i]=${COMP_WORDS[i+$word_offset]} done for (( i; i <= COMP_CWORD; i++ )); do unset COMP_WORDS[i] done ((COMP_CWORD -= $word_offset)) COMPREPLY=() local cur _get_comp_words_by_ref cur if [[ $COMP_CWORD -eq 0 ]]; then local IFS=$'\n' compopt -o filenames COMPREPLY=( $( compgen -d -c -- "$cur" ) ) else local cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]} local cspec=$( complete -p $cmd 2>/dev/null ) # If we have no completion for $cmd yet, see if we have for basename if [[ ! $cspec && $cmd == */* ]]; then cspec=$( complete -p ${cmd##*/} 2>/dev/null ) [[ $cspec ]] && compcmd=${cmd##*/} fi # If still nothing, just load it for the basename if [[ ! $cspec ]]; then compcmd=${cmd##*/} _completion_loader $compcmd cspec=$( complete -p $compcmd 2>/dev/null ) fi if [[ -n $cspec ]]; then if [[ ${cspec#* -F } != $cspec ]]; then # complete -F <function> # get function name local func=${cspec#*-F } func=${func%% *} if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}" else $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" fi # restore initial compopts local opt while [[ $cspec == *" -o "* ]]; do # FIXME: should we take "+o opt" into account? cspec=${cspec#*-o } opt=${cspec%% *} compopt -o $opt cspec=${cspec#$opt} done else cspec=${cspec#complete} cspec=${cspec%%$compcmd} COMPREPLY=( $( eval compgen "$cspec" -- '$cur' ) ) fi elif [[ ${#COMPREPLY[@]} -eq 0 ]]; then # XXX will probably never happen as long as completion loader loads # *something* for every command thrown at it ($cspec != empty) _minimal fi fi } complete -F _command aoss command do else eval exec ltrace nice nohup padsp \ then time tsocks vsound xargs _root_command() { local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin local root_command=$1 _command } complete -F _root_command fakeroot gksu gksudo kdesudo really # Return true if the completion should be treated as running as root _complete_as_root() { [[ $EUID -eq 0 || ${root_command:-} ]] } _longopt() { local cur prev words cword split _init_completion -s || return case "${prev,,}" in --help|--usage|--version) return 0 ;; --*dir*) _filedir -d return 0 ;; --*file*|--*path*) _filedir return 0 ;; --+([-a-z0-9_])) local argtype=$( $1 --help 2>&1 | sed -ne \ "s|.*$prev\[\{0,1\}=[<[]\{0,1\}\([-A-Za-z0-9_]\{1,\}\).*|\1|p" ) case ${argtype,,} in *dir*) _filedir -d return 0 ;; *file*|*path*) _filedir return 0 ;; esac ;; esac $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \ sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\1/p' | sort -u )" \ -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace elif [[ "$1" == @(mk|rm)dir ]]; then _filedir -d else _filedir fi } # makeinfo and texi2dvi are defined elsewhere. complete -F _longopt a2ps awk base64 bash bc bison cat colordiff cp csplit \ cut date df diff dir du enscript env expand fmt fold gperf \ grep grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod \ mv netstat nl nm objcopy objdump od paste pr ptx readelf rm rmdir \ sed seq sha{,1,224,256,384,512}sum shar sort split strip sum tac tail tee \ texindex touch tr uname unexpand uniq units vdir wc who declare -A _xspecs _filedir_xspec() { local cur prev words cword _init_completion || return _tilde "$cur" || return 0 local IFS=$'\n' xspec=${_xspecs[${1##*/}]} tmp local -a toks toks=( $( compgen -d -- "$(quote_readline "$cur")" | { while read -r tmp; do printf '%s\n' $tmp done } )) # Munge xspec to contain uppercase version too # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306 eval xspec="${xspec}" local matchop=! if [[ $xspec == !* ]]; then xspec=${xspec#!} matchop=@ fi xspec="$matchop($xspec|${xspec^^})" toks+=( $( eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | { while read -r tmp; do [[ -n $tmp ]] && printf '%s\n' $tmp done } )) if [[ ${#toks[@]} -ne 0 ]]; then compopt -o filenames COMPREPLY=( "${toks[@]}" ) fi } _install_xspec() { local xspec=$1 cmd shift for cmd in $@; do _xspecs[$cmd]=$xspec done complete -F _filedir_xspec $@ } # bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510 _install_xspec '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat lbunzip2 lbzcat _install_xspec '!*.@(zip|[ejsw]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|do[ct][xm]|p[op]t[mx]|xl[st][xm])' unzip zipinfo _install_xspec '*.Z' compress znew # zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510 _install_xspec '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat unpigz _install_xspec '!*.Z' uncompress # lzcmp, lzdiff intentionally not here, see Debian: #455510 _install_xspec '!*.@(tlz|lzma)' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma _install_xspec '!*.@(?(t)xz|tlz|lzma)' unxz xzcat _install_xspec '!*.lrz' lrunzip _install_xspec '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)' ee _install_xspec '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|svg)' qiv _install_xspec '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|?(e)ps)' xv _install_xspec '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview _install_xspec '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi kdvi _install_xspec '!*.dvi' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx _install_xspec '!*.[pf]df' acroread gpdf xpdf _install_xspec '!*.@(?(e)ps|pdf)' kpdf _install_xspec '!*.@(okular|@(?(e|x)ps|?(E|X)PS|[pf]df|[PF]DF|dvi|DVI|cb[rz]|CB[RZ]|djv?(u)|DJV?(U)|dvi|DVI|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX|epub|EPUB|odt|ODT|fb?(2)|FB?(2)|mobi|MOBI|g3|G3|chm|CHM)?(.?(gz|GZ|bz2|BZ2)))' okular _install_xspec '!*.pdf' epdfview _install_xspec '!*.@(cb[rz7t]|djv?(u)|?(e)ps|pdf)' zathura _install_xspec '!*.@(?(e)ps|pdf)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr _install_xspec '!*.texi*' makeinfo texi2html _install_xspec '!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi _install_xspec '!*.mp3' mpg123 mpg321 madplay _install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[gmv]|OG[GMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.part)' xine aaxine fbxine _install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[gmv]|OG[GMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.part)' kaffeine dragon _install_xspec '!*.@(avi|asf|wmv)' aviplay _install_xspec '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay _install_xspec '!*.@(mpg|mpeg|avi|mov|qt)' xanim _install_xspec '!*.@(ogg|m3u|flac|spx)' ogg123 _install_xspec '!*.@(mp3|ogg|pls|m3u)' gqmpeg freeamp _install_xspec '!*.fig' xfig _install_xspec '!*.@(mid?(i)|cmf)' playmidi _install_xspec '!*.@(mid?(i)|rmi|rcp|[gr]36|g18|mod|xm|it|x3m|s[3t]m|kar)' timidity _install_xspec '!*.@(669|abc|am[fs]|d[bs]m|dmf|far|it|mdl|m[eo]d|mid?(i)|mt[2m]|okta|p[st]m|s[3t]m|ult|umx|wav|xm)' modplugplay modplug123 _install_xspec '*.@(o|so|so.!(conf|*/*)|a|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim view rview rgvim rgview gview emacs xemacs sxemacs kate kwrite _install_xspec '!*.@(zip|z|gz|tgz)' bzme # konqueror not here on purpose, it's more than a web/html browser _install_xspec '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx galeon dillo elinks amaya firefox mozilla-firefox iceweasel google-chrome chromium-browser epiphany _install_xspec '!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm)' oowriter _install_xspec '!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)' ooimpress _install_xspec '!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)' oocalc _install_xspec '!*.@(sxd|std|sda|sdd|?(f)odg|otg)' oodraw _install_xspec '!*.@(sxm|smf|mml|odf)' oomath _install_xspec '!*.odb' oobase _install_xspec '!*.[rs]pm' rpm2cpio _install_xspec '!*.aux' bibtex _install_xspec '!*.po' poedit gtranslator kbabel lokalize _install_xspec '!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])' harbour gharbour hbpp _install_xspec '!*.[Hh][Rr][Bb]' hbrun _install_xspec '!*.ly' lilypond ly2dvi _install_xspec '!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))' cdiff _install_xspec '!@(*.@(ks|jks|jceks|p12|pfx|bks|ubr|gkr|cer|crt|cert|p7b|pkipath|pem|p10|csr|crl)|cacerts)' portecle _install_xspec '!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)' kid3 kid3-qt _install_xspec '!*.py' pyflakes unset -f _install_xspec # Minimal completion to use as fallback in _completion_loader. _minimal() { local cur prev words cword split _init_completion -s || return $split && return _filedir } # Complete the empty string to allow completion of '>', '>>', and '<' # http://lists.gnu.org/archive/html/bug-bash/2012-01/msg00045.html complete -F _minimal '' # set up dynamic completion loading _completion_loader() { local compfile=./completions [[ $BASH_SOURCE == */* ]] && compfile="${BASH_SOURCE%/*}/completions" compfile+="/${1##*/}" # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 124 # Need to define *something*, otherwise there will be no completion at all. complete -F _minimal "$1" && return 124 } && complete -D -F _completion_loader # Function for loading and calling functions from dynamically loaded # completion files that may not have been sourced yet. # @param $1 completion file to load function from in case it is missing # @param $2... function and its arguments _xfunc() { set -- "$@" local srcfile=$1 shift declare -F $1 &>/dev/null || { local compdir=./completions [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions" . "$compdir/$srcfile" } "$@" } # source compat completion directory definitions if [[ -d $BASH_COMPLETION_COMPAT_DIR && -r $BASH_COMPLETION_COMPAT_DIR && \ -x $BASH_COMPLETION_COMPAT_DIR ]]; then for i in $(LC_ALL=C command ls "$BASH_COMPLETION_COMPAT_DIR"); do i=$BASH_COMPLETION_COMPAT_DIR/$i [[ ${i##*/} != @($_backup_glob|Makefile*|$_blacklist_glob) \ && -f $i && -r $i ]] && . "$i" done fi unset i _blacklist_glob # source user completion file [[ ${BASH_SOURCE[0]} != ~/.bash_completion && -r ~/.bash_completion ]] \ && . ~/.bash_completion unset -f have unset have set $BASH_COMPLETION_ORIGINAL_V_VALUE unset BASH_COMPLETION_ORIGINAL_V_VALUE # ex: ts=4 sw=4 et filetype=sh completions/systemd-cgtop 0000644 00000002512 14720751124 0011630 0 ustar 00 # systemd-cgtop(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word() { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } _systemd_cgtop() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local comps local -A OPTS=( [STANDALONE]='-h --help --version -p -t -c -m -i -b --batch -n --iterations -d --delay' [ARG]='--cpu --depth' ) _init_completion || return COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) } complete -F _systemd_cgtop systemd-cgtop completions/ctrlaltdel 0000644 00000000517 14720751124 0011163 0 ustar 00 _ctrlaltdel_module() { local cur prev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $(compgen -W "hard soft" -- $cur) ) fi return 0 } complete -F _ctrlaltdel_module ctrlaltdel completions/whereis 0000644 00000001027 14720751124 0010474 0 ustar 00 _whereis_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-B'|'-M'|'-S') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) ) return 0 ;; '-h'|'-V') return 0 ;; esac case $cur in -*) OPTS="-b -B -m -M -s -S -f -u -l" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac COMPREPLY=( $(compgen -W "file" -- $cur) ) return 0 } complete -F _whereis_module whereis completions/sfdisk 0000644 00000002650 14720751124 0010314 0 ustar 00 _sfdisk_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-u'|'--unit') COMPREPLY=( $(compgen -W "S C B M" -- $cur) ) return 0 ;; '-n'|'-C'|'--cylinders'|'-H'|'--heads'|'-S'|'--sectors') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; '-O'|'-I') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-h'|'--help'|'-v'|'--version') return 0 ;; esac case $cur in '=') cur=${cur#=} ;; -*) OPTS="--show-size --id --change-id --print-id --list --dump --increment --unit --one-only --list-types --DOS --DOS-extended --re-read -N -n -O -I --verify --version --help --force --no-reread --quiet --Linux --show-geometry --show-pt-geometry --activate= --unhide= --show-extended --leave-last --IBM --in-order --not-in-order --inside-outer --not-inside-outer --nested --chained --onesector --cylinders --heads --sectors" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'disk' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) return 0 } complete -F _sfdisk_module sfdisk completions/su 0000644 00000001540 14720751124 0007455 0 ustar 00 _su_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-'|'-u'|'--user') COMPREPLY=( $(compgen -u -- $cur) ) return 0 ;; '-g'|'--group'|'-G'|'--supp-group') COMPREPLY=( $(compgen -g -- $cur) ) return 0 ;; '-s'|'--shell') COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS=" --user --preserve-environment --group --supp-group --login --command --session-command --fast --shell --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _su_module su complete -F _su_module runuser completions/lvm 0000644 00000052415 14720751124 0007633 0 ustar 00 # bash completion for lvm -*- shell-script -*- _lvm_volumegroups() { COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \ sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) ) } _lvm_physicalvolumes() { COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \ sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) ) } _lvm_logicalvolumes() { COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \ sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) ) if [[ $cur == /dev/mapper/* ]]; then _filedir local i for i in ${!COMPREPLY[@]}; do [[ ${COMPREPLY[i]} == */control ]] && unset COMPREPLY[i] done fi } _lvm_units() { COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- "$cur" ) ) } _lvm_sizes() { COMPREPLY=( $( compgen -W 'k K m M g G t T' -- "$cur" ) ) } # @param $1 glob matching args known to take an argument _lvm_count_args() { args=0 local offset=1 if [[ "${words[0]}" == lvm ]]; then offset=2 fi local i prev=${words[$offset-1]} for (( i=$offset; i < cword; i++ )); do if [[ "${words[i]}" != -* && $prev != $1 ]]; then args=$(($args + 1)) fi prev=${words[i]} done } _lvmdiskscan() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) fi } && complete -F _lvmdiskscan lvmdiskscan _pvscan() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--debug --exported --novolumegroup --help --ignorelockingfailure --partial --short --uuid --verbose --version' -- "$cur" ) ) fi } && complete -F _pvscan pvscan _pvs() { local cur prev words cword _init_completion || return case $prev in -o|-O|--options|--sort) COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid pv_size pv_free pv_used pv_name pv_attr pv_pe_count pv_pe_alloc_count' -- "$cur" ) ) return 0 ;; --units) _lvm_units return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_physicalvolumes fi } && complete -F _pvs pvs _pvdisplay() { local cur prev words cword _init_completion || return case $prev in --units) _lvm_units return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_physicalvolumes fi } && complete -F _pvdisplay pvdisplay _pvchange() { local cur prev words cword _init_completion || return case $prev in -A|-x|--autobackup|--allocatable) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_physicalvolumes fi } && complete -F _pvchange pvchange _pvcreate() { local cur prev words cword _init_completion || return case $prev in --restorefile) _filedir return 0 ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) return 0 ;; --metadatacopies) COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) ) return 0 ;; --metadatasize|--setphysicalvolumesize) _lvm_sizes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_physicalvolumes fi } && complete -F _pvcreate pvcreate _pvmove() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -n|--name) _lvm_logicalvolumes return 0 esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--abort --autobackup --background --debug --force --help --interval --test --verbose --version --name' \ -- "$cur" ) ) else _lvm_physicalvolumes fi } && complete -F _pvmove pvmove _pvremove() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_physicalvolumes fi } && complete -F _pvremove pvremove _vgscan() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) fi } && complete -F _vgscan vgscan _vgs() { local cur prev words cword _init_completion || return case $prev in -o|-O|--options|--sort) COMPREPLY=( $( compgen -W 'vg_fmt vg_uuid vg_name vg_attr vg_size vg_free vg_sysid vg_extent_size vg_extent_count vg_free_count max_lv max_pv pv_count lv_count snap_count vg_seqno' \ -- "$cur" ) ) return 0 ;; --units) _lvm_units return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgs vgs _vgdisplay() { local cur prev words cword _init_completion || return case $prev in --units) _lvm_units return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgdisplay vgdisplay _vgchange() { local cur prev words cword _init_completion || return case $prev in -a|-A|-x|--available|--autobackup|--resizeable) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--autobackup --alloc --partial --debug --help --ignorelockingfailure --test --uuid --verbose --version --available --resizeable --logicalvolume --addtag --deltag' \ -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgchange vgchange _vgcreate() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) return 0 ;; -s|--physicalextentsize) _lvm_sizes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--autobackup --addtag --alloc --debug --help --maxlogicalvolumes --metadatatype --maxphysicalvolumes --physicalextentsize --test --verbose --version' -- "$cur" ) ) else local args _lvm_count_args @(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize) if [[ $args -eq 0 ]]; then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && complete -F _vgcreate vgcreate _vgremove() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgremove vgremove _vgrename() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgrename vgrename _vgreduce() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args _lvm_count_args @(-A|--autobackup) if [[ $args -eq 0 ]]; then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && complete -F _vgreduce vgreduce _vgextend() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -L|--size) _lvm_sizes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args _lvm_count_args @(-A|--autobackup|-L|--size) if [[ $args -eq 0 ]]; then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && complete -F _vgextend vgextend _vgport() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgport vgimport vgexport _vgck() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgck vgck _vgconvert() { local cur prev words cword _init_completion || return case $prev in -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) return 0 ;; --metadatacopies) COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) ) return 0 ;; --metadatasize) _lvm_sizes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgconvert vgconvert _vgcfgbackup() { local cur prev words cword _init_completion || return case $prev in -f|--file) _filedir return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgcfgbackup vgcfgbackup _vgcfgrestore() { local cur prev words cword _init_completion || return case $prev in -f|--file) _filedir return 0 ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) return 0 ;; -n|--name) _lvm_volumegroups return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgcfgrestore vgcfgrestore _vgmerge() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgmerge vgmerge _vgsplit() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -M|--metadatatype) COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--autobackup --debug --help --list --metadatatype --test --verbose --version' -- "$cur" ) ) else local args _lvm_count_args @(-A|--autobackup|-M|--metadatatype) if [[ $args -eq 0 || $args -eq 1 ]]; then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && complete -F _vgsplit vgsplit _vgmknodes() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_volumegroups fi } && complete -F _vgmknodes vgmknodes _lvscan() { local cur prev words cword _init_completion || return if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) fi } && complete -F _lvscan lvscan _lvs() { local cur prev words cword _init_completion || return case $prev in -o|-O|--options|--sort) COMPREPLY=( $( compgen -W 'lv_uuid lv_name lv_attr lv_minor lv_size seg_count origin snap_percent segtype stripes stripesize chunksize seg_start seg_size' -- "$cur" ) ) return 0 ;; --units) _lvm_units return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_logicalvolumes fi } && complete -F _lvs lvs _lvdisplay() { local cur prev words cword _init_completion || return case $prev in --units) _lvm_units return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_logicalvolumes fi } && complete -F _lvdisplay lvdisplay _lvchange() { local cur prev words cword _init_completion || return case $prev in -a|-A|-C|-M|--available|--autobackup|--contiguous|--persistent) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -p|--permission) COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_logicalvolumes fi } && complete -F _lvchange lvchange _lvcreate() { local cur prev words cword _init_completion || return case $prev in -A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -L|--size) _lvm_sizes return 0 ;; -p|--permission) COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) ) return 0 ;; -n|--name) _lvm_logicalvolumes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args _lvm_count_args @(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name) if [[ $args -eq 0 ]]; then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && complete -F _lvcreate lvcreate _lvremove() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_logicalvolumes fi } && complete -F _lvremove lvremove _lvrename() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_logicalvolumes fi } && complete -F _lvrename lvrename _lvreduce() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -L|--size) _lvm_sizes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _lvm_logicalvolumes fi } && complete -F _lvreduce lvreduce _lvresize() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -L|--size) _lvm_sizes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args _lvm_count_args @(-A|--autobackup|-L|--size) if [[ $args -eq 0 ]]; then _lvm_logicalvolumes else _lvm_physicalvolumes fi fi } && complete -F _lvresize lvresize _lvextend() { local cur prev words cword _init_completion || return case $prev in -A|--autobackup) COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) ) return 0 ;; -L|--size) _lvm_sizes return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else local args _lvm_count_args @(-A|--autobackup|-L|--size) if [[ $args -eq 0 ]]; then _lvm_logicalvolumes else _lvm_physicalvolumes fi fi } && complete -F _lvextend lvextend _lvm() { local cur prev words cword _init_completion || return if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W 'dumpconfig help lvchange lvcreate lvdisplay lvextend lvmchange lvmdiskscan lvmsadc lvmsar lvreduce lvremove lvrename lvresize lvs lvscan pvchange pvcreate pvdata pvdisplay pvmove pvremove pvresize pvs pvscan vgcfgbackup vgcfgrestore vgchange vgck vgconvert vgcreate vgdisplay vgexport vgextend vgimport vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan vgsplit version' -- "$cur" ) ) else case ${words[1]} in pvchange) _pvchange ;; pvcreate) _pvcreate ;; pvdisplay) _pvdisplay ;; pvmove) _pvmove ;; pvremove) _pvremove ;; pvresize) _pvresize ;; pvs) _pvs ;; pvscan) _pvscan ;; vgcfgbackup) _vgcfgbackup ;; vgcfgrestore) _vgcfgrestore ;; vgchange) _vgchange ;; vgck) _vgck ;; vgconvert) _vgconvert ;; vgcreate) _vgcreate ;; vgdisplay) _vgdisplay ;; vgexport) _vgexport ;; vgextend) _vgextend ;; vgimport) _vgimport ;; vgmerge) _vgmerge ;; vgmknodes) _vgmknodes ;; vgreduce) _vgreduce ;; vgremove) _vgremove ;; vgrename) _vgrename ;; vgs) _vgs ;; vgscan) _vgscan ;; vgsplit) _vgsplit ;; lvchange) _lvchange ;; lvcreate) _lvcreate ;; lvdisplay) _lvdisplay ;; lvextend) _lvextend ;; lvreduce) _lvreduce ;; lvremove) _lvremove ;; lvrename) _lvrename ;; lvresize) _lvresize ;; lvs) _lvs ;; lvscan) _lvscan ;; esac fi } && complete -F _lvm lvm # ex: ts=4 sw=4 et filetype=sh completions/pip3 0000644 00000000420 14720751124 0007675 0 ustar 00 # pip bash completion start _pip3_completion() { COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ COMP_CWORD=$COMP_CWORD \ PIP_AUTO_COMPLETE=1 $1 ) ) } complete -o default -F _pip3_completion pip3 pip3.6 # pip bash completion end completions/readprofile 0000644 00000001247 14720751124 0011326 0 ustar 00 _readprofile_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-m'|'--mapfile'|'-p'|'--profile') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-M'|'--multiplier') COMPREPLY=( $(compgen -W "multiplier" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS="--mapfile --profile --multiplier --info --verbose --all --histbin --counters --reset --no-auto --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _readprofile_module readprofile completions/localectl 0000644 00000006554 14720751124 0011002 0 ustar 00 # localectl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __locale_fields=( LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME \ LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER \ LC_NAME LC_ADDRESS LC_TELEPHONE \ LC_MEASUREMENT LC_IDENTIFICATION ) # LC_ALL is omitted on purpose _localectl() { local i verb comps locale_vals local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --no-convert --no-pager --no-ask-password -H --host --machine' if __contains_word "$prev" $OPTS; then case $prev in --host|-H) comps='' ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi local -A VERBS=( [STANDALONE]='status list-locales list-keymaps' [LOCALES]='set-locale' [KEYMAPS]='set-keymap' [X11]='set-x11-keymap' ) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[LOCALES]}; then if [[ $cur = *=* ]]; then mapfile -t locale_vals < <(command localectl list-locales 2>/dev/null) COMPREPLY=( $(compgen -W '${locale_vals[*]}' -- "${cur#=}") ) elif [[ $prev = "=" ]]; then mapfile -t locale_vals < <(command localectl list-locales 2>/dev/null) COMPREPLY=( $(compgen -W '${locale_vals[*]}' -- "$cur") ) else compopt -o nospace COMPREPLY=( $(compgen -W '${__locale_fields[*]}' -S= -- "$cur") ) fi return 0 elif __contains_word "$verb" ${VERBS[KEYMAPS]}; then comps=$(command localectl list-keymaps) elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[X11]}; then comps='' fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _localectl localectl completions/fsck 0000644 00000001425 14720751124 0007756 0 ustar 00 _fsck_module() { local cur prev OPTS DEVS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-b') COMPREPLY=( $(compgen -W "superblock" -- $cur) ) return 0 ;; '-B') COMPREPLY=( $(compgen -W "blocksize" -- $cur) ) return 0 ;; '-j') COMPREPLY=( $(compgen -W "external_journal" -- $cur) ) return 0 ;; '-l'|'-L') COMPREPLY=( $(compgen -W "bad_blocks_file" -- $cur) ) return 0 ;; '-?') return 0 ;; esac case $cur in -*) OPTS="-p -n -y -c -f -v -b -B -j -l -L" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) COMPREPLY=( $(compgen -W "$DEVS" -- $cur) ) return 0 } complete -F _fsck_module fsck completions/raw 0000644 00000000742 14720751124 0007622 0 ustar 00 _raw_module() { local cur prev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) local OPTS OPTS="--query --all --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac COMPREPLY=( $(compgen -W "$(for I in /dev/raw/*; do if [ -e $I ]; then echo $I; fi; done)" -- $cur) ) return 0 } complete -F _raw_module raw completions/setarch 0000644 00000001407 14720751124 0010461 0 ustar 00 _setarch_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $(compgen -W "$(setarch --list)" -- $cur) ) return 0 fi case $cur in -*) OPTS="--verbose --addr-no-randomize --fdpic-funcptrs --mmap-page-zero --addr-compat-layout --read-implies-exec --32bit --short-inode --whole-seconds --sticky-timeouts --3gb --4gb --uname-2.6 --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 } complete -F _setarch_module setarch completions/findmnt 0000644 00000005427 14720751124 0010475 0 ustar 00 _findmnt_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-p'|'--poll') COMPREPLY=( $(compgen -W "=list" -- $cur) ) return 0 ;; '-w'|'--timeout') COMPREPLY=( $(compgen -W "timeout" -- $cur) ) return 0 ;; '-d'|'--direction') COMPREPLY=( $(compgen -W "forward backward" -- $cur) ) return 0 ;; '-F'|'--tab-file') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-N'|'--task') local TID='' I ARR for I in /proc/*/mountinfo; do IFS=/ read -ra ARR <<< "$I"; TID+="${ARR[2]} "; done COMPREPLY=( $(compgen -W "$TID" -- $cur) ) return 0 ;; '-O'|'--options') local MTAB_3RD I declare -a TMP_ARR declare -A MNT_OPTS while read MTAB_3RD; do IFS=',' read -ra TMP_ARR <<<"$MTAB_3RD" for I in ${TMP_ARR[@]}; do MNT_OPTS[$I]='1' done done < <(findmnt -rno OPTIONS) COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) ) return 0 ;; '-o'|'--output') # FIXME: how to append to a string with compgen? local OUTPUT OUTPUT="SOURCE TARGET FSTYPE OPTIONS VFS-OPTIONS FS-OPTIONS LABEL UUID PARTLABEL PARTUUID MAJ\:MIN ACTION OLD-TARGET OLD-OPTIONS SIZE AVAIL USED USE% FSROOT TID ID OPT-FIELDS PROPAGATION FREQ PASSNO" compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-t'|'--types') local TYPES TYPES="adfs affs autofs cifs coda coherent cramfs debugfs devpts efs ext ext2 ext3 ext4 hfs hfsplus hpfs iso9660 jfs minix msdos ncpfs nfs nfs4 ntfs proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs umsdos usbfs vfat xenix xfs xiafs" COMPREPLY=( $(compgen -W "$TYPES" -- $cur) ) return 0 ;; '-S'|'--source') local DEV_MPOINT DEV_MPOINT=$(findmnt -rno SOURCE | grep ^/dev) COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) return 0 ;; '-T'|'--target') local DEV_MPOINT DEV_MPOINT=$(findmnt -rno TARGET) COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--fstab --mtab --kernel --poll --timeout --all --ascii --canonicalize --df --direction --evaluate --tab-file --first-only --invert --list --task --noheadings --notruncate --options --output --pairs --raw --types --nofsroot --submounts --source --target --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEV_MPOINT DEV_MPOINT=$(findmnt -rno TARGET,SOURCE) COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) return 0 } complete -F _findmnt_module findmnt completions/ul 0000644 00000001217 14720751124 0007447 0 ustar 00 _ul_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-t'|'--terminal') local TERM_LIST I TERM_LIST='' for I in /usr/share/terminfo/?/*; do TERM_LIST+="${I##*/} " done COMPREPLY=( $(compgen -W "$TERM_LIST" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--terminal --indicated --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _ul_module ul completions/chsh 0000644 00000000772 14720751124 0007761 0 ustar 00 _chsh_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-s'|'--shell') COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) ) return 0 ;; '-u'|'--help'|'-v'|'--version') return 0 ;; esac case $cur in -*) OPTS="--shell --list-shells --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac COMPREPLY=( $(compgen -u -- $cur) ) return 0 } complete -F _chsh_module chsh completions/yum 0000644 00000026350 14720751124 0007646 0 ustar 00 # bash completion for yum _yum_helper() { local IFS=$'\n' if [[ -n "$YUM_CACHEDIR" && "$1 $2" == "list available" ]]; then for db in $(find "$YUM_CACHEDIR" -name primary_db.sqlite); do COMPREPLY+=( $( sqlite3 "$db" \ "SELECT name||'.'||arch FROM packages WHERE name LIKE '$3%'" ) ) done return fi COMPREPLY+=( $( /usr/share/yum-cli/completion-helper.py -d 0 -C "$@" 2>/dev/null ) ) } _yum_list() { # Fail fast for things that look like paths or options. [[ $2 == */* || $2 == [.~-]* ]] && return # Listing all available packages takes way too long [[ $1 != "installed" && ${#2} -lt 1 ]] && return _yum_helper list "$@" } # arguments: # 1 = 1 or 0 to list enabled or disabled plugins # 2 = current word to be completed _yum_plugins() { local val [[ $1 -eq 1 ]] && val='\(1\|yes\|true\|on\)' || val='\(0\|no\|false\|off\)' COMPREPLY+=( $( compgen -W '$( command grep -il "^\s*enabled\s*=\s*$val" \ /etc/yum/pluginconf.d/*.conf 2>/dev/null \ | sed -ne "s|^.*/\([^/]\{1,\}\)\.conf$|\1|p" )' -- "$2" ) ) } # arguments: # 1 = current word to be completed _yum_binrpmfiles() { COMPREPLY+=( $( compgen -f -o plusdirs -X '!*.rpm' -- "$1" ) ) COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -X '*.src.rpm' ) ) COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -X '*.nosrc.rpm' ) ) } _yum_baseopts() { local opts='--help --tolerant --cacheonly --config --randomwait --debuglevel --showduplicates --errorlevel --rpmverbosity --quiet --verbose --assumeyes --assumeno --version --installroot --enablerepo --disablerepo --exclude --disableexcludes --obsoletes --noplugins --nogpgcheck --skip-broken --color --releasever --setopt --downloadonly --downloaddir --disableincludes' [[ $COMP_LINE == *--noplugins* ]] || \ opts+=" --disableplugin --enableplugin" printf %s "$opts" } _yum_transactions() { COMPREPLY+=( $( compgen -W "$( $yum -d 0 -C history 2>/dev/null | \ sed -ne 's/^[[:space:]]*\([0-9]\{1,\}\).*/\1/p' )" -- "$cur" ) ) } _yum_atgroups() { if [[ $1 == \@* ]]; then _yum_helper groups list all "${1:1}" COMPREPLY=( "${COMPREPLY[@]/#/@}" ) return 0 fi return 1 } # arguments: # 1 = current word to be completed # 2 = previous word # return 0 if no more completions should be sought, 1 otherwise _yum_complete_baseopts() { case $2 in -d|--debuglevel|-e|--errorlevel) COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- "$1" ) ) return 0 ;; --rpmverbosity) COMPREPLY=( $( compgen -W 'info critical emergency error warn debug' -- "$1" ) ) return 0 ;; -c|--config) COMPREPLY=( $( compgen -f -o plusdirs -X "!*.conf" -- "$1" ) ) return 0 ;; --installroot|--downloaddir) COMPREPLY=( $( compgen -d -- "$1" ) ) return 0 ;; --enablerepo) _yum_helper repolist disabled "$1" return 0 ;; --disablerepo) _yum_helper repolist enabled "$1" return 0 ;; --disableexcludes|--disableincludes) _yum_helper repolist all "$1" local main= [[ $2 == *excludes ]] && main=main COMPREPLY=( $( compgen -W '${COMPREPLY[@]} all $main' -- "$1" ) ) return 0 ;; --enableplugin) _yum_plugins 0 "$1" return 0 ;; --disableplugin) _yum_plugins 1 "$1" return 0 ;; --color) COMPREPLY=( $( compgen -W 'always auto never' -- "$1" ) ) return 0 ;; -R|--randomwait|-x|--exclude|-h|--help|--version|--releasever|--cve|\ --bz|--advisory|--tmprepo|--verify-filenames|--setopt) return 0 ;; --download-order) COMPREPLY=( $( compgen -W 'default smallestfirst largestfirst' \ -- "$1" ) ) return 0 ;; --override-protection) _yum_list installed "$1" return 0 ;; --verify-configuration-files) COMPREPLY=( $( compgen -W '1 0' -- "$1" ) ) return 0 ;; esac return 1 } _yum() { COMPREPLY=() local yum=$1 cur=$2 prev=$3 words=("${COMP_WORDS[@]}") declare -F _get_comp_words_by_ref &>/dev/null && \ _get_comp_words_by_ref -n = cur prev words # Commands offered as completions local cmds=( check check-update clean deplist distro-sync downgrade groups help history info install list load-transaction makecache provides reinstall remove repolist search shell update upgrade version ) local i c cmd subcmd for (( i=1; i < ${#words[@]}-1; i++ )) ; do [[ -n $cmd ]] && subcmd=${words[i]} && break # Recognize additional commands and aliases for c in ${cmds[@]} check-rpmdb distribution-synchronization erase \ group groupinfo groupinstall grouplist groupremove groupupdate \ grouperase install-na load-ts localinstall localupdate whatprovides ; do [[ ${words[i]} == $c ]] && cmd=$c && break done done case $cmd in check|check-rpmdb) COMPREPLY=( $( compgen -W 'dependencies duplicates all' \ -- "$cur" ) ) return 0 ;; check-update|makecache|resolvedep) return 0 ;; clean) [[ $prev == $cmd ]] && \ COMPREPLY=( $( compgen -W 'expire-cache packages headers metadata cache dbcache all' -- "$cur" ) ) return 0 ;; deplist) COMPREPLY=( $( compgen -f -o plusdirs -X '!*.[rs]pm' -- "$cur" ) ) _yum_list all "$cur" return 0 ;; distro-sync|distribution-synchronization) [[ $prev == $cmd ]] && \ COMPREPLY=( $( compgen -W 'full different' -- "$cur" ) ) _yum_list installed "$cur" return 0 ;; downgrade|reinstall) if ! _yum_atgroups "$cur" ; then _yum_binrpmfiles "$cur" _yum_list installed "$cur" fi return 0 ;; erase|remove) _yum_atgroups "$cur" || _yum_list installed "$cur" return 0 ;; group*) if [[ ($cmd == groups || $cmd == group) && $prev == $cmd ]] ; then COMPREPLY=( $( compgen -W 'info install list remove summary' \ -- "$cur" ) ) else _yum_helper groups list all "$cur" fi return 0 ;; help) [[ $prev == $cmd ]] && \ COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) ) return 0 ;; history) if [[ $prev == $cmd ]] ; then COMPREPLY=( $( compgen -W 'info list packages-list packages-info summary addon-info redo undo rollback new sync stats' -- "$cur" ) ) return 0 fi case $subcmd in undo|repeat|addon|addon-info|rollback) if [[ $prev == $subcmd ]]; then COMPREPLY=( $( compgen -W "last" -- "$cur" ) ) _yum_transactions fi ;; redo) case $prev in redo) COMPREPLY=( $( compgen -W "force-reinstall force-remove last" -- "$cur" ) ) _yum_transactions ;; reinstall|force-reinstall|remove|force-remove) COMPREPLY=( $( compgen -W "last" -- "$cur" ) ) _yum_transactions ;; esac ;; package-list|pkg|pkgs|pkg-list|pkgs-list|package|packages|\ packages-list|pkg-info|pkgs-info|package-info|packages-info) _yum_list available "$cur" ;; info|list|summary) if [[ $subcmd != info ]] ; then COMPREPLY=( $( compgen -W "all" -- "$cur" ) ) [[ $cur != all ]] && _yum_list available "$cur" else _yum_list available "$cur" fi _yum_transactions ;; sync|synchronize) _yum_list installed "$cur" ;; esac return 0 ;; info) _yum_list all "$cur" return 0 ;; install) if ! _yum_atgroups "$cur" ; then _yum_binrpmfiles "$cur" _yum_list available "$cur" fi return 0 ;; install-na) _yum_list available "$cur" return 0 ;; list) [[ $prev == $cmd ]] && \ COMPREPLY=( $( compgen -W 'all available updates installed extras obsoletes recent' -- "$cur" ) ) return 0 ;; load-transaction|load-ts) COMPREPLY=( $( compgen -f -o plusdirs -X '!*.yumtx' -- "$cur" ) ) return 0 ;; localinstall|localupdate) _yum_binrpmfiles "$cur" return 0 ;; provides|whatprovides) COMPREPLY=( $( compgen -f -o plusdirs -- "$cur" ) ) return 0 ;; repolist) [[ $prev == $cmd ]] && \ COMPREPLY=( $( compgen -W 'all enabled disabled' -- "$cur" ) ) return 0 ;; search) [[ $prev == $cmd ]] && COMPREPLY=( $( compgen -W 'all' -- "$cur" ) ) return 0 ;; shell) [[ $prev == $cmd ]] && \ COMPREPLY=( $( compgen -f -o plusdirs -- "$cur" ) ) return 0 ;; update|upgrade) if ! _yum_atgroups "$cur" ; then _yum_binrpmfiles "$cur" _yum_list updates "$cur" fi return 0 ;; version) [[ $prev == $cmd ]] && \ COMPREPLY=( $( compgen -W 'all installed available nogroups grouplist groupinfo' -- "$cur" ) ) return 0 ;; esac local split=false declare -F _split_longopt &>/dev/null && _split_longopt && split=true _yum_complete_baseopts "$cur" "$prev" && return 0 $split && return 0 if [[ $cur == -* ]] ; then COMPREPLY=( $( compgen -W '$( _yum_baseopts )' -- "$cur" ) ) return 0 fi COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) ) } && complete -F _yum -o filenames yum yummain.py # Local variables: # mode: shell-script # sh-basic-offset: 4 # sh-indent-comment: t # indent-tabs-mode: nil # End: # ex: ts=4 sw=4 et filetype=sh completions/mkswap 0000644 00000001375 14720751124 0010336 0 ustar 00 _mkswap_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-p'|'--pagesize') COMPREPLY=( $(compgen -W "bytes" -- $cur) ) return 0 ;; '-L'|'--label') COMPREPLY=( $(compgen -W "label" -- $cur) ) return 0 ;; '-v'|'--swapversion') COMPREPLY=( $(compgen -W "1" -- $cur) ) return 0 ;; '-U'|'--uuid'|'-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--check --force --pagesize --label --swapversion --uuid --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _mkswap_module mkswap completions/colcrt 0000644 00000000744 14720751124 0010321 0 ustar 00 _colcrt_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS=" --no-underlining --half-lines --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _colcrt_module colcrt completions/systemd-analyze 0000644 00000007625 14720751124 0012171 0 ustar 00 # systemd-analyze(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # Copyright 2013 Harald Hoyer # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __get_machines() { local a b machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } _systemd_analyze() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='--help --version --system --from-pattern --to-pattern --order --require --no-pager' [ARG]='-H --host -M --machine --fuzz --man' ) local -A VERBS=( [STANDALONE]='time blame plot dump' [CRITICAL_CHAIN]='critical-chain' [DOT]='dot' [LOG_LEVEL]='set-log-level' [VERIFY]='verify' ) _init_completion || return for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then verb=${COMP_WORDS[i]} break fi done if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --host|-H) comps=$(compgen -A hostname) ;; --machine|-M) comps=$( __get_machines ) ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ -z $verb && $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then if [[ $cur = -* ]]; then comps='--help --version --system ' fi elif __contains_word "$verb" ${VERBS[CRITICAL_CHAIN]}; then if [[ $cur = -* ]]; then comps='--help --version --system --fuzz' fi elif __contains_word "$verb" ${VERBS[DOT]}; then if [[ $cur = -* ]]; then comps='--help --version --system --from-pattern --to-pattern --order --require' fi elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then if [[ $cur = -* ]]; then comps='--help --version --system' else comps='debug info notice warning err crit alert emerg' fi elif __contains_word "$verb" ${VERBS[VERIFY]}; then if [[ $cur = -* ]]; then comps='--help --version --system --no-man' else comps=$( compgen -A file -- "$cur" ) compopt -o filenames fi fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _systemd_analyze systemd-analyze completions/resizepart 0000644 00000001263 14720751124 0011220 0 ustar 00 _resizepart_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $COMP_CWORD in 1) local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'disk' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) OPTS="--help --version $DEVICES" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) ;; 2) prev="${COMP_WORDS[COMP_CWORD-1]}" COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) ) ;; 3) COMPREPLY="length" ;; esac return 0 } complete -F _resizepart_module resizepart completions/kmod 0000644 00000006243 14720751124 0007765 0 ustar 00 # kmod completion -*- shell-script -*- # # This file is part of kmod. # # Copyright 2010 Ran Benita # Copyright (C) 2013 Intel Corporation. All rights reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. __contains_word () { local word=$1; shift for w in "$@"; do [[ "$w" = "$word" ]] && return 0; done return 1 } __is_opt () { local prevprev=${COMP_WORDS[COMP_CWORD-2]} local short="$1" long="$2" if [[ "$prev" = "$short" || "$prev" = "$long" ]]; then declare -g cur=${cur#=} return 0 elif [[ "$prev" = "=" && "$prevprev" = "$long" ]]; then return 0 fi return 1 } _kmod_static_nodes () { local OPTS='-o -f -h --help' local OPTS_EQUAL='--output --format' local GROUP_FORMAT='human tmpfiles devname' if __is_opt '-o' '--output'; then compopt -o filenames COMPREPLY=( $(compgen -f -- "$cur") ) return 0 elif __is_opt '-f' '--format'; then COMPREPLY=( $(compgen -W "$GROUP_FORMAT" -- "$cur" ) ) return 0 fi local cur=${COMP_WORDS[COMP_CWORD]} compopt -o nospace COMPREPLY=( $(compgen -W "$OPTS" -- "$cur") ) COMPREPLY+=( $(compgen -W "$OPTS_EQUAL" -S= -- "$cur") ) } _kmod() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local VERBS=(help list static-nodes) local OPTS='-h --help -V --version' local verb # standalone options, no other option or action allowed for ((i=0; $i < $COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${OPTS}; then return 0 fi done # find the action for ((i=0; $i <= $COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" "${VERBS[@]}"; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]} ${VERBS[*]}' -- "$cur") ) return 0 fi local func=${verb//-/_} if declare -F _kmod_${func} > /dev/null; then _kmod_${func} fi # allow the space if there's only one completion and it doesn't end with # '=' if [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *"=" ]] ; then compopt +o nospace fi return 0 } complete -F _kmod kmod completions/xz 0000644 00000002731 14720751124 0007472 0 ustar 00 # xz(1) completion -*- shell-script -*- _xz() { local cur prev words cword split _init_completion -s || return local xspec="*.@(xz|lzma|txz|tlz)" case $prev in --decompress|--list|--test|-!(-*)[dlt]*) xspec="!"$xspec ;; --files|--files0) _filedir return 0 ;; -C|--check) COMPREPLY=( $( compgen -W 'crc32 crc64 sha256 none' -- "$cur" ) ) return 0 ;; -F|--format) COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- "$cur" ) ) return 0 ;; -M|--memlimit|--memlimit-compress|--memlimit-decompress|--memory|\ -S|--suffix|--delta|--lzma1|--lzma2) # argument required but no completions available return 0 ;; -h|--help|-H|--long-help|-V|--version|--info-memory) # all other arguments are noop with these return 0 ;; esac $split && return 0 _expand || return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \ -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return 0 fi local IFS=$'\n' compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ $( compgen -d -- "$cur" ) ) } && complete -F _xz xz pxz # ex: ts=4 sw=4 et filetype=sh completions/curl 0000644 00000005653 14720751124 0010004 0 ustar 00 # curl(1) completion -*- shell-script -*- _curl() { local cur prev words cword _init_completion || return case $prev in --ciphers|--connect-timeout|-C|--continue-at|-F|--form|--form-string|\ --ftp-account|--ftp-alternative-to-user|-P|--ftp-port|-H|--header|-h|\ --help|--hostpubmd5|--keepalive-time|--krb|--limit-rate|--local-port|\ --mail-from|--mail-rcpt|--max-filesize|--max-redirs|-m|--max-time|\ --pass|--proto|--proto-redir|--proxy-user|--proxy1.0|-Q|--quote|-r|\ --range|-X|--request|--retry|--retry-delay|--retry-max-time|\ --socks5-gssapi-service|-t|--telnet-option|--tftp-blksize|-z|\ --time-cond|--url|-u|--user|-A|--user-agent|-V|--version|-w|\ --write-out|--resolve|--tlsuser|--tlspassword) return ;; -K|--config|-b|--cookie|-c|--cookie-jar|-D|--dump-header|--egd-file|\ --key|--libcurl|-o|--output|--random-file|-T|--upload-file|--trace|\ --trace-ascii|--netrc-file) _filedir return ;; --cacert|-E|--cert) _filedir '@(c?(e)rt|cer|pem|der)' return ;; --capath) _filedir -d return ;; --cert-type|--key-type) COMPREPLY=( $( compgen -W 'DER PEM ENG' -- "$cur" ) ) return ;; --crlfile) _filedir crl return ;; -d|--data|--data-ascii|--data-binary|--data-urlencode) if [[ $cur == \@* ]]; then cur=${cur:1} _filedir COMPREPLY=( "${COMPREPLY[@]/#/@}" ) fi return ;; --delegation) COMPREPLY=( $( compgen -W 'none policy always' -- "$cur" ) ) return ;; --engine) COMPREPLY=( $( compgen -W 'list' -- "$cur" ) ) return ;; --ftp-method) COMPREPLY=( $( compgen -W 'multicwd nocwd singlecwd' -- "$cur" ) ) return ;; --ftp-ssl-ccc-mode) COMPREPLY=( $( compgen -W 'active passive' -- "$cur" ) ) return ;; --interface) _available_interfaces -a return ;; -x|--proxy|--socks4|--socks4a|--socks5|--socks5-hostname) _known_hosts_real return ;; --pubkey) _filedir pub return ;; --stderr) COMPREPLY=( $( compgen -W '-' -- "$cur" ) ) _filedir return ;; --tlsauthtype) COMPREPLY=( $( compgen -W 'SRP' -- "$cur" ) ) return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) fi } && complete -F _curl curl # ex: ts=4 sw=4 et filetype=sh completions/fdisk 0000644 00000002057 14720751124 0010132 0 ustar 00 _fdisk_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-s') local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'part' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) return 0 ;; '-b') COMPREPLY=( $(compgen -W "512 1024 2048 4096" -- $cur) ) return 0 ;; '-c') COMPREPLY=( $(compgen -W "dos nondos" -- $cur) ) return 0 ;; '-u') COMPREPLY=( $(compgen -W "cylinders sectors" -- $cur) ) return 0 ;; '-C'|'-H'|'-S') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; '-h'|'-v') return 0 ;; esac case $cur in -*) OPTS="-l -s -b -c -h -u -v -C -H -S" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'disk' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) return 0 } complete -F _fdisk_module fdisk completions/systemd-run 0000644 00000007016 14720751124 0011324 0 ustar 00 # systemd-run(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2013 Zbigniew Jędrzejewski-Szmek # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __systemctl() { local mode=$1; shift 1 systemctl $mode --full --no-legend "$@" } __get_slice_units () { __systemctl $1 list-units --all -t slice \ | { while read -r a b c d; do echo " $a"; done; }; } __get_machines() { local a b machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } _systemd_run() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --system --scope --unit --description --slice -r --remain-after-exit --send-sighup -H --host -M --machine --service-type --uid --gid --nice --setenv -p --property' local mode=--system local i for (( i=1; i <= COMP_CWORD; i++ )); do if [[ ${COMP_WORDS[i]} != -* ]]; then local root_command=${COMP_WORDS[i]} _command_offset $i return fi [[ $i -lt $COMP_CWORD && ${COMP_WORDS[i]} == @(--unit|--description|--slice|--service-type|-H|--host|-M|--machine|-p|--property) ]] && ((i++)) done case "$prev" in --unit|--description) # argument required but no completions available return ;; --slice) local comps=$(__get_slice_units $mode) COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 ;; --service-type) local comps='simple forking oneshot dbus notify idle' COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 ;; -p|--property) local comps='CPUAccounting= MemoryAccounting= BlockIOAccounting= SendSIGHUP= SendSIGKILL= MemoryLimit= CPUShares= BlockIOWeight= User= Group= DevicePolicy= KillMode= DeviceAllow= BlockIOReadBandwidth= BlockIOWriteBandwidth= BlockIODeviceWeight= Nice= Environment= KillSignal= LimitCPU= LimitFSIZE= LimitDATA= LimitSTACK= LimitCORE= LimitRSS= LimitNOFILE= LimitAS= LimitNPROC= LimitMEMLOCK= LimitLOCKS= LimitSIGPENDING= LimitMSGQUEUE= LimitNICE= LimitRTPRIO= LimitRTTIME= PassEnvironment=' COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 ;; -H|--host) local comps=$(compgen -A hostname) COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 ;; -M|--machine) local comps=$( __get_machines ) COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 ;; esac COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 } complete -F _systemd_run systemd-run completions/udevadm 0000644 00000007216 14720751124 0010461 0 ustar 00 # udevadm(8) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __get_all_sysdevs() { local -a devs=(/sys/bus/*/devices/*/ /sys/class/*/*/) printf '%s\n' "${devs[@]%/}" } _udevadm() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --debug' local verbs=(info trigger settle control monitor hwdb test-builtin test) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" "${verbs[@]}" && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]} ${verbs[*]}' -- "$cur") ) return 0 fi case $verb in 'info') if [[ $cur = -* ]]; then comps='--help --query= --path= --name= --root --attribute-walk --export-db --cleanup-db' else comps=$( __get_all_sysdevs ) fi ;; 'trigger') comps='--help --verbose --dry-run --type= --action= --subsystem-match= --subsystem-nomatch= --attr-match= --attr-nomatch= --property-match= --tag-match= --sysname-match= --parent-match=' ;; 'settle') comps='--help --timeout= --seq-start= --seq-end= --exit-if-exists= --quiet' ;; 'control') comps='--help --exit --log-priority= --stop-exec-queue --start-exec-queue --reload --property= --children-max= --timeout=' ;; 'monitor') comps='--help --kernel --udev --property --subsystem-match= --tag-match=' ;; 'hwdb') comps='--help --update --test=' ;; 'test') if [[ $cur = -* ]]; then comps='--help --action=' else comps=$( __get_all_sysdevs ) fi ;; 'test-builtin') comps='blkid btrfs hwdb input_id keyboard kmod net_id net_setup_link path_id usb_id uaccess' ;; *) comps=${VERBS[*]} ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _udevadm udevadm completions/setsid 0000644 00000000661 14720751124 0010324 0 ustar 00 _setsid_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--ctty --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 } complete -F _setsid_module setsid completions/setsebool 0000644 00000003430 14720751124 0011025 0 ustar 00 # This file is part of systemd. # # Copyright 2011 Dan Walsh # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local word=$1; shift for w in $*; do [[ $w = $word ]] && return 0; done return 1 } __get_all_booleans () { getsebool -a | cut -f1 -d' ' } _setsebool () { local command=${COMP_WORDS[1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local verb comps if [ "$verb" = "" -a "$prev" = "setsebool" -o "$prev" = "-P" ]; then COMPREPLY=( $(compgen -W "-P $( __get_all_booleans ) " -- "$cur") ) return 0 fi COMPREPLY=( $(compgen -W "0 1 -P" -- "$cur") ) return 0 } _getsebool () { local command=${COMP_WORDS[1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local verb comps if [ "$verb" = "" -a "$prev" == "getsebool" ]; then COMPREPLY=( $(compgen -W "-a $( __get_all_booleans ) " -- "$cur") ) return 0 fi if [ "$verb" = "" -a "$prev" != "-a" ]; then COMPREPLY=( $(compgen -W "$( __get_all_booleans ) " -- "$cur") ) return 0 fi return 0 } complete -F _setsebool setsebool complete -F _getsebool getsebool completions/lsmcli 0000644 00000045053 14720751124 0010320 0 ustar 00 # Copyright (C) 2015 Red Hat, Inc., Tony Asleson <tasleson@redhat.com> # Distributed under the GNU General Public License, version 2.0. # See: https://www.gnu.org/licenses/gpl-2.0.html # # Bash completion for lsmcli. This may be far from ideal, # suggestions & improvements appreciated! potential_args='' # Skip value lookups by default NO_VALUE_LOOKUP=${LSMCLI_AUTO_COMPLETE_VALUE:=0} function join { local IFS="$1"; shift; echo "$*"; } # Linear search of an array of strings for the specified string function listcontains() { declare -a the_list=("${!1}") for word in "${the_list[@]}" ; do [[ ${word} == $2 ]] && return 0 done return 1 } # Given a list of what is possible and what is on the command line return # what is left. # $1 What is possible # Retults are returned in global string $potential_args function possible_args() { local l=() for i in $1 do listcontains COMP_WORDS[@] "$i" if [[ $? -eq 1 ]] ; then l+=("$i") fi done potential_args=$( join ' ', "${l[@]}" ) } # Returns the position of the value in the COMP_WORDS that contains $1, or # 255 if it doesn't exist function arg_index() { count=0 for i in "${COMP_WORDS[@]}" do if [[ "$i" == "$1" ]] ; then return ${count} fi let count+=1 done return 255 } function _lsm() { local cur prev opts sep='#' COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts_short="-b -v -u -P -H -t -e -f -w -b" opts_long=" --help --version --uri --prompt --human --terse --enum \ --force --wait --header --script " opts_cmds="list job-status capabilities plugin-info volume-create \ volume-delete volume-resize volume-replicate \ volume-replicate-range volume-replicate-range-block-size \ volume-dependants volume-dependants-rm volume-access-group \ volume-mask volume-unmask access-group-create \ access-group-delete access-group-add access-group-remove \ volume-enable volume-disable iscsi-chap fs-create fs-delete \ fs-resize fs-export fs-unexport fs-clone fs-snap-create \ fs-snap-delete fs-snap-restore fs-dependants fs-dependants-rm \ file-clone ls lp lv ld la lf lt lb c p vc vd vr vm vi ve vi ac \ aa ar ad vri volume-raid-info pool-member-info pmi \ vrc volume-raid-create vrcc volume-raid-create-cap \ volume-phy-disk-cache-update vpdcu \ volume-read-cache-policy-update vrcpu \ volume-write-cache-policy-update vwcpu \ volume-cache-info vci volume-ident-led-on vilon \ volume-ident-led-off viloff local-disk-list ldl \ system-read-cache-pct-update srcpu \ local-disk-ident-led-on ldilon \ local-disk-ident-led-off ldiloff \ local-disk-fault-led-on ldflon \ local-disk-fault-led-off ldfloff" list_args="--type" list_type_args="volumes pools fs snapshots exports nfs_client_auth \ access_groups systems disks plugins target_ports \ batteries" opts_filter="--sys --pool --vol --disk --ag --fs --nfs" cap_args="--sys" volume_create_args="--name --size --pool" volume_delete_args="--vol --force" # Should force be here, to easy to tab through?" volume_resize_args="--vol --size --force" # Should force be here, to easy to tab through?" volume_replicate_args="--vol --name --rep-type" # Hmmm, this looks like a bug with CLI, should support lower and upper case? volume_rep_types="CLONE COPY MIRROR_ASYNC MIRROR_SYNC" volume_replicate_range_args="--src-vol --dst-vol --rep-type --src-start \ --dst-start --count --force" # Force ? volume_replication_range_bs="--sys" volume_dependants="--vol" volume_access_group_args="--vol" volume_masking_args="--vol --ag" access_group_create_args="--name --init --sys" access_group_delete_args="--ag" access_group_add_remove_args="--ag --init" volume_enable_disable_args="--vol" volume_raidinfo_args="--vol" iscsi_chap_args="--in-user --in-pass --out-user --out-pass" fs_create_args="--name --size --pool" fs_delete_args="--fs --force" # Force ? fs_resize_args="--fs --size --force" # Force ? fs_export_args="--fs --exportpath --anonuid --auth-type --root-host --ro-host --rw-host" fs_unexport_args="--export" fs_clone_args="--src-fs --dst-name" fs_snap_create_args="--name --fs" fs_snap_delete_args="--snap --fs" fs_snap_restore_args="--snap --fs --file --fileas --force" fs_dependants_args="--fs" file_clone_args="--fs --src --dst --backing-snapshot" pool_member_info_args="--pool" volume_raid_create_args="--name --disk --raid-type --strip-size" volume_raid_create_cap_args="--sys" volume_phy_disk_cache_update_args="--vol --policy" volume_read_cache_policy_update_args="--vol --policy" volume_write_cache_policy_update_args="--vol --policy" volume_cache_info_args="--vol" volume_ident_led_on_off_args="--vol" system_read_cache_pct_update_args="--vol --read-pct" local_disk_led_args="--path" # These operations can potentially be slow and cause hangs depending on plugin and configuration if [[ ${NO_VALUE_LOOKUP} -ne 0 ]] ; then # Check if we have somthing present that we can help the user with case "${prev}" in --sys) # Is there a better way todo this? local items=`lsmcli list --type systems -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --pool) # Is there a better way todo this? local items=`lsmcli list --type pools -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --vol|--src-vol|--dst-vol) # Is there a better way todo this? local items=`lsmcli list --type volumes -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --disk) # Is there a better way todo this? local items=`lsmcli list --type disks -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --ag) # Is there a better way todo this? local items=`lsmcli list --type access_groups -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --init) arg_index "--ag" i=$? # We have an access group present on the command line so filter the intiators to it if [[ ${i} -ne 255 ]]; then # It would be better if we filtered the result with the access group # if it's present on the command line already. local items=`lsmcli list --type access_groups -t${sep} --ag ${COMP_WORDS[${i}+1]} | awk -F ${sep} '{print $3}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 else local items=`lsmcli list --type access_groups -t${sep} | awk -F ${sep} '{print $3}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 fi ;; --nfs-export) # Is there a better way todo this? local items=`lsmcli list --type exports -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --tgt) # Is there a better way todo this? local items=`lsmcli list --type target_ports -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --fs|--src-fs) local items=`lsmcli list --type fs -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --export) local items=`lsmcli list --type exports -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; --snap) arg_index "--fs" i=$? # We have an access group present on the command line so filter the snapshots to it if [[ ${i} -ne 255 ]]; then local items=`lsmcli list --type snapshots \ --fs ${COMP_WORDS[${i}+1]} -t${sep} | awk -F ${sep} '{print $1}'` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 else COMPREPLY=( $(compgen -W "" -- ${cur}) ) return 0 fi ;; --auth-type) local items=`lsmcli list --type nfs_client_auth -t ' '` COMPREPLY=( $(compgen -W "${items}" -- ${cur}) ) return 0 ;; *) ;; esac fi # Cases where we don't have to worry about look-up time case "${prev}" in --type) COMPREPLY=( $(compgen -W "${list_type_args}" -- ${cur}) ) return 0 ;; --size|--count|--src-start|--dst-start|--name|--in-user|--in-pass|\ --out-user|--out-pass|--exportpath|--anonuid|--root-host|--ro-host|\ --rw-host|--dest-name|--file|--fileas|--src|--dst) # These we cannot lookup, so don't offer any values COMPREPLY=( $(compgen -W "" -- ${cur}) ) return 0 ;; --rep-type) COMPREPLY=( $(compgen -W "${volume_rep_types}" -- ${cur}) ) return 0 ;; snapshots) # Specific listing case where you need a fs too if [[ ${COMP_WORDS[COMP_CWORD-2]} == '--type' && \ ${COMP_WORDS[COMP_CWORD-3]} == 'list' ]] ; then COMPREPLY=( $(compgen -W "--fs" -- ${cur}) ) return 0 fi ;; *) esac case "${COMP_WORDS[1]}" in job-status) possible_args "--job" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; list) possible_args ${list_args} COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-create|vc) possible_args "${volume_create_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-delete|vd) possible_args "${volume_delete_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-raid-info|vri) possible_args "${volume_raidinfo_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-resize|vr) possible_args "${volume_resize_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-replicate) possible_args "${volume_replicate_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-replicate-range) possible_args "${volume_replicate_range_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-replicate-range-block-size) possible_args "${volume_replication_range_bs}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-dependants|volume-dependants-rm) possible_args "${volume_dependants}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-access-group) possible_args "${volume_access_group_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-mask|volume-unmask|vm|vu) possible_args "${volume_masking_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; access-group-create|ac) possible_args "${access_group_create_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; access-group-delete|ad) possible_args "${access_group_delete_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; access-group-add|access-group-remove|aa|ar) possible_args "${access_group_add_remove_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-enable|volume-disable|ve|vi) possible_args "${volume_enable_disable_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; iscsi-chap) possible_args "${iscsi_chap_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-create) possible_args "${fs_create_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-delete) possible_args "${fs_delete_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-resize) possible_args "${fs_resize_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-export) possible_args "${fs_export_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-unexport) possible_args "${fs_unexport_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-clone) possible_args "${fs_clone_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-snap-create) possible_args "${fs_snap_create_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-snap-delete) possible_args "${fs_snap_delete_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-snap-restore) possible_args "${fs_snap_restore_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; fs-dependants|fs-dependants-rm) possible_args "${fs_dependants_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; file-clone) possible_args "${file_clone_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; capabilities|c) possible_args "${cap_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; pool-member-info|pmi) possible_args "${pool_member_info_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-raid-create|vrc) possible_args "${volume_raid_create_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-raid-create-cap|vrcc) possible_args "${volume_raid_create_cap_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-phy-disk-cache-update|vpdcu) possible_args "${volume_phy_disk_cache_update_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-read-cache-policy-update|vrcpu) possible_args "${volume_read_cache_policy_update_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-write-cache-policy-update|vwcpu) possible_args "${volume_write_cache_policy_update_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-cache-info|vci) possible_args "${volume_cache_info_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; volume-ident-led-on|volume-ident-led-off|vilon|viloff) possible_args "${volume_ident_led_on_off_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; system-read-cache-pct-update|srcpu) possible_args "${system_read_cache_pct_update_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; local-disk-ident-led-on|ldilon| \ local-disk-ident-led-off|ldiloff| \ local-disk-fault-led-on|ldflon| \ local-disk-fault-led-off|ldfloff) possible_args "${local_disk_led_args}" COMPREPLY=( $(compgen -W "${potential_args}" -- ${cur}) ) return 0 ;; *) ;; esac # Handle the case where we are starting out with nothing if [[ ${prev} == 'lsmcli' ]] ; then if [[ ${cur} == --* ]] ; then COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) ) return 0 fi if [[ ${cur} == -* ]] ; then COMPREPLY=( $(compgen -W "${opts_short}${opts_long}" -- ${cur}) ) return 0 fi if [[ ${cur} == * ]] ; then COMPREPLY=( $(compgen -W "${opts_short}${opts_long}${opts_cmds}" -- ${cur}) ) return 0 fi fi } complete -F _lsm lsmcli completions/wget 0000644 00000014411 14720751124 0007775 0 ustar 00 # wget(1) completion -*- shell-script -*- _wget() { local cur prev words cword split _init_completion -s || return case $prev in --progress) COMPREPLY=( $( compgen -W 'bar dot' -- "$cur" ) ) return ;; --bind-address) _ip_addresses "$cur" return ;; -D|--domains|--exclude-domains) _known_hosts_real "$cur" return ;; --restrict-file-names) local excludes=() case $cur in *unix*|*windows*) excludes=( windows unix ) ;;& *lowercase*|*uppercase*) excludes+=( lowercase uppercase ) ;;& *nocontrol*) excludes+=( nocontrol ) ;;& *ascii*) excludes+=( ascii ) ;; esac local excludes_str=$( export IFS='|'; echo "${excludes[*]}"; ) # prevopt is the previous options string used as a prefix # to avoid COMPREPLY replacing them with the $lastopt completion local lastopt=${cur/*,} prevopt= [[ $cur == *,* ]] && prevopt=${cur%,*}, COMPREPLY=( $( compgen -P "$prevopt" -X "@($excludes_str)" \ -W 'unix windows nocontrol ascii lowercase uppercase' \ -- "$lastopt" ) ) # +o nospace when no more valid option is possible (= append a space) local opt_as_arr=( $( echo ${COMPREPLY[0]//,/ } ) ) [[ ${#opt_as_arr[@]} -lt 4 ]] && compopt -o nospace return ;; --prefer-family) COMPREPLY=( $( compgen -W 'IPv4 IPv6 none' -- "$cur" ) ) return ;; -P|--directory-prefix|--ca-directory|--warc-tempdir) _filedir -d return ;; -o|--output-file|-a|--append-output|--config|--load-cookies|\ --save-cookies|--post-file|--certificate|--ca-certificate|\ --private-key|--random-file|--egd-file|--warc-file|--warc-dedup) _filedir return ;; -O|--output-document|-i|--input-file) _filedir && [[ $cur == - || -z $cur ]] && COMPREPLY+=( - ) return ;; --secure-protocol) COMPREPLY=( $( compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur" ) ) return ;; --certificate-type|--private-key-type) COMPREPLY=( $( compgen -W 'PEM DER' -- "$cur" ) ) return ;; --follow-tags|--ignore-tags) local lastopt=${cur/*,} prevopt= [[ $cur == *,* ]] && prevopt=${cur%,*}, COMPREPLY=( $( compgen -P "$prevopt" -W 'a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dir div dfn dl dt em fieldset font form frame frameset h6 head hr html i iframe img input ins isindex kbd label legend li link map menu meta noframes noscript object ol optgroup option p param pre q s samp script select small span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var xmp' \ -- "$lastopt" ) ) return ;; -t|--tries|-T|--timeout|--dns-timeout|--connect-timeout|--read-timeout|\ -w|--wait|--waitretry|--cut-dirs|--max-redirect|-l|--level) # expect integer number COMPREPLY+=( $( compgen -P "$cur" -W "{0..9}" ) ) compopt -o nospace return ;; -Q|--quota|--limit-rate|--warc-max-size) # expect size if [[ $cur == *@(k|m) ]]; then COMPREPLY=( $( compgen -W "$cur" ) ) elif [[ $cur ]]; then COMPREPLY=( $( compgen -P "$cur" -W "{0..9} k m" ) ) compopt -o nospace else COMPREPLY=( $( compgen -W "{0..9}" ) ) compopt -o nospace fi return ;; --user|--http-user|--proxy-user|--ftp-user) COMPREPLY=( $( compgen -W "$( sed -n \ '/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc \ 2>/dev/null )" -- "$cur" ) ) return ;; --header) COMPREPLY=( $( compgen -W 'Accept Accept-Charset Accept-Encoding Accept-Language Accept-Ranges Age Allow Authorization Cache-Control Connection Content-Encoding Content-Language Content-Length Content-Location Content-MD5 Content-Range Content-Type Date ETag Expect Expires From Host If-Match If-Modified-Since If-None-Match If-Range If-Unmodified-Since Last-Modified Location Max-Forwards Pragma Proxy-Authenticate Proxy-Authorization Range Referer Retry-After Server TE Trailer Transfer-Encoding Upgrade User-Agent Vary Via Warning WWW-Authenticate' -- "$cur" ) ) compopt -o nospace return ;; --local-encoding|--remote-encoding) type -P xauth &>/dev/null && \ COMPREPLY=( $( compgen -W '$( iconv -l 2>/dev/null | \ sed -e "s@/*\$@@" -e "s/[,()]//g" 2>/dev/null )' -- "$cur" ) ) return ;; -e|--execute) return # TODO base=STR ;; -nv|--report-speed) COMPREPLY=( $( compgen -W 'bits' -- "$cur" ) ) return ;; -B|--base|--password|--ftp-password|--http-password|--proxy-password|\ --default-page|--referer|-U|--user-agent|--post-data|--warc-header|-A|\ --accept|-R|--reject|-I|--include-directories|-X|--exclude-directories) # argument required but no completions available return ;; esac $split && return if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi } && complete -F _wget wget # ex: ts=4 sw=4 et filetype=sh completions/systemd-detect-virt 0000644 00000002445 14720751124 0012753 0 ustar 00 # systemd-detect-virt(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word() { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } _systemd_detect_virt() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps local -A OPTS=( [STANDALONE]='-h --help --version -c --container -v --vm -q --quiet' ) _init_completion || return COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) } complete -F _systemd_detect_virt systemd-detect-virt completions/groupadd 0000644 00000001205 14720751124 0010631 0 ustar 00 # groupadd(8) completion -*- shell-script -*- _groupadd() { local cur prev words cword split _init_completion -s || return # TODO: if -o/--non-unique is given, could complete on existing gids # with -g/--gid case $prev in -g|--gid|-K|--key|-p|--password) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return 0 fi } && complete -F _groupadd groupadd # ex: ts=4 sw=4 et filetype=sh completions/mkfs.minix 0000644 00000001314 14720751124 0011110 0 ustar 00 _mkfs.minix_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-i') COMPREPLY=( $(compgen -W "inodes" -- $cur) ) return 0 ;; '-l') COMPREPLY=( $(compgen -W "badblocks-file" -- $cur) ) return 0 ;; '-n') COMPREPLY=( $(compgen -W "14 30" -- $cur) ) return 0 ;; '-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="-c -i -l -n -1 -2 -3" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEVS while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) COMPREPLY=( $(compgen -W "$DEVS" -- $cur) ) return 0 } complete -F _mkfs.minix_module mkfs.minix completions/fstrim 0000644 00000001162 14720751124 0010332 0 ustar 00 _fstrim_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-o'|'--offset'|'-l'|'--length'|'-m'|'--minimum') COMPREPLY=( $(compgen -W "num" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--offset --length --minimum --verbose --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local MPOINTS MPOINTS=$(findmnt -rno SOURCE | grep ^/dev) COMPREPLY=( $(compgen -W "$MPOINTS" -- $cur) ) return 0 } complete -F _fstrim_module fstrim completions/chrt 0000644 00000001440 14720751124 0007765 0 ustar 00 _chrt_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac # FIXME: -p is ambiguous, it takes either pid or priority as an # argument depending on whether user wanted to get or set the # values. Perhaps the command interface should be reconsidered. case $cur in -*) OPTS="--batch --fifo --idle --other --rr --reset-on-fork --all-tasks --help --max --pid --verbose --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local PIDS PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 } complete -F _chrt_module chrt completions/umount.linux 0000644 00000010601 14720751124 0011511 0 ustar 00 # umount(8) completion -*- shell-script -*- # Just like COMPREPLY=(`compgen -W "${COMPREPLY[*]}" -- "$cur"`), only better! # # This will correctly escape special characters in COMPREPLY. _reply_compgen_array() { # Create the argument for compgen -W by escaping twice. # # One round of escape is because we want to reply with escaped arguments. A # second round is required because compgen -W will helpfully expand it's # argument. local i wlist for i in ${!COMPREPLY[*]}; do local q=$(quote "$(printf %q "${COMPREPLY[$i]}")") wlist+=$q$'\n' done # We also have to add another round of escaping to $cur. local ecur="$cur" ecur="${ecur//\\/\\\\}" ecur="${ecur//\'/\'}" # Actually generate completions. local oldifs=$IFS IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)' IFS=$oldifs } # Unescape strings in the linux fstab(5) format (with octal escapes). __linux_fstab_unescape() { eval $1="'${!1//\'/\047}'" eval $1="'${!1/%\\/\\\\}'" eval "$1=$'${!1}'" } # Complete linux fstab entries. # # Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab # and /proc/mounts. _linux_fstab() { COMPREPLY=() # Read and unescape values into COMPREPLY local fs_spec fs_file fs_other local oldifs="$IFS" while read -r fs_spec fs_file fs_other; do if [[ $fs_spec = [#]* ]]; then continue; fi if [[ $1 == -L ]]; then local fs_label=${fs_spec/#LABEL=} if [[ $fs_label != "$fs_spec" ]]; then __linux_fstab_unescape fs_label IFS=$'\0' COMPREPLY+=("$fs_label") IFS=$oldifs fi else __linux_fstab_unescape fs_spec __linux_fstab_unescape fs_file IFS=$'\0' [[ $fs_spec = */* ]] && COMPREPLY+=("$fs_spec") [[ $fs_file = */* ]] && COMPREPLY+=("$fs_file") IFS=$oldifs fi done # Add relative paths to COMPREPLY if [[ $cur && $cur != /* ]]; then local realcur [[ $cur == */ ]] && # don't let readlink drop last / from path realcur="$( readlink -f "$cur." 2> /dev/null )/" || realcur=$( readlink -f "$cur" 2> /dev/null ) if [[ $realcur ]]; then local dirrealcur= dircur= basecur if [[ $cur == */* ]]; then dirrealcur="${realcur%/*}/" dircur="${cur%/*}/" fi basecur=${cur#"$dircur"} local i n=${#COMPREPLY[@]} for (( i=0; i < $n; i++ )); do [[ "${COMPREPLY[i]}" == "$realcur"* ]] && COMPREPLY+=( $( cd "$dircur" 2> /dev/null && compgen -f -d -P "$dircur" \ -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur" ) ) done fi fi _reply_compgen_array } _umount() { local cur prev words cword _init_completion || return case "$prev" in -t) # FIXME: no<fstype> local split=false if [[ "$cur" == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi COMPREPLY=( $( compgen -W 'adfs affs autofs btrfs cifs coda cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs iso9660 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs umsdos usbfs vfat xfs' -- "$cur" ) ) _fstypes $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) return ;; -O) # argument required but no completions available return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l --no-canonicalize --fake' -- "$cur" ) ) [[ $COMPREPLY ]] && return fi if [[ -r /proc/mounts ]]; then # Linux /proc/mounts is properly quoted. This is important when # unmounting usb devices with pretty names. _linux_fstab < /proc/mounts else local IFS=$'\n' COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) ) fi } && complete -F _umount -o dirnames umount # ex: ts=4 sw=4 et filetype=sh completions/cfdisk 0000644 00000001340 14720751124 0010267 0 ustar 00 _cfdisk_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-c') COMPREPLY=( $(compgen -W "cylinders" -- $cur) ) return 0 ;; '-h') COMPREPLY=( $(compgen -W "heads" -- $cur) ) return 0 ;; '-s') COMPREPLY=( $(compgen -W "sectors" -- $cur) ) return 0 ;; '-v') return 0 ;; esac case $cur in -*) OPTS="-a -z -c -h -s" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'disk' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) return 0 } complete -F _cfdisk_module cfdisk completions/gapplication 0000644 00000002555 14720751124 0011507 0 ustar 00 # Check for bash [ -z "$BASH_VERSION" ] && return #################################################################################################### __app() { case "${COMP_CWORD}" in 1) COMPREPLY=($(compgen -W "help version list-apps launch action list-actions" -- "${COMP_WORDS[1]}")) return 0 ;; 2) case "${COMP_WORDS[1]}" in launch|action|list-actions) COMPREPLY=($(compgen -W "`gapplication list-apps`" -- "${COMP_WORDS[2]}")) return 0 ;; *) COMPREPLY=() return 0 ;; esac ;; esac # Otherwise, what we will do is based on the command in ${COMP_WORDS[1]} case "${COMP_WORDS[1]}" in action) # Word 3 is the action name. This is the only one we can help with. if [ "${COMP_CWORD}" == 3 ]; then COMPREPLY=($(compgen -W "`gapplication list-actions "${COMP_WORDS[2]}"`" -- "${COMP_WORDS[3]}")) return 0 else COMPREPLY=() return 0 fi ;; launch) # Filenames... COMPREPLY=($(compgen -A file "${COMP_WORDS[COMP_CWORD]}")) return 0 ;; *) # Nothing else should be out this far... COMPREPLY=() return 0 esac } #################################################################################################### complete -F __app gapplication completions/ionice 0000644 00000001505 14720751124 0010275 0 ustar 00 _ionice_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-c'|'--class') COMPREPLY=( $(compgen -W "{0..3} none realtime best-effort idle" -- $cur) ) return 0 ;; '-n'|'--classdata') COMPREPLY=( $(compgen -W "{0..7}" -- $cur) ) return 0 ;; '-p'|'--pid') local PIDS PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--class --classdata --pid --ignore --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _ionice_module ionice completions/partx 0000644 00000002114 14720751124 0010162 0 ustar 00 _partx_module() { local cur prev OPTS OUTPUT COMPREPLY=() OUTPUT="NR START END SECTORS SIZE NAME UUID TYPE FLAGS SCHEME" cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-n'|'--nr') return 0 ;; '-o'|'--output') # FIXME: how to append to a string with compgen? compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-t'|'--type') # FIXME: some command should list type libblkid knows. COMPREPLY=( $(compgen -W "aix bsd dos gpt mac minix sgi solaris_x86 sun ultrix unixware" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--add --delete --show --update --bytes --noheadings --nr --output --pairs --raw --type --verbose --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'disk' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) return 0 } complete -F _partx_module partx completions/setterm 0000644 00000004371 14720751124 0010516 0 ustar 00 _setterm_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-term') local TERM_LIST I TERM_LIST='' for I in /usr/share/terminfo/?/*; do TERM_LIST+="${I##*/} " done COMPREPLY=( $(compgen -W "$TERM_LIST" -- $cur) ) return 0 ;; '-foreground'|'-background'|'-ulcolor'|'-hbcolor') COMPREPLY=( $(compgen -W "default black blue cyan green magenta red white yellow" -- $cur) ) return 0 ;; '-cursor'|'-repeat'|'-appcursorkeys'|'-linewrap'|'-inversescreen'|'-bold'|'-half-bright'|'-blink'|'-reverse'|'-underline'|'-msg') COMPREPLY=( $(compgen -W "off on" -- $cur) ) return 0 ;; '-clear') COMPREPLY=( $(compgen -W "all rest" -- $cur) ) return 0 ;; '-tabs'|'-clrtabs') COMPREPLY=( $(compgen -W "tab1 tab2 tab3 tab160" -- $cur) ) return 0 ;; '-regtabs') COMPREPLY=( $(compgen -W "{1..160}" -- $cur) ) return 0 ;; '-blank') COMPREPLY=( $(compgen -W "{0..60} force poke" -- $cur) ) return 0 ;; '-dump'|'-append') local NUM_CONS NUM_CONS=(/sys/class/tty/*) COMPREPLY=( $(compgen -W "{1..${#NUM_CONS[*]}}" -- $cur) ) return 0 ;; '-file') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-msglevel') COMPREPLY=( $(compgen -W "{1..8}" -- $cur) ) return 0 ;; '-powersave') COMPREPLY=( $(compgen -W "on vsync hsync powerdown off" -- $cur) ) return 0 ;; '-powerdown') COMPREPLY=( $(compgen -W "{0..60}" -- $cur) ) return 0 ;; '-blength') COMPREPLY=( $(compgen -W "0-2000" -- $cur) ) return 0 ;; '-bfreq') COMPREPLY=( $(compgen -W "freqnumber" -- $cur) ) return 0 ;; '-help'|'-version') return 0 ;; esac OPTS=" -term -reset -initialize -cursor -repeat -appcursorkeys -linewrap -default -foreground -background -ulcolor -hbcolor -ulcolor -hbcolor -inversescreen -bold -half-bright -blink -reverse -underline -store -clear -tabs -clrtabs -regtabs -blank -dump -append -file -msg -msglevel -powersave -powerdown -blength -bfreq -version -help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _setterm_module setterm completions/look 0000644 00000001074 14720751124 0007774 0 ustar 00 _look_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-t'|'--terminate') COMPREPLY=( $(compgen -W "char" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--alternative --alphanum --ignore-case --terminate --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _look_module look completions/scriptreplay 0000644 00000001120 14720751124 0011541 0 ustar 00 _scriptreplay_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-d'|'--divisor') COMPREPLY=( $(compgen -W "digit" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--timing --typescript --divisor --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _scriptreplay_module scriptreplay completions/bzip2 0000644 00000002212 14720751124 0010051 0 ustar 00 # bash completion for bzip2 -*- shell-script -*- _bzip2() { local cur prev words cword _init_completion || return case $prev in -b|-h|--help|-p) return 0 ;; -n) COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then local helpopts=$( _parse_help "$1" ) COMPREPLY=( $( compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ -- "$cur" ) ) return 0 fi local IFS=$'\n' xspec="*.bz2" if [[ "$prev" == --* ]]; then [[ "$prev" == --decompress || \ "$prev" == --list || \ "$prev" == --test ]] && xspec="!"$xspec [[ "$prev" == --compress ]] && xspec= elif [[ "$prev" == -* ]]; then [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec [[ "$prev" == -*z* ]] && xspec= fi _expand || return 0 compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ $( compgen -d -- "$cur" ) ) } && complete -F _bzip2 bzip2 pbzip2 lbzip2 # ex: ts=4 sw=4 et filetype=sh completions/gdbus 0000644 00000001647 14720751124 0010142 0 ustar 00 # Check for bash [ -z "$BASH_VERSION" ] && return #################################################################################################### __gdbus() { local IFS=$'\n' local cur=`_get_cword :` local suggestions=$(gdbus complete "${COMP_LINE}" ${COMP_POINT}) COMPREPLY=($(compgen -W "$suggestions" -- "$cur")) # Remove colon-word prefix from COMPREPLY items case "$cur" in *:*) case "$COMP_WORDBREAKS" in *:*) local colon_word=${cur%${cur##*:}} local i=${#COMPREPLY[*]} while [ $((--i)) -ge 0 ]; do COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} done ;; esac ;; esac } #################################################################################################### complete -o nospace -F __gdbus gdbus completions/systemd-delta 0000644 00000003640 14720751124 0011610 0 ustar 00 # systemd-delta(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word() { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } _systemd-delta() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local comps local -A OPTS=( [STANDALONE]='--help -h --no-pager --version' [ARG]='--diff --type -t' ) _init_completion || return if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --diff) comps='yes no' ;; --type|-t) comps='masked equivalent redirected overridden unchanged extended default' ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ "$cur" = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _systemd-delta systemd-delta completions/gzip 0000644 00000002262 14720751124 0010001 0 ustar 00 # bash completion for gzip -*- shell-script -*- _gzip() { local cur prev words cword _init_completion || return case $prev in -b|--blocksize|-S|--suffix|-h|--help|-V|--version) return 0 ;; -p|--processes) COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) {-1..-9}' \ -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return 0 fi local IFS=$'\n' xspec="*.@(gz|t[ag]z)" if [[ "$prev" == --* ]]; then [[ "$prev" == --decompress || \ "$prev" == --list || \ "$prev" == --test ]] && xspec="!"$xspec [[ "$prev" == --force ]] && xspec= elif [[ "$prev" == -* ]]; then [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec [[ "$prev" == -*f* ]] && xspec= fi _expand || return 0 compopt -o filenames COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \ $( compgen -d -- "$cur" ) ) } && complete -F _gzip gzip pigz # ex: ts=4 sw=4 et filetype=sh completions/logger 0000644 00000002207 14720751124 0010306 0 ustar 00 _logger_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-f'|'--file') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-n'|'--server') COMPREPLY=( $(compgen -A hostname -- $cur) ) return 0 ;; '-P'|'--port') COMPREPLY=( $(compgen -W "$(awk '$1 ~ /^syslog$/ {split($2, a, "/"); print a[1]}' /etc/services)" -- $cur) ) return 0 ;; '-p'|'--priority') COMPREPLY=( $(compgen -W "{auth,authpriv,cron,daemon,ftp,lpr,mail,news,security}.{alert,crit,debug,emerg,err,error}" -- $cur) ) return 0 ;; '-t'|'--tag') COMPREPLY=( $(compgen -W "tag" -- $cur) ) return 0 ;; '-u'|'--socket') COMPREPLY=( $(compgen -W "$(awk '$NF ~ /^\// {print $NF}' /proc/net/unix)" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--udp --id --file --help --server --port --priority --stderr --tag --socket --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac return 0 } complete -F _logger_module logger completions/wdctl 0000644 00000002262 14720751124 0010145 0 ustar 00 _wdctl_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-f'|'--flags') local FLAGS FLAGS="ALARMONLY CARDRESET EXTERN1 EXTERN2 FANFAULT KEEPALIVEPING MAGICCLOSE OVERHEAT POWEROVER POWERUNDER PRETIMEOUT SETTIMEOUT" COMPREPLY=( $(compgen -W "$FLAGS" -- $cur) ) return 0 ;; '-o'|'--output') # FIXME: how to append to a string with compgen? local OUTPUT OUTPUT="FLAG DESCRIPTION STATUS BOOT-STATUS DEVICE" compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-s'|'--settimeout') COMPREPLY=( $(compgen -W "seconds" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--flags --noflags --noident --noheadings --oneline --output --raw --notimeouts --settimeout --flags-only --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- ${cur:-"/dev/"}) ) return 0 } complete -F _wdctl_module wdctl completions/fsfreeze 0000644 00000001014 14720751124 0010633 0 ustar 00 _fsfreeze_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--freeze --unfreeze --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local MPOINT MPOINT="$(findmnt -t ext2,ext3,ext4,reiserfs,jfs,xfs -o TARGET -n -r)" COMPREPLY=( $(compgen -W "$MPOINT" -- $cur) ) return 0 } complete -F _fsfreeze_module fsfreeze completions/dmesg 0000644 00000002040 14720751124 0010121 0 ustar 00 _dmesg_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-F'|'--file') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-f'|'--facility') COMPREPLY=( $(compgen -W "kern user mail daemon auth syslog lpr news" -- $cur) ) return 0 ;; '-l'|'--level'|'-n'|'--console-level') COMPREPLY=( $(compgen -W "emerg alert crit err warn notice info debug" -- $cur) ) return 0 ;; '-s'|'--buffer-size') COMPREPLY=( $(compgen -W "size" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS="--clear --read-clear --console-off --show-delta --reltime --console-on --file --facility --human --kernel --color --level --console-level --nopager --raw --syslog --buffer-size --ctime --notime --userspace --follow --decode --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _dmesg_module dmesg completions/systemd-cat 0000644 00000003570 14720751124 0011270 0 ustar 00 # systemd-cat(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word() { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } _systemd_cat() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps local -A OPTS=( [STANDALONE]='-h --help --version' [ARG]='-t --identifier -p --priority --level-prefix' ) _init_completion || return if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --identifier|-t) comps='' ;; --priority|-p) comps='emerg alert crit err warning notice info debug' ;; --level-prefix) comps='yes no' ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) } complete -F _systemd_cat systemd-cat completions/hexdump 0000644 00000001223 14720751124 0010476 0 ustar 00 _hexdump_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-e') COMPREPLY=( $(compgen -W "format" -- $cur) ) return 0 ;; '-n') COMPREPLY=( $(compgen -W "length" -- $cur) ) return 0 ;; '-s') COMPREPLY=( $(compgen -W "offset" -- $cur) ) return 0 ;; '-V') return 0 ;; esac case $cur in -*) OPTS="-b -c -C -d -o -x -e -f -n -s -v -V" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _hexdump_module hexdump completions/ping 0000644 00000003467 14720751124 0007775 0 ustar 00 # ping(8) completion -*- shell-script -*- _ping() { local cur prev words cword _init_completion -n = || return case $prev in -c|-F|-G|-g|-h|-i|-l|-m|-P|-p|-s|-t|-V|-W|-w|-z) return ;; -I) _available_interfaces -a return ;; -M) # Path MTU strategy in Linux, mask|time in FreeBSD local opts="do want dont" [[ $OSTYPE == *bsd* ]] && opts="mask time" COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) return ;; -N) if [[ $cur != *= ]]; then COMPREPLY=( $( compgen -W 'name ipv6 ipv6-global ipv6-sitelocal ipv6-linklocal ipv6-all ipv4 ipv4-all subject-ipv6= subject-ipv4= subject-name= subject-fqdn=' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace fi return ;; -Q) # TOS in Linux, "somewhat quiet" (no args) in FreeBSD if [[ $OSTYPE != *bsd* ]]; then COMPREPLY=( $( compgen -W '{0..7}' -- "$cur" ) ) return fi ;; -S) # Socket sndbuf in Linux, source IP in FreeBSD [[ $OSTYPE == *bsd* ]] && _ip_addresses return ;; -T) # Timestamp option in Linux, TTL in FreeBSD [[ $OSTYPE == *bsd* ]] || \ COMPREPLY=( $( compgen -W 'tsonly tsandaddr' -- "$cur" ) ) return ;; esac if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) return fi _known_hosts_real "$cur" } && complete -F _ping ping ping6 # ex: ts=4 sw=4 et filetype=sh completions/setpriv 0000644 00000003737 14720751124 0010534 0 ustar 00 _setpriv_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '--inh-caps'|'--bounding-set') # FIXME: how to append to a string with compgen? local INHERIT INHERIT=$(setpriv --list-caps| awk '{print $1, "-" $1}') compopt -o nospace COMPREPLY=( $(compgen -W "all $INHERIT" -S ',' -- $cur) ) return 0 ;; '--ruid'|'--euid'|'--reuid') local UIDS UIDS=$(getent passwd | awk -F: '{print $3}') COMPREPLY=( $(compgen -W "$UIDS" -- $cur) ) return 0 ;; '--rgid'|'--egid'|'--regid') local GIDS GIDS=$(getent group | awk -F: '{print $3}') COMPREPLY=( $(compgen -W "$GIDS" -- $cur) ) return 0 ;; '--groups') # FIXME: how to append to a string with compgen? local GIDS GIDS=$(getent group | awk -F: '{print $3}') compopt -o nospace COMPREPLY=( $(compgen -W "$GIDS" -S ',' -- $cur) ) return 0 ;; '--securebits') local SBITS SBITS="noroot noroot_locked no_setuid_fixup no_setuid_fixup_locked keep_caps_locked -noroot -noroot_locked -no_setuid_fixup -no_setuid_fixup_locked -keep_caps_locked" COMPREPLY=( $(compgen -W "$SBITS" -- $cur) ) return 0 ;; '--selinux-label') # FIXME: how to list selinux labels? COMPREPLY=( $(compgen -W "label" -- $cur) ) return 0 ;; '--apparmor-profile') # FIXME: how to list apparmor profiles? COMPREPLY=( $(compgen -W "profile" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--dump --no-new-privs --inh-caps --bounding-set --ruid --euid --rgid --egid --reuid --regid --clear-groupsclear --keep-groupskeep --groups --securebits --selinux-label --apparmor-profile --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 } complete -F _setpriv_module setpriv completions/ssh 0000644 00000026766 14720751124 0007644 0 ustar 00 # ssh(1) completion -*- shell-script -*- _ssh_ciphers() { COMPREPLY+=( $( compgen -W '3des-cbc aes128-cbc aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour blowfish-cbc cast128-cbc' -- "$cur" ) ) } _ssh_macs() { COMPREPLY+=( $( compgen -W 'hmac-md5 hmac-sha1 umac-64@openssh.com hmac-ripemd160 hmac-sha1-96 hmac-md5-96' -- "$cur" ) ) } _ssh_options() { compopt -o nospace COMPREPLY=( $( compgen -S = -W 'AddressFamily BatchMode BindAddress ChallengeResponseAuthentication CheckHostIP Cipher Ciphers ClearAllForwardings Compression CompressionLevel ConnectionAttempts ConnectTimeout ControlMaster ControlPath ControlPersist DynamicForward EnableSSHKeysign EscapeChar ExitOnForwardFailure ForwardAgent ForwardX11 ForwardX11Timeout ForwardX11Trusted GatewayPorts GlobalKnownHostsFile GSSAPIAuthentication GSSAPIClientIdentity GSSAPIDelegateCredentials GSSAPIKeyExchange GSSAPIRenewalForcesRekey GSSAPIServerIdentity GSSAPITrustDns HashKnownHosts Host HostbasedAuthentication HostKeyAlgorithms HostKeyAlias HostName IdentityFile IdentitiesOnly IPQoS KbdInteractiveDevices KexAlgorithms LocalCommand LocalForward LogLevel MACs NoHostAuthenticationForLocalhost NumberOfPasswordPrompts PasswordAuthentication PermitLocalCommand PKCS11Provider Port PreferredAuthentications Protocol ProxyCommand PubkeyAuthentication RekeyLimit RemoteForward RequestTTY RhostsRSAAuthentication RSAAuthentication SendEnv ServerAliveCountMax ServerAliveInterval SmartcardDevice StrictHostKeyChecking TCPKeepAlive Tunnel TunnelDevice UsePrivilegedPort User UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation' -- "$cur" ) ) } # Complete a ssh suboption (like ForwardAgent=y<tab>) # Only one parameter: the string to complete including the equal sign. # Not all suboptions are completed. # Doesn't handle comma-separated lists. _ssh_suboption() { # Split into subopt and subval local prev=${1%%=*} cur=${1#*=} case $prev in BatchMode|ChallengeResponseAuthentication|CheckHostIP|\ ClearAllForwardings|ControlPersist|Compression|EnableSSHKeysign|\ ExitOnForwardFailure|ForwardAgent|ForwardX11|ForwardX11Trusted|\ GatewayPorts|GSSAPIAuthentication|GSSAPIKeyExchange|\ GSSAPIDelegateCredentials|GSSAPIRenewalForcesRekey|GSSAPITrustDns|\ HashKnownHosts|HostbasedAuthentication|IdentitiesOnly|\ KbdInteractiveAuthentication|KbdInteractiveDevices|\ NoHostAuthenticationForLocalhost|PasswordAuthentication|\ PubkeyAuthentication|RhostsRSAAuthentication|RSAAuthentication|\ StrictHostKeyChecking|TCPKeepAlive|UsePrivilegedPort|\ VerifyHostKeyDNS|VisualHostKey) COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) ) ;; AddressFamily) COMPREPLY=( $( compgen -W 'any inet inet6' -- "$cur" ) ) ;; BindAddress) _ip_addresses ;; Cipher) COMPREPLY=( $( compgen -W 'blowfish des 3des' -- "$cur" ) ) ;; IPQoS) COMPREPLY=( $( compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3} cs{0..7} ef lowdelay throughput reliability' -- "$cur" ) ) ;; Protocol) COMPREPLY=( $( compgen -W '1 2 1,2 2,1' -- "$cur" ) ) ;; RequestTTY) COMPREPLY=( $( compgen -W 'no yes force auto' -- "$cur" ) ) ;; Tunnel) COMPREPLY=( $( compgen -W 'yes no point-to-point ethernet' \ -- "$cur" ) ) ;; PreferredAuthentications) COMPREPLY=( $( compgen -W 'gssapi-with-mic host-based publickey keyboard-interactive password' -- "$cur" ) ) ;; MACs) _ssh_macs ;; Ciphers) _ssh_ciphers ;; esac return 0 } # Try to complete -o SubOptions= # # Returns 0 if the completion was handled or non-zero otherwise. _ssh_suboption_check() { # Get prev and cur words without splitting on = local cureq=`_get_cword :=` preveq=`_get_pword :=` if [[ $cureq == *=* && $preveq == -o ]]; then _ssh_suboption $cureq return $? fi return 1 } _ssh() { local cur prev words cword _init_completion -n : || return local configfile local -a config _ssh_suboption_check && return 0 case $prev in -F|-i|-S) _filedir return 0 ;; -c) _ssh_ciphers return 0 ;; -m) _ssh_macs return 0 ;; -l) COMPREPLY=( $( compgen -u -- "$cur" ) ) return 0 ;; -O) COMPREPLY=( $( compgen -W 'check forward exit stop' -- "$cur" ) ) return 0 ;; -o) _ssh_options return 0 ;; -w) _available_interfaces return 0 ;; -b) _ip_addresses return 0 ;; -D|-e|-I|-L|-p|-R|-W) return 0 ;; esac if [[ "$cur" == -F* ]]; then cur=${cur#-F} _filedir # Prefix completions with '-F' COMPREPLY=( "${COMPREPLY[@]/#/-F}" ) cur=-F$cur # Restore cur elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument set -- "${words[@]}" while [[ $# -gt 0 ]]; do if [[ $1 == -F* ]]; then if [[ ${#1} -gt 2 ]]; then configfile="$(dequote "${1:2}")" else shift [[ $1 ]] && configfile="$(dequote "$1")" fi break fi shift done _known_hosts_real -a -F "$configfile" "$cur" if [[ $cword -ne 1 ]]; then compopt -o filenames COMPREPLY+=( $( compgen -c -- "$cur" ) ) fi fi return 0 } && shopt -u hostcomplete && complete -F _ssh ssh slogin autossh # sftp(1) completion # _sftp() { local cur prev words cword _init_completion || return local configfile _ssh_suboption_check && return 0 case $prev in -b|-F|-i) _filedir return 0 ;; -o) _ssh_options return 0 ;; -c) _ssh_ciphers return 0 ;; -B|-D|-P|-R|-S|-s) return 0 ;; esac if [[ "$cur" == -F* ]]; then cur=${cur#-F} _filedir # Prefix completions with '-F' COMPREPLY=( "${COMPREPLY[@]/#/-F}" ) cur=-F$cur # Restore cur elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) else # Search COMP_WORDS for '-F configfile' argument set -- "${words[@]}" while [[ $# -gt 0 ]]; do if [[ $1 == -F* ]]; then if [[ ${#1} -gt 2 ]]; then configfile="$(dequote "${1:2}")" else shift [[ $1 ]] && configfile="$(dequote "$1")" fi break fi shift done _known_hosts_real -a -F "$configfile" "$cur" fi return 0 } && shopt -u hostcomplete && complete -F _sftp sftp # things we want to backslash escape in scp paths _scp_path_esc='[][(){}<>",:;^&!$=?`|\\'"'"'[:space:]]' # Complete remote files with ssh. If the first arg is -d, complete on dirs # only. Returns paths escaped with three backslashes. _scp_remote_files() { local IFS=$'\n' # remove backslash escape from the first colon cur=${cur/\\:/:} local userhost=${cur%%?(\\):*} local path=${cur#*:} # unescape (3 backslashes to 1 for chars we escaped) path=$( sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path" ) # default to home dir of specified user on remote host if [[ -z $path ]]; then path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null) fi local files if [[ $1 == -d ]]; then # escape problematic characters; remove non-dirs files=$( ssh -o 'Batchmode yes' $userhost \ command ls -aF1dL "$path*" 2>/dev/null | \ sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d' ) else # escape problematic characters; remove executables, aliases, pipes # and sockets; add space at end of file names files=$( ssh -o 'Batchmode yes' $userhost \ command ls -aF1dL "$path*" 2>/dev/null | \ sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \ -e 's/[^\/]$/& /g' ) fi COMPREPLY+=( $files ) } # This approach is used instead of _filedir to get a space appended # after local file/dir completions, and -o nospace retained for others. # If first arg is -d, complete on directory names only. The next arg is # an optional prefix to add to returned completions. _scp_local_files() { local IFS=$'\n' local dirsonly=false if [[ $1 == -d ]]; then dirsonly=true shift fi if $dirsonly ; then COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \ sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") ) else COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \ sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \ -e 's/[^\/]$/& /g' -e "s/^/$1/") ) fi } # scp(1) completion # _scp() { local cur prev words cword _init_completion -n : || return local configfile prefix _ssh_suboption_check && { COMPREPLY=( "${COMPREPLY[@]/%/ }" ) return 0 } case $prev in -l|-P) return 0 ;; -F|-i|-S) _filedir compopt +o nospace return 0 ;; -c) _ssh_ciphers COMPREPLY=( "${COMPREPLY[@]/%/ }" ) return 0 ;; -o) _ssh_options return 0 ;; esac _expand || return 0 case $cur in !(*:*)/*|[.~]*) ;; # looks like a path *:*) _scp_remote_files ; return 0 ;; esac if [[ "$cur" == -F* ]]; then cur=${cur#-F} prefix=-F else # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument set -- "${words[@]}" while [[ $# -gt 0 ]]; do if [[ $1 == -F* ]]; then if [[ ${#1} -gt 2 ]]; then configfile="$(dequote "${1:2}")" else shift [[ $1 ]] && configfile="$(dequote "$1")" fi break fi shift done case $cur in -*) COMPREPLY=( $( compgen -W '$( _parse_usage "${words[0]}" )' \ -- "$cur" ) ) COMPREPLY=( "${COMPREPLY[@]/%/ }" ) return 0 ;; */*|[.~]*) # not a known host, pass through ;; *) _known_hosts_real -c -a -F "$configfile" "$cur" ;; esac fi _scp_local_files "$prefix" return 0 } && complete -F _scp -o nospace scp # ex: ts=4 sw=4 et filetype=sh completions/sudo 0000644 00000002454 14720751124 0010005 0 ustar 00 # bash completion for sudo(8) -*- shell-script -*- _sudo() { local cur prev words cword _init_completion || return local i mode=normal [[ $1 == *sudoedit ]] && mode=edit [[ $mode == normal ]] && for (( i=1; i <= COMP_CWORD; i++ )); do if [[ ${COMP_WORDS[i]} != -* ]]; then local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin local root_command=${COMP_WORDS[i]} _command_offset $i return fi if [[ ${COMP_WORDS[i]} == -e ]]; then mode=edit break fi [[ ${COMP_WORDS[i]} == -@(u|U|g|C|p) ]] && ((i++)) done case "$prev" in -u|-U) COMPREPLY=( $( compgen -u -- "$cur" ) ) return ;; -g) COMPREPLY=( $( compgen -g -- "$cur" ) ) return ;; -C|-p) # argument required but no completions available return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-A -b -C -E -e -g -H -h -i -K -k -L -l -ll -n -P -p -S -s -U -u -V -v' -- "$cur" ) ) return fi if [[ $mode == edit ]]; then _filedir fi } && complete -F _sudo sudo sudoedit # ex: ts=4 sw=4 et filetype=sh completions/mount 0000644 00000003664 14720751124 0010201 0 ustar 00 # mount(8) completion -*- shell-script -*- if [[ $OSTYPE == *linux* ]]; then . "$BASH_SOURCE.linux" return fi # This will pull a list of possible mounts out of # /etc/{,v}fstab, unless the word being completed contains a ':', which # would indicate the specification of an NFS server. In that case, we # query the server for a list of all available exports and complete on # that instead. # _mount() { local cur prev words cword _init_completion -n : || return local sm host case $prev in -t|--types) _fstypes return 0 ;; esac [[ "$cur" == \\ ]] && cur="/" if [[ "$cur" == *:* ]]; then for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do [[ -x $sm ]] || continue COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \ awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) ) return 0 done fi if [[ "$cur" == //* ]]; then host=${cur#//} host=${host%%/*} if [[ -n $host ]]; then COMPREPLY=( $( compgen -P "//$host" -W \ "$( smbclient -d 0 -NL $host 2>/dev/null | sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' | sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \ -- "${cur#//$host}" ) ) fi elif [[ -r /etc/vfstab ]]; then # Solaris COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" ) ) elif [[ ! -e /etc/fstab ]]; then # probably Cygwin COMPREPLY=( $( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) ) else # probably BSD COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab )" -- "$cur" ) ) fi } && complete -F _mount -o default -o dirnames mount # ex: ts=4 sw=4 et filetype=sh completions/tc 0000644 00000064637 14720751124 0007454 0 ustar 00 # tc(8) completion -*- shell-script -*- # Copyright 2016 6WIND S.A. # Copyright 2016 Quentin Monnet <quentin.monnet@6wind.com> QDISC_KIND=' choke codel bfifo pfifo pfifo_head_drop fq fq_codel gred hhf \ mqprio multiq netem pfifo_fast pie red rr sfb sfq tbf atm cbq drr \ dsmark hfsc htb prio qfq ' FILTER_KIND=' basic bpf cgroup flow flower fw route rsvp tcindex u32 matchall ' ACTION_KIND=' gact mirred bpf sample ' # Takes a list of words in argument; each one of them is added to COMPREPLY if # it is not already present on the command line. Returns no value. _tc_once_attr() { local w subcword found for w in $*; do found=0 for (( subcword=3; subcword < ${#words[@]}-1; subcword++ )); do if [[ $w == ${words[subcword]} ]]; then found=1 break fi done [[ $found -eq 0 ]] && \ COMPREPLY+=( $( compgen -W "$w" -- "$cur" ) ) done } # Takes a list of words in argument; each one of them is added to COMPREPLY if # it is not already present on the command line from the provided index. Returns # no value. _tc_once_attr_from() { local w subcword found from=$1 shift for w in $*; do found=0 for (( subcword=$from; subcword < ${#words[@]}-1; subcword++ )); do if [[ $w == ${words[subcword]} ]]; then found=1 break fi done [[ $found -eq 0 ]] && \ COMPREPLY+=( $( compgen -W "$w" -- "$cur" ) ) done } # Takes a list of words in argument; adds them all to COMPREPLY if none of them # is already present on the command line. Returns no value. _tc_one_of_list() { local w subcword for w in $*; do for (( subcword=3; subcword < ${#words[@]}-1; subcword++ )); do [[ $w == ${words[subcword]} ]] && return 1 done done COMPREPLY+=( $( compgen -W "$*" -- "$cur" ) ) } # Takes a list of words in argument; adds them all to COMPREPLY if none of them # is already present on the command line from the provided index. Returns no # value. _tc_one_of_list_from() { local w subcword from=$1 shift for w in $*; do for (( subcword=$from; subcword < ${#words[@]}-1; subcword++ )); do [[ $w == ${words[subcword]} ]] && return 1 done done COMPREPLY+=( $( compgen -W "$*" -- "$cur" ) ) } # Returns "$cur ${cur}arg1 ${cur}arg2 ..." _tc_expand_units() { [[ $cur =~ ^[0-9]+ ]] || return 1 local value=${cur%%[^0-9]*} [[ $cur == $value ]] && echo $cur echo ${@/#/$value} } # Complete based on given word, usually $prev (or possibly the word before), # for when an argument or an option name has but a few possible arguments (so # tc does not take particular commands into account here). # Returns 0 is completion should stop after running this function, 1 otherwise. _tc_direct_complete() { case $1 in # Command options dev) _available_interfaces return 0 ;; classid) return 0 ;; estimator) local list=$( _tc_expand_units 'secs' 'msecs' 'usecs' ) COMPREPLY+=( $( compgen -W "$list" -- "$cur" ) ) return 0 ;; handle) return 0 ;; parent|flowid) local i iface ids cmd for (( i=3; i < ${#words[@]}-2; i++ )); do [[ ${words[i]} == dev ]] && iface=${words[i+1]} break done for cmd in qdisc class; do if [[ -n $iface ]]; then ids+=$( tc $cmd show dev $iface 2>/dev/null | \ cut -d\ -f 3 )" " else ids+=$( tc $cmd show 2>/dev/null | cut -d\ -f 3 ) fi done [[ $ids != " " ]] && \ COMPREPLY+=( $( compgen -W "$ids" -- "$cur" ) ) return 0 ;; protocol) # list comes from lib/ll_proto.c COMPREPLY+=( $( compgen -W ' 802.1Q 802.1ad 802_2 802_3 LLDP aarp \ all aoe arp atalk atmfate atmmpoa ax25 bpq can control cust \ ddcmp dec diag dna_dl dna_rc dna_rt econet ieeepup ieeepupat \ ip ipv4 ipv6 ipx irda lat localtalk loop mobitex ppp_disc \ ppp_mp ppp_ses ppptalk pup pupat rarp sca snap tipc tr_802_2 \ wan_ppp x25' -- "$cur" ) ) return 0 ;; prio) return 0 ;; stab) COMPREPLY+=( $( compgen -W 'mtu tsize mpu overhead linklayer' -- "$cur" ) ) ;; # Qdiscs and classes options alpha|bands|beta|buckets|corrupt|debug|decrement|default|\ default_index|depth|direct_qlen|divisor|duplicate|ewma|flow_limit|\ flows|hh_limit|increment|indices|linklayer|non_hh_weight|num_tc|\ penalty_burst|penalty_rate|prio|priomap|probability|queues|r2q|\ reorder|vq|vqs) return 0 ;; setup) COMPREPLY+=( $( compgen -W 'vqs' -- "$cur" ) ) return 0 ;; hw) COMPREPLY+=( $( compgen -W '1 0' -- "$cur" ) ) return 0 ;; distribution) COMPREPLY+=( $( compgen -W 'uniform normal pareto paretonormal' -- "$cur" ) ) return 0 ;; loss) COMPREPLY+=( $( compgen -W 'random state gmodel' -- "$cur" ) ) return 0 ;; # Qdiscs and classes options options gap|gmodel|state) return 0 ;; # Filters options map) COMPREPLY+=( $( compgen -W 'key' -- "$cur" ) ) return 0 ;; hash) COMPREPLY+=( $( compgen -W 'keys' -- "$cur" ) ) return 0 ;; indev) _available_interfaces return 0 ;; eth_type) COMPREPLY+=( $( compgen -W 'ipv4 ipv6' -- "$cur" ) ) return 0 ;; ip_proto) COMPREPLY+=( $( compgen -W 'tcp udp' -- "$cur" ) ) return 0 ;; # Filters options options key|keys) [[ ${words[@]} =~ graft ]] && return 1 COMPREPLY+=( $( compgen -W 'src dst proto proto-src proto-dst iif \ priority mark nfct nfct-src nfct-dst nfct-proto-src \ nfct-proto-dst rt-classid sk-uid sk-gid vlan-tag rxhash' -- \ "$cur" ) ) return 0 ;; # BPF options - used for filters, actions, and exec export|bytecode|bytecode-file|object-file) _filedir return 0 ;; object-pinned|graft) # Pinned object is probably under /sys/fs/bpf/ [[ -n "$cur" ]] && _filedir && return 0 COMPREPLY=( $( compgen -G "/sys/fs/bpf/*" -- "$cur" ) ) || _filedir compopt -o nospace return 0 ;; section) if (type objdump > /dev/null 2>&1) ; then local fword objfile section_list for (( fword=3; fword < ${#words[@]}-3; fword++ )); do if [[ ${words[fword]} == object-file ]]; then objfile=${words[fword+1]} break fi done section_list=$( objdump -h $objfile 2>/dev/null | \ sed -n 's/^ *[0-9]\+ \([^ ]*\) *.*/\1/p' ) COMPREPLY+=( $( compgen -W "$section_list" -- "$cur" ) ) fi return 0 ;; import|run) _filedir return 0 ;; type) COMPREPLY+=( $( compgen -W 'cls act' -- "$cur" ) ) return 0 ;; # Actions options random) _tc_one_of_list 'netrand determ' return 0 ;; # Units for option arguments bandwidth|maxrate|peakrate|rate) local list=$( _tc_expand_units 'bit' \ 'kbit' 'kibit' 'kbps' 'kibps' \ 'mbit' 'mibit' 'mbps' 'mibps' \ 'gbit' 'gibit' 'gbps' 'gibps' \ 'tbit' 'tibit' 'tbps' 'tibps' ) COMPREPLY+=( $( compgen -W "$list" -- "$cur" ) ) ;; admit_bytes|avpkt|burst|cell|initial_quantum|limit|max|min|mtu|mpu|\ overhead|quantum|redflowlist) local list=$( _tc_expand_units \ 'b' 'kbit' 'k' 'mbit' 'm' 'gbit' 'g' ) COMPREPLY+=( $( compgen -W "$list" -- "$cur" ) ) ;; db|delay|evict_timeout|interval|latency|perturb|rehash|reset_timeout|\ target|tupdate) local list=$( _tc_expand_units 'secs' 'msecs' 'usecs' ) COMPREPLY+=( $( compgen -W "$list" -- "$cur" ) ) ;; esac return 1 } # Complete with options names for qdiscs. Each qdisc has its own set of options # and it seems we cannot really parse it from anywhere, so we add it manually # in this function. # Returns 0 is completion should stop after running this function, 1 otherwise. _tc_qdisc_options() { case $1 in choke) _tc_once_attr 'limit bandwidth ecn min max burst' return 0 ;; codel) _tc_once_attr 'limit target interval' _tc_one_of_list 'ecn noecn' return 0 ;; bfifo|pfifo|pfifo_head_drop) _tc_once_attr 'limit' return 0 ;; fq) _tc_once_attr 'limit flow_limit quantum initial_quantum maxrate \ buckets' _tc_one_of_list 'pacing nopacing' return 0 ;; fq_codel) _tc_once_attr 'limit flows target interval quantum' _tc_one_of_list 'ecn noecn' return 0 ;; gred) _tc_once_attr 'setup vqs default grio vq prio limit min max avpkt \ burst probability bandwidth' return 0 ;; hhf) _tc_once_attr 'limit quantum hh_limit reset_timeout admit_bytes \ evict_timeout non_hh_weight' return 0 ;; mqprio) _tc_once_attr 'num_tc map queues hw' return 0 ;; netem) _tc_once_attr 'delay distribution corrupt duplicate loss ecn \ reorder rate' return 0 ;; pie) _tc_once_attr 'limit target tupdate alpha beta' _tc_one_of_list 'bytemode nobytemode' _tc_one_of_list 'ecn noecn' return 0 ;; red) _tc_once_attr 'limit min max avpkt burst adaptive probability \ bandwidth ecn harddrop' return 0 ;; rr|prio) _tc_once_attr 'bands priomap multiqueue' return 0 ;; sfb) _tc_once_attr 'rehash db limit max target increment decrement \ penalty_rate penalty_burst' return 0 ;; sfq) _tc_once_attr 'limit perturb quantum divisor flows depth headdrop \ redflowlimit min max avpkt burst probability ecn harddrop' return 0 ;; tbf) _tc_once_attr 'limit burst rate mtu peakrate latency overhead \ linklayer' return 0 ;; cbq) _tc_once_attr 'bandwidth avpkt mpu cell ewma' return 0 ;; dsmark) _tc_once_attr 'indices default_index set_tc_index' return 0 ;; hfsc) _tc_once_attr 'default' return 0 ;; htb) _tc_once_attr 'default r2q direct_qlen debug' return 0 ;; multiq|pfifo_fast|atm|drr|qfq) return 0 ;; esac return 1 } # Complete with options names for BPF filters or actions. # Returns 0 is completion should stop after running this function, 1 otherwise. _tc_bpf_options() { [[ ${words[${#words[@]}-3]} == object-file ]] && \ _tc_once_attr 'section export' [[ ${words[${#words[@]}-5]} == object-file ]] && \ [[ ${words[${#words[@]}-3]} =~ (section|export) ]] && \ _tc_once_attr 'section export' _tc_one_of_list 'bytecode bytecode-file object-file object-pinned' _tc_once_attr 'verbose index direct-action action classid' return 0 } # Complete with options names for filter actions. # This function is recursive, thus allowing multiple actions statement to be # parsed. # Returns 0 is completion should stop after running this function, 1 otherwise. _tc_filter_action_options() { for ((acwd=$1; acwd < ${#words[@]}-1; acwd++)); do if [[ action == ${words[acwd]} ]]; then _tc_filter_action_options $((acwd+1)) && return 0 fi done local action acwd for ((acwd=$1; acwd < ${#words[@]}-1; acwd++)); do if [[ $ACTION_KIND =~ ' '${words[acwd]}' ' ]]; then _tc_one_of_list_from $acwd action _tc_action_options $acwd && return 0 fi done _tc_one_of_list_from $acwd $ACTION_KIND return 0 } # Complete with options names for filters. # Returns 0 is completion should stop after running this function, 1 otherwise. _tc_filter_options() { for ((acwd=$1; acwd < ${#words[@]}-1; acwd++)); do if [[ action == ${words[acwd]} ]]; then _tc_filter_action_options $((acwd+1)) && return 0 fi done filter=${words[$1]} case $filter in basic) _tc_once_attr 'match action classid' return 0 ;; bpf) _tc_bpf_options return 0 ;; cgroup) _tc_once_attr 'match action' return 0 ;; flow) local i for (( i=5; i < ${#words[@]}-1; i++ )); do if [[ ${words[i]} =~ ^keys?$ ]]; then _tc_direct_complete 'key' COMPREPLY+=( $( compgen -W 'or and xor rshift addend' -- \ "$cur" ) ) break fi done _tc_once_attr 'map hash divisor baseclass match action' return 0 ;; matchall) _tc_once_attr 'action skip_sw skip_hw' return 0 ;; flower) _tc_once_attr 'action classid indev dst_mac src_mac eth_type \ ip_proto dst_ip src_ip dst_port src_port' return 0 ;; fw) _tc_once_attr 'action classid' return 0 ;; route) _tc_one_of_list 'from fromif' _tc_once_attr 'to classid action' return 0 ;; rsvp) _tc_once_attr 'ipproto session sender classid action tunnelid \ tunnel flowlabel spi/ah spi/esp u8 u16 u32' [[ ${words[${#words[@]}-3]} == tunnel ]] && \ COMPREPLY+=( $( compgen -W 'skip' -- "$cur" ) ) [[ ${words[${#words[@]}-3]} =~ u(8|16|32) ]] && \ COMPREPLY+=( $( compgen -W 'mask' -- "$cur" ) ) [[ ${words[${#words[@]}-3]} == mask ]] && \ COMPREPLY+=( $( compgen -W 'at' -- "$cur" ) ) return 0 ;; tcindex) _tc_once_attr 'hash mask shift classid action' _tc_one_of_list 'pass_on fall_through' return 0 ;; u32) _tc_once_attr 'match link classid action offset ht hashkey sample' COMPREPLY+=( $( compgen -W 'ip ip6 udp tcp icmp u8 u16 u32 mark \ divisor' -- "$cur" ) ) return 0 ;; esac return 1 } # Complete with options names for actions. # Returns 0 is completion should stop after running this function, 1 otherwise. _tc_action_options() { local from=$1 local action=${words[from]} case $action in bpf) _tc_bpf_options return 0 ;; mirred) _tc_one_of_list_from $from 'ingress egress' _tc_one_of_list_from $from 'mirror redirect' _tc_once_attr_from $from 'index dev' return 0 ;; sample) _tc_once_attr_from $from 'rate' _tc_once_attr_from $from 'trunc' _tc_once_attr_from $from 'group' return 0 ;; gact) _tc_one_of_list_from $from 'reclassify drop continue pass' _tc_once_attr_from $from 'random' return 0 ;; esac return 1 } # Complete with options names for exec. # Returns 0 is completion should stop after running this function, 1 otherwise. _tc_exec_options() { case $1 in import) [[ ${words[${#words[@]}-3]} == import ]] && \ _tc_once_attr 'run' return 0 ;; graft) COMPREPLY+=( $( compgen -W 'key type' -- "$cur" ) ) [[ ${words[${#words[@]}-3]} == object-file ]] && \ _tc_once_attr 'type' _tc_bpf_options return 0 ;; esac return 1 } # Main completion function # Logic is as follows: # 1. Check if previous word is a global option; if so, propose arguments. # 2. Check if current word is a global option; if so, propose completion. # 3. Check for the presence of a main command (qdisc|class|filter|...). If # there is one, first call _tc_direct_complete to see if previous word is # waiting for a particular completion. If so, propose completion and exit. # 4. Extract main command and -- if available -- its subcommand # (add|delete|show|...). # 5. Propose completion based on main and sub- command in use. Additional # functions may be called for qdiscs, classes or filter options. _tc() { local cur prev words cword _init_completion || return case $prev in -V|-Version) return 0 ;; -b|-batch|-cf|-conf) _filedir return 0 ;; -force) COMPREPLY=( $( compgen -W '-batch' -- "$cur" ) ) return 0 ;; -nm|name) [[ -r /etc/iproute2/tc_cls ]] || \ COMPREPLY=( $( compgen -W '-conf' -- "$cur" ) ) return 0 ;; -n|-net|-netns) local nslist=$( ip netns list 2>/dev/null ) COMPREPLY+=( $( compgen -W "$nslist" -- "$cur" ) ) return 0 ;; -tshort) _tc_once_attr '-statistics' COMPREPLY+=( $( compgen -W 'monitor' -- "$cur" ) ) return 0 ;; -timestamp) _tc_once_attr '-statistics -tshort' COMPREPLY+=( $( compgen -W 'monitor' -- "$cur" ) ) return 0 ;; esac # Search for main commands local subcword cmd subcmd for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do [[ ${words[subcword]} == -b?(atch) ]] && return 0 [[ -n $cmd ]] && subcmd=${words[subcword]} && break [[ ${words[subcword]} != -* && \ ${words[subcword-1]} != -@(n?(et?(ns))|c?(on)f) ]] && \ cmd=${words[subcword]} done if [[ -z $cmd ]]; then case $cur in -*) local c='-Version -statistics -details -raw -pretty \ -iec -graphe -batch -name -netns -timestamp' [[ $cword -eq 1 ]] && c+=' -force' COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) return 0 ;; *) COMPREPLY=( $( compgen -W "help $( tc help 2>&1 | \ command sed \ -e '/OBJECT := /!d' \ -e 's/.*{//' \ -e 's/}.*//' \ -e \ 's/|//g' )" -- "$cur" ) ) return 0 ;; esac fi [[ $subcmd == help ]] && return 0 # For this set of commands we may create COMPREPLY just by analysing the # previous word, if it expects for a specific list of options or values. if [[ $cmd =~ (qdisc|class|filter|action|exec) ]]; then _tc_direct_complete $prev && return 0 if [[ ${words[${#words[@]}-3]} == estimator ]]; then local list=$( _tc_expand_units 'secs' 'msecs' 'usecs' ) COMPREPLY+=( $( compgen -W "$list" -- "$cur" ) ) && return 0 fi fi # Completion depends on main command and subcommand in use. case $cmd in qdisc) case $subcmd in add|change|replace|link|del|delete) if [[ $(($cword-$subcword)) -eq 1 ]]; then COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) return 0 fi local qdisc qdwd for ((qdwd=$subcword; qdwd < ${#words[@]}-1; qdwd++)); do if [[ $QDISC_KIND =~ ' '${words[qdwd]}' ' ]]; then qdisc=${words[qdwd]} _tc_qdisc_options $qdisc && return 0 fi done _tc_one_of_list $QDISC_KIND _tc_one_of_list 'root ingress parent clsact' _tc_once_attr 'handle estimator stab' ;; show) _tc_once_attr 'dev' _tc_one_of_list 'ingress clsact' _tc_once_attr '-statistics -details -raw -pretty -iec \ -graph -name' ;; help) return 0 ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add delete change \ replace link show' -- "$cur" ) ) ;; esac ;; class) case $subcmd in add|change|replace|del|delete) if [[ $(($cword-$subcword)) -eq 1 ]]; then COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) return 0 fi local qdisc qdwd for ((qdwd=$subcword; qdwd < ${#words[@]}-1; qdwd++)); do if [[ $QDISC_KIND =~ ' '${words[qdwd]}' ' ]]; then qdisc=${words[qdwd]} _tc_qdisc_options $qdisc && return 0 fi done _tc_one_of_list $QDISC_KIND _tc_one_of_list 'root parent' _tc_once_attr 'classid' ;; show) _tc_once_attr 'dev' _tc_one_of_list 'root parent' _tc_once_attr '-statistics -details -raw -pretty -iec \ -graph -name' ;; help) return 0 ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add delete change \ replace show' -- "$cur" ) ) ;; esac ;; filter) case $subcmd in add|change|replace|del|delete) if [[ $(($cword-$subcword)) -eq 1 ]]; then COMPREPLY=( $( compgen -W 'dev' -- "$cur" ) ) return 0 fi local filter fltwd for ((fltwd=$subcword; fltwd < ${#words[@]}-1; fltwd++)); do if [[ $FILTER_KIND =~ ' '${words[fltwd]}' ' ]]; then _tc_filter_options $fltwd && return 0 fi done _tc_one_of_list $FILTER_KIND _tc_one_of_list 'root ingress egress parent' _tc_once_attr 'handle estimator pref protocol' ;; show) _tc_once_attr 'dev' _tc_one_of_list 'root ingress egress parent' _tc_once_attr '-statistics -details -raw -pretty -iec \ -graph -name' ;; help) return 0 ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add delete change \ replace show' -- "$cur" ) ) ;; esac ;; action) case $subcmd in add|change|replace) local action acwd for ((acwd=$subcword; acwd < ${#words[@]}-1; acwd++)); do if [[ $ACTION_KIND =~ ' '${words[acwd]}' ' ]]; then _tc_action_options $acwd && return 0 fi done _tc_one_of_list $ACTION_KIND ;; get|del|delete) _tc_once_attr 'index' ;; lst|list|flush|show) _tc_one_of_list $ACTION_KIND ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add delete change \ replace show list flush action' -- "$cur" ) ) ;; esac ;; monitor) COMPREPLY=( $( compgen -W 'help' -- "$cur" ) ) ;; exec) case $subcmd in bpf) local excmd exwd EXEC_KIND=' import debug graft ' for ((exwd=$subcword; exwd < ${#words[@]}-1; exwd++)); do if [[ $EXEC_KIND =~ ' '${words[exwd]}' ' ]]; then excmd=${words[exwd]} _tc_exec_options $excmd && return 0 fi done _tc_one_of_list $EXEC_KIND ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'bpf' -- "$cur" ) ) ;; esac ;; esac } && complete -F _tc tc # ex: ts=4 sw=4 et filetype=sh completions/lsinitrd 0000644 00000004057 14720751124 0010664 0 ustar 00 # # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Copyright 2013 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # __contains_word () { local word=$1; shift for w in $*; do [[ $w = $word ]] && return 0; done return 1 } _lsinitrd() { local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-s --size -h --help' [ARG]='-f --file -k --kver' ) if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --file|-f) comps=$(compgen -f -- "$cur") compopt -o filenames ;; --kver|-k) comps=$(cd /lib/modules; echo [0-9]*) ;; *) return 0 ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi comps=$(compgen -f -- "$cur") compopt -o filenames COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _lsinitrd lsinitrd completions/journalctl 0000644 00000012635 14720751124 0011212 0 ustar 00 # journalctl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC} ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE _{P,U,G}ID _COMM _EXE _CMDLINE _AUDIT_{SESSION,LOGINUID} _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID} _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT _KERNEL_{DEVICE,SUBSYSTEM} _UDEV_{SYSNAME,DEVNODE,DEVLINK} __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP) __syslog_priorities=(emerg alert crit err warning notice info debug) _journalctl() { local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-a --all --full --system --user --disk-usage -f --follow --header -h --help -l --local --new-id128 -m --merge --no-pager --no-tail -q --quiet --setup-keys --this-boot --verify --version --list-catalog --update-catalog --list-boots --show-cursor --dmesg -k --pager-end -e -r --reverse --utc -x --catalog --no-full --force --dump-catalog --flush' [ARG]='-b --boot --this-boot -D --directory --file -F --field -o --output -u --unit -p --priority' [ARGUNKNOWN]='-c --cursor --interval -n --lines --since --until --after-cursor --verify-key --identifier --root --machine' ) if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then case $prev in --boot|--this-boot|-b) comps=$(journalctl -F '_BOOT_ID' 2>/dev/null) ;; --directory|-D) comps=$(compgen -d -- "$cur") compopt -o filenames ;; --file) comps=$(compgen -f -- "$cur") compopt -o filenames ;; --output|-o) comps='short short-iso short-precise short-monotonic verbose export json json-pretty json-sse cat' ;; --field|-F) comps=${__journal_fields[*]} ;; --priority|-p) comps=${__syslog_priorities[*]} ;; --unit|-u) comps=$(journalctl -F '_SYSTEMD_UNIT' 2>/dev/null) ;; *) return 0 ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 elif [[ $cur = *=* ]]; then mapfile -t field_vals < <(journalctl -F "${prev%=}" 2>/dev/null) COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") ) elif [[ $cur = /dev* ]]; then compopt -o filenames COMPREPLY=( $(compgen -f -- "${cur}") ) elif [[ $cur = /* ]]; then # Append /dev/ to the list of completions, so that # after typing /<TAB><TAB> the user sees /dev/ as one # of the alternatives. Later on the rule above will # take care of showing device files in /dev/. mapfile -t field_vals < <(journalctl -F "_EXE" 2>/dev/null; echo '/dev/') COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur}") ) if [[ "${COMPREPLY[@]}" = '/dev/' ]]; then compopt -o filenames COMPREPLY=( $(compgen -f -- "${cur}") ) fi elif [[ $prev = '=' ]]; then mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null) COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") ) else compopt -o nospace COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") ) fi } complete -F _journalctl journalctl completions/blkdiscard 0000644 00000001213 14720751124 0011125 0 ustar 00 _blkdiscard_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-o'|'--offset'|'-l'|'--length') COMPREPLY=( $(compgen -W "num" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--offset --length --secure --zeroout --verbose --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEVS DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) COMPREPLY=( $(compgen -W "$DEVS" -- $cur) ) return 0 } complete -F _blkdiscard_module blkdiscard completions/chcpu 0000644 00000002266 14720751124 0010136 0 ustar 00 _chcpu_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-e'|'--enable') local CPULIST # FIXME: will propose only binding to a cpu. # Maybe this should add comma, and continue? CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/offline) COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) ) return 0 ;; '-d'|'--disable') local CPULIST # FIXME: will propose only binding to a cpu. # Maybe this should add comma, and continue? CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online) COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) ) return 0 ;; '-c'|'--configure'|'-g'|'--deconfigure') COMPREPLY=( $(compgen -W "cpu-list" -- $cur) ) return 0 ;; '-p'|'--dispatch') COMPREPLY=( $(compgen -W "horizontal vertical" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS="--help --enable --disable --configure --deconfigure --dispatch --rescan --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _chcpu_module chcpu completions/quota 0000644 00000007263 14720751124 0010167 0 ustar 00 # bash completion for quota-tools -*- shell-script -*- _user_or_group() { local i # complete on groups if -g was given for (( i=1; i < cword; i++ )); do if [[ "${words[i]}" == -@(g|-group) ]]; then COMPREPLY=( $( compgen -g -- "$cur" ) ) return 0 fi done # otherwise complete on users COMPREPLY=( $( compgen -u -- "$cur" ) ) } _quota_parse_help() { local opts=$( _parse_help "$1" ) [[ $opts ]] || opts=$( _parse_usage "$1" ) # non-GNU? COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } _quota_formats() { COMPREPLY=( $( compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur" ) ) } _filesystems() { # Only list filesystems starting with "/", otherwise we also get #+ "binfmt_misc", "proc", "tmpfs", ... COMPREPLY=( $( compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \ -- "$cur" ) ) } _quota() { local cur prev words cword split _init_completion -s || return case $prev in -F|--format) _quota_formats return 0 ;; -h|--help|-V|--version) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then _quota_parse_help "$1" else _user_or_group fi } && complete -F _quota -o default quota _setquota() { local cur prev words cword split _init_completion -s || return case $prev in -F|--format) _quota_formats return 0 ;; -p|--prototype) _user_or_group return 0 ;; -h|--help|-V|--version) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then _quota_parse_help "$1" else local args _count_args case $args in 1) _user_or_group ;; 2) _filesystems ;; esac fi } && complete -F _setquota -o default setquota _edquota() { local cur prev words cword split _init_completion -s || return case $prev in -F|--format) _quota_formats return 0 ;; -f|--filesystem) _filesystems return 0 ;; -p|--prototype) _user_or_group return 0 ;; -h|--help|-V|--version) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then _quota_parse_help "$1" else _user_or_group fi } && complete -F _edquota -o default edquota _quotacheck() { local cur prev words cword split _init_completion -s || return case $prev in -F|--format) _quota_formats return 0 ;; -h|--help|-V|--version) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then _quota_parse_help "$1" else _filesystems fi } && complete -F _quotacheck -o default quotacheck repquota _quotaon() { local cur prev words cword split _init_completion -s || return case $prev in -F|--format) _quota_formats return 0 ;; -x|--xfs-command) COMPREPLY=( $( compgen -W 'delete enforce' -- "$cur" ) ) return 0 ;; -h|--help|-V|--version) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then _quota_parse_help "$1" else _filesystems fi } && complete -F _quotaon -o default quotaon quotaoff # ex: ts=4 sw=4 et filetype=sh completions/zramctl 0000644 00000002275 14720751124 0010510 0 ustar 00 _zramctl_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-a'|'--algorithm') COMPREPLY=( $(compgen -W "lzo lz4" -- $cur) ) return 0 ;; '-o'|'--output') local prefix realcur OUTPUT_ALL OUTPUT realcur="${cur##*,}" prefix="${cur%$realcur}" OUTPUT_ALL="NAME DISKSIZE DATA COMPR ALGORITHM STREAMS ZERO-PAGES TOTAL MOUNTPOINT" for WORD in $OUTPUT_ALL; do if ! [[ $prefix == *"$WORD"* ]]; then OUTPUT="$WORD $OUTPUT" fi done compopt -o nospace COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) ) return 0 ;; '-s'|'--size') COMPREPLY=( $(compgen -W "size" -- $cur) ) return 0 ;; '-t'|'--streams') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; esac case $cur in -*) OPTS=" --algorithm --bytes --find --noheadings --output --raw --reset --size --streams --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- ${cur:-"/dev/zram"}) ) return 0 } complete -F _zramctl_module zramctl completions/more 0000644 00000001020 14720751124 0007761 0 ustar 00 _more_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-V') return 0 ;; esac case $cur in -*) OPTS="-d -f -l -p -c -u -s -number -V" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; +*) OPTS="+number +/string" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _more_module more completions/cpio 0000644 00000005571 14720751124 0007770 0 ustar 00 # bash completion for cpio -*- shell-script -*- _cpio() { local cur prev words cword split _init_completion -s -n : || return # --name value style option case $prev in -H|--format) COMPREPLY=( $( compgen -W \ 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur" ) ) return 0 ;; -E|-F|-I|--file|--pattern-file) _filedir return 0 ;; -R|--owner) _usergroup return 0 ;; --rsh-command) compopt -o filenames COMPREPLY=( $( compgen -c -- "$cur" ) ) return 0 ;; esac $split && return 0 if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through -? --help --license --usage --version' -- "$cur" ) ) else case ${words[1]} in -o|--create) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B -L -V -C -H -M -O -F --file --format --message --null --reset-access-time --verbose --dot --append --block-size --dereference --io-size --quiet --force-local --rsh-command --help --version' \ -- "$cur" ) ) fi ;; -i|--extract) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r -t -s -u -v -B -S -V -C -E -H -M -R -I -F --file --make-directories --nonmatching --preserve-modification-time --numeric-uid-gid --rename --list --swap-bytes --swap --dot --unconditional --verbose --block-size --swap-halfwords --io-size --pattern-file --format --owner --no-preserve-owner --message --force-local --no-absolute-filenames --sparse --only-verify-crc --quiet --rsh-command --help --to-stdout --version' \ -- "$cur" ) ) fi ;; -p*|--pass-through) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-0 -a -d -l -m -u -v -L -V -R --null --reset-access-time --make-directories --link --quiet --preserve-modification-time --unconditional --verbose --dot --dereference --owner --no-preserve-owner --sparse --help --version' \ -- "$cur" ) ) else _filedir -d fi ;; esac fi } && complete -F _cpio cpio # ex: ts=4 sw=4 et filetype=sh completions/tuned-adm 0000644 00000000777 14720751124 0010717 0 ustar 00 # bash completion for tuned-adm _tuned_adm() { local commands="active list off profile recommend verify" local cur prev words cword _init_completion || return if [[ "$cword" -eq 1 ]]; then COMPREPLY=( $(compgen -W "$commands" -- "$cur" ) ) elif [[ "$cword" -eq 2 && "$prev" == "profile" ]]; then COMPREPLY=( $(compgen -W "$(command find /usr/lib/tuned /etc/tuned -mindepth 1 -maxdepth 1 -type d -printf "%f\n")" -- "$cur" ) ) else COMPREPLY=() fi return 0 } && complete -F _tuned_adm tuned-adm completions/bootctl 0000644 00000003454 14720751124 0010502 0 ustar 00 # bootctl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } _bootctl() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-h --help --version' ) if [[ "$cur" = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi local -A VERBS=( [STANDALONE]='status' ) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _bootctl bootctl completions/mkfs 0000644 00000001264 14720751124 0007771 0 ustar 00 _mkfs_module() { local cur prev OPTS DEVS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-t'|'--type') FSTYPES=$(for I in /sbin/mkfs.* /usr/sbin/mkfs.*; do if [ -e $I ]; then echo ${I##*mkfs.}; fi; done) COMPREPLY=( $(compgen -W "$FSTYPES" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS='--type --verbose --help --version' COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) ) return 0 } complete -F _mkfs_module mkfs completions/loginctl 0000644 00000010037 14720751124 0010642 0 ustar 00 # loginctl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __get_all_sessions () { loginctl --no-legend list-sessions | { while read -r a b; do printf "%s\n" "$a"; done; } ; } __get_all_users () { loginctl --no-legend list-users | { while read -r a b; do printf "%s\n" "$b"; done; } ; } __get_all_seats () { loginctl --no-legend list-seats | { while read -r a b; do printf "%s\n" "$a"; done; } ; } _loginctl () { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps local -A OPTS=( [STANDALONE]='--all -a --help -h --no-pager --privileged -P --version --no-legend --no-ask-password -l --full' [ARG]='--host -H --kill-who --property -p --signal -s --machine' ) if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --signal|-s) comps=$(compgen -A signal) ;; --kill-who) comps='all leader' ;; --host|-H) comps=$(compgen -A hostname) ;; --property|-p) comps='' ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ "$cur" = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi local -A VERBS=( [SESSIONS]='session-status show-session activate lock-session unlock-session terminate-session kill-session' [USERS]='user-status show-user enable-linger disable-linger terminate-user kill-user' [SEATS]='seat-status show-seat terminate-seat' [STANDALONE]='list-sessions list-users list-seats flush-devices' [ATTACH]='attach' ) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then comps="${VERBS[*]}" elif __contains_word "$verb" ${VERBS[SESSIONS]}; then comps=$( __get_all_sessions ) elif __contains_word "$verb" ${VERBS[USERS]}; then comps=$( __get_all_users ) elif __contains_word "$verb" ${VERBS[SEATS]}; then comps=$( __get_all_seats ) elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' elif __contains_word "$verb" ${VERBS[ATTACH]}; then if [[ $prev = $verb ]]; then comps=$( __get_all_seats ) else comps=$(compgen -A file -- "$cur" ) compopt -o filenames fi fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _loginctl loginctl completions/column 0000644 00000001325 14720751124 0010324 0 ustar 00 _column_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-c'|'--columns') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; '-s'|'--separator'|'-o'|'--output-separator') COMPREPLY=( $(compgen -W "string" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--columns --table --separator --output-separator --fillrows --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _column_module column completions/chgrp 0000644 00000001743 14720751124 0010136 0 ustar 00 # chgrp(1) completion -*- shell-script -*- _chgrp() { local cur prev words cword split _init_completion -s || return cur=${cur//\\\\/} if [[ "$prev" == --reference ]]; then _filedir return 0 fi $split && return 0 # options completion if [[ "$cur" == -* ]]; then local w opts for w in "${words[@]}" ; do [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break done COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --silent --quiet --reference --recursive --verbose --help --version $opts' -- "$cur" ) ) return 0 fi # first parameter on line or first since an option? if [[ $cword -eq 1 && "$cur" != -* || "$prev" == -* ]]; then _allowed_groups "$cur" else _filedir || return 0 fi return 0 } && complete -F _chgrp chgrp # ex: ts=4 sw=4 et filetype=sh completions/write 0000644 00000000756 14720751124 0010170 0 ustar 00 _write_module() { local cur prev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $COMP_CWORD in 1) COMPREPLY=( $(compgen -u -- $cur) ) return 0 ;; 2) local I TERMS='' for I in /sys/class/tty/*; do TERMS+="/dev${I##/sys/class/tty} " done COMPREPLY=( $(compgen -W "$TERMS" -- $cur) ) return 0 ;; esac return 0 } complete -F _write_module write completions/rpm 0000644 00000023426 14720751124 0007633 0 ustar 00 # bash completion for rpm -*- shell-script -*- # helper functions _rpm_installed_packages() { if [[ -r /var/log/rpmpkgs && \ /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then # using RHL 7.2 or later - this is quicker than querying the DB COMPREPLY=( $( compgen -W "$( sed -ne \ 's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \ /var/log/rpmpkgs )" -- "$cur" ) ) elif type rpmqpack &>/dev/null ; then # SUSE's rpmqpack is faster than rpm -qa COMPREPLY=( $( compgen -W '$( rpmqpack )' -- "$cur" ) ) else COMPREPLY=( $( ${1:-rpm} -qa --nodigest --nosignature \ --queryformat='%{NAME} ' "$cur*" 2>/dev/null ) ) fi } _rpm_groups() { local IFS=$'\n' COMPREPLY=( $( compgen -W "$( ${1:-rpm} -qa --nodigest --nosignature \ --queryformat='%{GROUP}\n' 2>/dev/null )" -- "$cur" ) ) } _rpm_macros() { # get a list of macros COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | sed -ne \ 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p' )" \ -- "$cur" ) ) } _rpm_buildarchs() { COMPREPLY=( $( compgen -W "$( ${1:-rpm} --showrc | sed -ne \ 's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p' )" \ -- "$cur" ) ) } # rpm(8) completion # _rpm() { local cur prev words cword split _init_completion -s || return if [[ $cword -eq 1 ]]; then # first parameter on line case $cur in --*) COMPREPLY=( $( compgen -W '--help --version --initdb --checksig --addsign --delsign --rebuilddb --showrc --setperms --setugids --eval --install --upgrade --query --freshen --erase --verify --querytags --import' \ -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W '-e -E -F -i -q -t -U -V' \ -- "$cur" ) ) ;; esac return 0 fi case $prev in --dbpath|--excludepath|--prefix|--relocate|--root|-r) _filedir -d return 0 ;; --eval|-E) _rpm_macros $1 return 0 ;; --pipe) compopt -o filenames COMPREPLY=( $( compgen -c -- "$cur" ) ) return 0 ;; --rcfile) _filedir return 0 ;; --specfile) # complete on .spec files _filedir spec return 0 ;; --whatprovides) if [[ "$cur" == */* ]]; then _filedir else # complete on capabilities local IFS=$'\n' COMPREPLY=( $( compgen -W "$( $1 -qa --nodigest --nosignature \ --queryformat='%{PROVIDENAME}\n' 2>/dev/null )" \ -- "$cur" ) ) fi return 0 ;; --whatrequires) if [[ "$cur" == */* ]]; then _filedir else # complete on capabilities local IFS=$'\n' COMPREPLY=( $( compgen -W "$( $1 -qa --nodigest --nosignature \ --queryformat='%{REQUIRENAME}\n' 2>/dev/null )" \ -- "$cur" ) ) fi return 0 ;; --define|-D|--fileid|--hdrid|--pkgid) # argument required but no completions available return 0 ;; esac $split && return 0 # options common to all modes local opts="--define= --eval= --macros= --nodigest --nosignature --rcfile= --quiet --pipe --verbose" case ${words[1]} in -[iFU]*|--install|--freshen|--upgrade) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts --percent --force --test --replacepkgs --replacefiles --root --excludedocs --includedocs --noscripts --ignorearch --dbpath --prefix= --ignoreos --nodeps --allfiles --ftpproxy --ftpport --justdb --httpproxy --httpport --noorder --relocate= --badreloc --notriggers --excludepath= --ignoresize --oldpackage --queryformat --repackage --nosuggests" -- "$cur" ) ) else _filedir '[rs]pm' fi ;; -e|--erase) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts --allmatches --noscripts --notriggers --nodeps --test --repackage" -- "$cur" ) ) else _rpm_installed_packages $1 fi ;; -q*|--query) # options common to all query types opts+=" --changelog --configfiles --conflicts --docfiles --dump --enhances --filesbypkg --filecaps --fileclass --filecolor --fileprovide --filerequire --filesbypkg --info --list --obsoletes --pipe --provides --queryformat= --requires --scripts --suggests --triggers --xml" if [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then # -qf completion if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts --dbpath --fscontext --last --root --state" -- "$cur" ) ) else _filedir fi elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then # -qg completion _rpm_groups $1 elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then # -qp; uninstalled package completion if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts --ftpport --ftpproxy --httpport --httpproxy --nomanifest" -- "$cur" ) ) else _filedir '[rs]pm' fi else # -q; installed package completion if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts --all --file --fileid --dbpath --fscontext --ftswalk --group --hdrid --last --package --pkgid --root= --specfile --state --triggeredby --whatprovides --whatrequires" \ -- "$cur" ) ) elif [[ ${words[@]} != *\ -@(*([^ -])a|-all )* ]]; then _rpm_installed_packages $1 fi fi ;; -K*|--checksig) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts --nopgp --nogpg --nomd5" \ -- "$cur" ) ) else _filedir '[rs]pm' fi ;; -[Vy]*|--verify) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts --root= --dbpath --nodeps --nogroup --nolinkto --nomode --nomtime --nordev --nouser --nofiles --noscripts --nomd5 --querytags --specfile --whatrequires --whatprovides" -- "$cur" ) ) # check whether we're doing file completion elif [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then _filedir elif [[ ${words[@]} == *\ -@(*([^ -])g|-group )* ]]; then _rpm_groups $1 elif [[ ${words[@]} == *\ -@(*([^ -])p|-package )* ]]; then _filedir '[rs]pm' else _rpm_installed_packages $1 fi ;; --resign|--addsign|--delsign) _filedir '[rs]pm' ;; --setperms|--setgids) _rpm_installed_packages $1 ;; --import|--dbpath|--root) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--import --dbpath --root=' \ -- "$cur" ) ) else _filedir fi ;; esac [[ $COMPREPLY == *= ]] && compopt -o nospace return 0 } && complete -F _rpm rpm _rpmbuild() { local cur prev words cword split _init_completion -s || return local rpm="${1%build*}" [[ $rpm == $1 ]] || ! type $rpm &>/dev/null && rpm= case $prev in --buildroot|--root|-r|--dbpath) _filedir -d return 0 ;; --target) _rpm_buildarchs return 0 ;; --eval|-E) _rpm_macros $rpm return 0 ;; --macros|--rcfile) _filedir return 0 ;; --buildpolicy) local cfgdir=$( $rpm --eval '%{_rpmconfigdir}' 2>/dev/null ) if [[ $cfgdir ]]; then COMPREPLY=( $( compgen -W "$( command ls $cfgdir 2>/dev/null \ | sed -ne 's/^brp-//p' )" -- "$cur" ) ) fi ;; --define|-D|--with|--without) return 0 ;; esac $split && return 0 if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return 0 fi # Figure out file extensions to complete local word ext for word in ${words[@]}; do case $word in -b?) ext=spec break ;; -t?|--tarbuild) ext='@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))' break ;; --rebuild|--recompile) ext='@(?(no)src.r|s)pm' break ;; esac done [[ -n $ext ]] && _filedir $ext } && complete -F _rpmbuild rpmbuild rpmbuild-md5 # ex: ts=4 sw=4 et filetype=sh completions/groupmod 0000644 00000001301 14720751124 0010655 0 ustar 00 # groupmod(8) completion -*- shell-script -*- _groupmod() { local cur prev words cword split _init_completion -s || return # TODO: if -o/--non-unique is given, could complete on existing gids # with -g/--gid case $prev in -g|--gid|-h|--help|-n|--new-name|-p|--password) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace return 0 fi COMPREPLY=( $( compgen -g -- "$cur" ) ) } && complete -F _groupmod groupmod # ex: ts=4 sw=4 et filetype=sh completions/lslocks 0000644 00000001752 14720751124 0010505 0 ustar 00 _lslocks_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-p'|'--pid') local PIDS # /proc/locks can have 8 to 9 fields, see commit # 55c0d16bab8cc84b72bf11cb2fdd8aa6205ac608 PIDS="$(awk '{print $(NF-3)}' /proc/locks)" COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; '-o'|'--output') # FIXME: how to append to a string with compgen? local OUTPUT OUTPUT="COMMAND PID TYPE SIZE MODE M START END PATH BLOCKER" compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--pid --output --noheadings --raw --notruncate --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _lslocks_module lslocks completions/ldattach 0000644 00000002357 14720751124 0010621 0 ustar 00 _ldattach_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-s'|'--speed') COMPREPLY=( $(compgen -W "speed" -- $cur) ) return 0 ;; '-i'|'--iflag') local IFLAGS IFLAGS="BRKINT ICRNL IGNBRK IGNCR IGNPAR IMAXBEL INLCR INPCK ISTRIP IUCLC IUTF8 IXANY IXOFF IXON PARMRK -BRKINT -ICRNL -IGNBRK -IGNCR -IGNPAR -IMAXBEL -INLCR -INPCK -ISTRIP -IUCLC -IUTF8 -IXANY -IXOFF -IXON -PARMRK" COMPREPLY=( $(compgen -W "$IFLAGS" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--debug --speed --sevenbits --eightbits --noparity --evenparity --oddparity --onestopbit --twostopbits --iflag --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; /*) local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; esac local LDISC_DEVICE LDISC_DEVICE="6PACK AX25 GIGASET GIGASET_M101 HCI HDLC IRDA M101 MOUSE PPP PPS R3964 SLIP STRIP SYNCPPP SYNC_PPP TTY X25 /dev/" COMPREPLY=( $(compgen -W "$LDISC_DEVICE" -- $cur) ) return 0 } complete -F _ldattach_module ldattach completions/eject 0000644 00000002250 14720751124 0010117 0 ustar 00 _eject_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-a'|'--auto'|'-i'|'--manualeject') COMPREPLY=( $(compgen -W "off on" -- $cur) ) return 0 ;; '-c'|'--changerslot') # FIXME: there must be way to determine slots COMPREPLY=( $(compgen -W "slot" -- $cur) ) return 0 ;; '-x'|'--cdspeed') COMPREPLY=( $(compgen -W "$(eject -X)" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--auto --changerslot --default --floppy --force --manualeject --no-unmount --no-partitions-unmount --noop --proc --tape --cdrom --scsi --trayclose --traytoggle --verbose --cdspeed --listspeed --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEVS DEVS="$(for I in /sys/class/block/*/removable; do if [ $(cat $I) -ne 0 ]; then OLD_IFS=$IFS IFS='/'; ARR=($I) echo "/dev/${ARR[4]}" IFS=$OLD_IFS fi done)" COMPREPLY=( $(compgen -W "$DEVS" $cur) ) return 0 } complete -F _eject_module eject completions/lsblk 0000644 00000002704 14720751124 0010140 0 ustar 00 _lsblk_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-e'|'--exclude'|'-I'|'--include') local MAJOR I J MAJOR='' for I in /sys/dev/block/*; do J=${I##*/} MAJOR="$MAJOR ${J%%:*}" done # FIXME: how to append to a string with compgen? compopt -o nospace COMPREPLY=( $(compgen -W "$MAJOR" -S ',' -- $cur) ) return 0 ;; '-o'|'--output') # FIXME: how to append to a string with compgen? OUTPUT="NAME KNAME MAJ:MIN FSTYPE MOUNTPOINT LABEL UUID PARTLABEL PARTUUID RA RO RM MODEL SIZE STATE OWNER GROUP MODE ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE TYPE DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN RAND PKNAME HCTL TRAN REV VENDOR" compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--all --bytes --nodeps --discard --exclude --fs --help --include --ascii --list --perms --noheadings --output --pairs --raw --inverse --topology --scsi --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEVS DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) COMPREPLY=( $(compgen -W "$DEVS" -- $cur) ) return 0 } complete -F _lsblk_module lsblk completions/rev 0000644 00000000660 14720751124 0007624 0 ustar 00 _rev_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _rev_module rev completions/coredumpctl 0000644 00000006533 14720751124 0011356 0 ustar 00 # coredumpctl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC} ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID} COREDUMP_EXE _{P,U,G}ID _COMM _EXE _CMDLINE _AUDIT_{SESSION,LOGINUID} _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID} _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT _KERNEL_{DEVICE,SUBSYSTEM} _UDEV_{SYSNAME,DEVNODE,DEVLINK} __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP) _coredumpctl() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1' local -A VERBS=( [LIST]='list' [DUMP]='dump gdb' ) if __contains_word "$prev" '--output -o'; then comps=$( compgen -A file -- "$cur" ) compopt -o filenames elif __contains_word "$prev" '--FIELD -F'; then comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" ) elif [[ $cur = -* ]]; then comps=${OPTS} elif __contains_word "$prev" ${VERBS[*]} && ! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -F --field'; then compopt -o nospace COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") ) return 0 elif [[ $cur = *=* ]]; then mapfile -t field_vals < <(coredumpctl -F "${prev%=}" 2>/dev/null) COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") ) return 0 elif [[ $prev = '=' ]]; then mapfile -t field_vals < <(coredumpctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null) comps=${field_vals[*]} else for ((i=0; i <= COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[LIST]} ${VERBS[DUMP]}; then comps='' fi fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _coredumpctl coredumpctl completions/pivot_root 0000644 00000000603 14720751124 0011231 0 ustar 00 _pivot_root_module() { local cur prev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $COMP_CWORD in 1|2) local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) ) ;; esac return 0 } complete -F _pivot_root_module pivot_root completions/machinectl 0000644 00000006172 14720751124 0011143 0 ustar 00 # machinectl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word() { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __get_machines() { local a b machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } _machinectl() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps local -A OPTS=( [STANDALONE]='--all -a --full --help -h --no-ask-password --no-legend --no-pager --version' [ARG]='--host -H --kill-who -M --machine --property -p --signal -s' ) local -A VERBS=( [STANDALONE]='list' [MACHINES]='status show terminate kill reboot login' ) _init_completion || return for ((i=0; i <= COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then verb=${COMP_WORDS[i]} break fi done if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --signal|-s) comps=$(compgen -A signal) ;; --kill-who) comps='all leader' ;; --host|-H) comps=$(compgen -A hostname) ;; --machine|-M) comps=$( __get_machines ) ;; --property|-p) comps='' ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ "$cur" = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' elif __contains_word "$verb" ${VERBS[MACHINES]}; then comps=$( __get_machines ) fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _machinectl machinectl completions/ipcs 0000644 00000001002 14720751124 0007755 0 ustar 00 _ipcs_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-i'|'--id') COMPREPLY=( $(compgen -W "id" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS="--id --help --version --shmems --queues --semaphores --all --time --pid --creator --limits --summary --human --bytes" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _ipcs_module ipcs completions/renice 0000644 00000001454 14720751124 0010277 0 ustar 00 _renice_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-g'|'--pgrp') local PGRP PGRP=$(ps -ax -opgrp | sed '1d') COMPREPLY=( $(compgen -W "$PGRP" -- $cur) ) return 0 ;; '-n'|'--priority') COMPREPLY=( $(compgen -W "{-20..20}" -- $cur) ) return 0 ;; '-p'|'--pid') local PIDS PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; '-u'|'--user') COMPREPLY=( $(compgen -u -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS="--pgrp --priority --pid --user --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _renice_module renice completions/fdformat 0000644 00000000636 14720751124 0010635 0 ustar 00 _fdformat_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac DEVS=$(for I in echo /dev/fd*; do if [ -e $I ]; then echo $I; fi; done) OPTS="--no-verify --help --version $DEVS" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _fdformat_module fdformat completions/mcookie 0000644 00000000766 14720751124 0010465 0 ustar 00 _mcookie_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-f'|'--file') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--file --verbose --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac return 0 } complete -F _mcookie_module mcookie completions/iptables 0000644 00000004334 14720751124 0010635 0 ustar 00 # bash completion for iptables -*- shell-script -*- _iptables() { local cur prev words cword split _init_completion -s || return local table chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p' if [[ ${words[@]} == *-t\ *filter* ]]; then table="-t filter" elif [[ ${words[@]} == *-t\ *nat* ]]; then table="-t nat" elif [[ ${words[@]} == *-t\ *mangle* ]]; then table="-t mangle" fi case $prev in -*[AIDRPFXLZ]) COMPREPLY=( $( compgen -W '`iptables $table -nL | \ sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) ) ;; -*t) COMPREPLY=( $( compgen -W 'nat filter mangle' -- "$cur" ) ) ;; -j) if [[ "$table" == "-t filter" || -z "$table" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT `iptables $table -nL | sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ "$cur" ) ) elif [[ $table == "-t nat" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \ sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ -- "$cur" ) ) elif [[ $table == "-t mangle" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS `iptables $table -nL | sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ "$cur" ) ) fi ;; *) if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--in-interface --out-interface --source --destination --protocol --fragment --match --append --delete --insert --replace --list --flush --zero --new --delete-chain --policy --rename-chain --proto --source --destination --in-interface --jump --match --numeric --out-interface --table --verbose --line-numbers --exact --fragment --modprobe --set-counters --version' -- "$cur" ) ) fi ;; esac } && complete -F _iptables iptables # ex: ts=4 sw=4 et filetype=sh completions/flock 0000644 00000001534 14720751124 0010127 0 ustar 00 _flock_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-w'|'--timeout') COMPREPLY=( $(compgen -W "seconds" -- $cur) ) return 0 ;; '-E'|'--conflict-exit-code') COMPREPLY=( $(compgen -W "{0..255}" -- $cur) ) return 0 ;; '-c'|'--command') compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--shared --exclusive --unlock --nonblock --timeout --conflict-exit-code --close --command --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- ${cur:-"/"}) ) return 0 } complete -F _flock_module flock completions/mountpoint 0000644 00000001072 14720751124 0011242 0 ustar 00 _mountpoint_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-f'|'--fixme') COMPREPLY=( $(compgen -W "fixme" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--quiet --fs-devno --devno --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- ${cur:-"/"}) ) return 0 } complete -F _mountpoint_module mountpoint completions/tailf 0000644 00000001022 14720751124 0010120 0 ustar 00 _tailf_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-n'|'--lines') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--lines --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _tailf_module tailf completions/nsenter 0000644 00000001673 14720751124 0010513 0 ustar 00 _nsenter_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-t'|'--target') local PIDS PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in '=') # FIXME: --root and --wd should use get only # directories as compgen output. If $cur is # overwrote the same way as below in case segment # for $prev the command-line will get mangled. cur=${cur#=} ;; -*) OPTS="--target --mount= --uts= --ipc= --net= --pid= --user= --root= --wd= --no-fork --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _nsenter_module nsenter completions/chown 0000644 00000002153 14720751124 0010145 0 ustar 00 # chown(1) completion -*- shell-script -*- _chown() { local cur prev words cword split # Don't treat user:group as separate words. _init_completion -s -n : || return case "$prev" in --from) _usergroup return 0 ;; --reference) _filedir return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then # Complete -options local w opts for w in "${words[@]}" ; do [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break done COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --from --silent --quiet --reference --recursive --verbose --help --version $opts' -- "$cur" ) ) else local args # The first argument is an usergroup; the rest are filedir. _count_args : if [[ $args -eq 1 ]]; then _usergroup -u else _filedir fi fi } && complete -F _chown chown # ex: ts=4 sw=4 et filetype=sh completions/swaplabel 0000644 00000001173 14720751124 0011002 0 ustar 00 _swaplabel_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-L'|'--label') COMPREPLY=( $(compgen -W "label" -- $cur) ) return 0 ;; '-U'|'--uuid') COMPREPLY=( $(compgen -W '$(uuidgen)' -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--label --uuid --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _swaplabel_module swaplabel completions/namei 0000644 00000000764 14720751124 0010126 0 ustar 00 _namei_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--help --version --mountpoints --modes --owners --long --nosymlinks --vertical" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _namei_module namei completions/chpasswd 0000644 00000001154 14720751124 0010643 0 ustar 00 # chpasswd(8) completion -*- shell-script -*- _chpasswd() { local cur prev words cword split _init_completion -s || return case $prev in -c|--crypt) COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \ -- "$cur" ) ) return 0 ;; -s|--sha-rounds) return 0 ;; esac $split && return 0 COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } && complete -F _chpasswd chpasswd # ex: ts=4 sw=4 et filetype=sh completions/systemctl 0000644 00000030456 14720751124 0011065 0 ustar 00 # systemctl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __systemctl() { local mode=$1; shift 1 systemctl $mode --full --no-legend "$@" } __systemd_properties() { local mode=$1 { __systemctl $mode show --all; /usr/lib/systemd/systemd --dump-configuration-items; } | while IFS='=' read -r key value; do [[ $value ]] && echo "$key" done } __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __filter_units_by_property () { local mode=$1 property=$2 value=$3 ; shift 3 local units=("$@") local props IFS=$'\n' read -rd '' -a props < \ <(__systemctl $mode show --property "$property" -- "${units[@]}") for ((i=0; $i < ${#units[*]}; i++)); do if [[ "${props[i]}" = "$property=$value" ]]; then echo " ${units[i]}" fi done } __get_all_units () { { __systemctl $1 list-unit-files; __systemctl $1 list-units --all; } \ | { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; }; } __get_template_names () { __systemctl $1 list-unit-files \ | { while read -r a b; do [[ $a =~ @\. ]] && echo " ${a%%@.*}@"; done; }; } __get_active_units () { __systemctl $1 list-units \ | { while read -r a b; do echo " $a"; done; }; } __get_startable_units () { # find startable inactive units __filter_units_by_property $mode ActiveState inactive $( __filter_units_by_property $mode CanStart yes $( __systemctl $mode list-unit-files --state enabled,disabled,static | \ { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } __systemctl $mode list-units --state inactive,failed | \ { while read -r a b; do echo " $a"; done; } )) } __get_restartable_units () { # filter out masked and not-found __filter_units_by_property $mode CanStart yes $( __systemctl $mode list-unit-files --state enabled,disabled,static | \ { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } __systemctl $mode list-units | \ { while read -r a b; do echo " $a"; done; } ) } __get_failed_units () { __systemctl $1 list-units \ | { while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }; } __get_enabled_units () { __systemctl $1 list-unit-files \ | { while read -r a b c ; do [[ $b == "enabled" ]] && echo " $a"; done; }; } __get_disabled_units () { __systemctl $1 list-unit-files \ | { while read -r a b c ; do [[ $b == "disabled" ]] && echo " $a"; done; }; } __get_masked_units () { __systemctl $1 list-unit-files \ | { while read -r a b c ; do [[ $b == "masked" ]] && echo " $a"; done; }; } __get_all_unit_files () { { __systemctl $1 list-unit-files; } | { while read -r a b; do echo " $a"; done; }; } _systemctl () { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps mode local -A OPTS=( [STANDALONE]='--all -a --reverse --after --before --defaults --fail --ignore-dependencies --failed --force -f --full -l --global --help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall --now --quiet -q --privileged -P --system --version --runtime --recursive -r' [ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --root' ) local -A PROPS='CPUQuota= CPUAccounting= MemoryAccounting= BlockIOAccounting= SendSIGHUP= SendSIGKILL= WakeSystem= DefaultDependencies= MemoryLimit= CPUShares= BlockIOWeight= User= Group= DevicePolicy= KillMode= DeviceAllow= BlockIOReadBandwidth= BlockIOWriteBandwidth= BlockIODeviceWeight= Nice= Environment= KillSignal= AccuracySec= LimitCPU= LimitFSIZE= LimitDATA= LimitSTACK= LimitCORE= LimitRSS= LimitNOFILE= LimitAS= LimitNPROC= LimitMEMLOCK= LimitLOCKS= LimitSIGPENDING= LimitMSGQUEUE= LimitNICE= LimitRTPRIO= LimitRTTIME=' if __contains_word "--user" ${COMP_WORDS[*]}; then mode=--user else mode=--system fi if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --signal|-s) comps=$(compgen -A signal) ;; --type|-t) comps='automount busname device mount path service snapshot socket swap target timer' ;; --state) comps='loaded not-found stub active inactive dead elapsed exited listening mounted plugged running waiting' ;; --kill-who) comps='all control main' ;; --root) comps=$(compgen -A directory -- "$cur" ) compopt -o filenames ;; --host|-H) comps=$(compgen -A hostname) ;; --property|-p) comps=$(__systemd_properties $mode) ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ "$cur" = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi local -A VERBS=( [ALL_UNITS]='is-active is-failed is-enabled status show cat mask preset help list-dependencies edit' [ENABLED_UNITS]='disable' [DISABLED_UNITS]='enable' [REENABLABLE_UNITS]='reenable' [FAILED_UNITS]='reset-failed' [STARTABLE_UNITS]='start' [STOPPABLE_UNITS]='stop condstop kill try-restart condrestart' [ISOLATABLE_UNITS]='isolate' [RELOADABLE_UNITS]='reload condreload reload-or-try-restart force-reload' [RESTARTABLE_UNITS]='restart reload-or-restart' [TARGET_AND_UNITS]='add-wants add-requires' [MASKED_UNITS]='unmask' [JOBS]='cancel' [SNAPSHOTS]='delete' [PROPERTIES]='set-property' [ENVS]='set-environment unset-environment' [STANDALONE]='daemon-reexec daemon-reload default emergency exit halt hibernate hybrid-sleep kexec list-jobs list-sockets list-timers list-units list-unit-files poweroff reboot rescue show-environment suspend get-default is-system-running' [NAME]='snapshot' [FILE]='link switch-root' [TARGETS]='set-default' ) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then comps="${VERBS[*]}" elif __contains_word "$verb" ${VERBS[ALL_UNITS]}; then comps=$( __get_all_units $mode ) compopt -o filenames elif __contains_word "$verb" ${VERBS[ENABLED_UNITS]}; then comps=$( __get_enabled_units $mode ) compopt -o filenames elif __contains_word "$verb" ${VERBS[DISABLED_UNITS]}; then comps=$( __get_disabled_units $mode; __get_template_names $mode) compopt -o filenames elif __contains_word "$verb" ${VERBS[REENABLABLE_UNITS]}; then comps=$( __get_disabled_units $mode; __get_enabled_units $mode; __get_template_names $mode) compopt -o filenames elif __contains_word "$verb" ${VERBS[STARTABLE_UNITS]}; then comps=$( __get_startable_units $mode; __get_template_names $mode) compopt -o filenames elif __contains_word "$verb" ${VERBS[RESTARTABLE_UNITS]}; then comps=$( __get_restartable_units $mode; __get_template_names $mode) compopt -o filenames elif __contains_word "$verb" ${VERBS[STOPPABLE_UNITS]}; then comps=$( __filter_units_by_property $mode CanStop yes \ $( __get_active_units $mode ) ) compopt -o filenames elif __contains_word "$verb" ${VERBS[RELOADABLE_UNITS]}; then comps=$( __filter_units_by_property $mode CanReload yes \ $( __get_active_units $mode ) ) compopt -o filenames elif __contains_word "$verb" ${VERBS[ISOLATABLE_UNITS]}; then comps=$( __filter_units_by_property $mode AllowIsolate yes \ $( __get_all_units $mode ) ) compopt -o filenames elif __contains_word "$verb" ${VERBS[FAILED_UNITS]}; then comps=$( __get_failed_units $mode ) compopt -o filenames elif __contains_word "$verb" ${VERBS[MASKED_UNITS]}; then comps=$( __get_masked_units $mode ) compopt -o filenames elif __contains_word "$verb" ${VERBS[TARGET_AND_UNITS]}; then if __contains_word "$prev" ${VERBS[TARGET_AND_UNITS]} \ || __contains_word "$prev" ${OPTS[STANDALONE]}; then comps=$( __systemctl $mode list-unit-files --type target --all \ | { while read -r a b; do echo " $a"; done; } ) else comps=$( __get_all_unit_files $mode ) fi compopt -o filenames elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[NAME]}; then comps='' elif __contains_word "$verb" ${VERBS[JOBS]}; then comps=$( __systemctl $mode list-jobs | { while read -r a b; do echo " $a"; done; } ) elif __contains_word "$verb" ${VERBS[SNAPSHOTS]}; then comps=$( __systemctl $mode list-units --type snapshot --full --all \ | { while read -r a b; do echo " $a"; done; } ) elif __contains_word "$verb" ${VERBS[ENVS]}; then comps=$( __systemctl $mode show-environment \ | while read -r line; do echo " ${line%%=*}=";done ) compopt -o nospace elif __contains_word "$verb" ${VERBS[FILE]}; then comps=$( compgen -A file -- "$cur" ) compopt -o filenames elif __contains_word "$verb" ${VERBS[TARGETS]}; then comps=$( __systemctl $mode list-unit-files --type target --full --all \ | { while read -r a b; do echo " $a"; done; } ) elif __contains_word "$verb" ${VERBS[PROPERTIES]}; then if __contains_word "$prev" ${VERBS[PROPERTIES]}; then comps=$( __get_active_units $mode ) else comps=$PROPS compopt -o nospace fi fi COMPREPLY=( $(compgen -o filenames -W '$comps' -- "$cur") ) return 0 } complete -F _systemctl systemctl completions/fallocate 0000644 00000001121 14720751124 0010753 0 ustar 00 _fallocate_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-o'|'--offset'|'-l'|'--length') COMPREPLY=( $(compgen -W "bytes" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--keep-size --punch-hole --offset --length --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _fallocate_module fallocate completions/hwclock 0000644 00000001651 14720751124 0010463 0 ustar 00 _hwclock_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-f'|'--rtc'|'--adjfile') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '--date') COMPREPLY=( $(compgen -W "date" -- $cur) ) return 0 ;; '--epoch') COMPREPLY=( $(compgen -W "year" -- $cur) ) return 0 ;; '-h'|'-?'|'--help'|'-v'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--help --show --set --hctosys --systohc --systz --adjust --compare --getepoch --setepoch --predict --version --utc --localtime --rtc --directisa --badyear --date --epoch --noadjfile --adjfile --test --debug" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac return 0 } complete -F _hwclock_module hwclock completions/cal 0000644 00000000624 14720751124 0007567 0 ustar 00 _cal_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--one --three --sunday --monday --julian --year --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac return 0 } complete -F _cal_module cal completions/grub 0000644 00000026641 14720751124 0007776 0 ustar 00 # # Bash completion for grub # # Copyright (C) 2010 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # GRUB is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GRUB. If not, see <http://www.gnu.org/licenses/>. # bash completion for grub __grub_dir() { local i c=1 boot_dir for (( c=1; c <= ${#COMP_WORDS[@]}; c++ )); do i="${COMP_WORDS[c]}" case "$i" in --boot-directory) c=$((++c)) i="${COMP_WORDS[c]}" boot_dir="${i##*=}"; break ;; esac done boot_dir=${boot_dir-/boot} echo "${boot_dir%/}/grub2" } # This function generates completion reply with compgen # - arg: accepts 1, 2, 3, or 4 arguments # $1 wordlist separate by space, tab or newline # $2 (optional) prefix to add # $3 (optional) current word to complete # $4 (optional) suffix to add __grubcomp () { local cur="${COMP_WORDS[COMP_CWORD]}" if [ $# -gt 2 ]; then cur="$3" fi case "$cur" in --*=) COMPREPLY=() ;; *) local IFS=' '$'\t'$'\n' COMPREPLY=($(compgen -P "${2-}" -W "${1-}" -S "${4-}" -- "$cur")) ;; esac } # Function that return long options from the help of the command # - arg: $1 (optional) command to get the long options from __grub_get_options_from_help () { local prog if [ $# -ge 1 ]; then prog="$1" else prog="${COMP_WORDS[0]}" fi local i IFS=" "$'\t'$'\n' for i in $(LC_ALL=C $prog --help) do case $i in --*) echo "${i%=*}";; esac done } # Function that return long options from the usage of the command # - arg: $1 (optional) command to get the long options from __grub_get_options_from_usage () { local prog if [ $# -ge 1 ]; then prog="$1" else prog="${COMP_WORDS[0]}" fi local i IFS=" "$'\t'$'\n' for i in $(LC_ALL=C $prog --usage) do case $i in \[--*\]) i=${i#[} # Remove leading [ echo ${i%%?(=*)]} # Remove optional value and trailing ] ;; esac done } __grub_get_last_option () { local i for (( i=$COMP_CWORD-1; i > 0; i-- )); do if [[ "${COMP_WORDS[i]}" == -* ]]; then echo "${COMP_WORDS[i]}" break; fi done } __grub_list_menuentries () { local cur="${COMP_WORDS[COMP_CWORD]}" local config_file=$(__grub_dir)/grub.cfg if [ -f "$config_file" ];then local IFS=$'\n' COMPREPLY=( $(compgen \ -W "$( awk -F "[\"']" '/menuentry/ { print $2 }' $config_file )" \ -- "$cur" )) #'# Help emacs syntax highlighting fi } __grub_list_modules () { local grub_dir=$(__grub_dir) local IFS=$'\n' COMPREPLY=( $( compgen -f -X '!*/*.mod' -- "${grub_dir}/$cur" | { while read -r tmp; do [ -n $tmp ] && { tmp=${tmp##*/} printf '%s\n' ${tmp%.mod} } done } )) } # # grub-set-default & grub-reboot # _grub_set_entry () { local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} _split_longopt && split=true case "$prev" in --boot-directory) _filedir -d return ;; esac $split && return 0 if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a menuentry __grub_list_menuentries fi } __grub_set_default_program="grub2-set-default" have ${__grub_set_default_program} && \ complete -F _grub_set_entry -o filenames ${__grub_set_default_program} unset __grub_set_default_program __grub_reboot_program="grub2-reboot" have ${__grub_reboot_program} && \ complete -F _grub_set_entry -o filenames ${__grub_reboot_program} unset __grub_reboot_program # # grub-editenv # _grub_editenv () { local cur prev COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} case "$prev" in create|list|set|unset) COMPREPLY=( "" ) return ;; esac __grubcomp "$(__grub_get_options_from_help) create list set unset" } __grub_editenv_program="grub2-editenv" have ${__grub_editenv_program} && \ complete -F _grub_editenv -o filenames ${__grub_editenv_program} unset __grub_editenv_program # # grub-mkconfig # _grub_mkconfig () { local cur prev COMPREPLY=() cur=`_get_cword` if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else _filedir fi } __grub_mkconfig_program="grub2-mkconfig" have ${__grub_mkconfig_program} && \ complete -F _grub_mkconfig -o filenames ${__grub_mkconfig_program} unset __grub_mkconfig_program # # grub-setup # _grub_setup () { local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} _split_longopt && split=true case "$prev" in -d|--directory) _filedir -d return ;; esac $split && return 0 if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a filename _filedir fi } __grub_bios_setup_program="grub2-bios-setup" have ${__grub_bios_setup_program} && \ complete -F _grub_setup -o filenames ${__grub_bios_setup_program} unset __grub_bios_setup_program __grub_sparc64_setup_program="grub2-sparc64-setup" have ${__grub_sparc64_setup_program} && \ complete -F _grub_setup -o filenames ${__grub_sparc64_setup_program} unset __grub_sparc64_setup_program # # grub-get-kernel-settings # _grub_get_kernel_settings () { local cur COMPREPLY=() cur=`_get_cword` if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a filename _filedir fi } __grub_get_kernel_settings_program="grub2-get-kernel-settings" have ${__grub_get_kernel_settings_program} && \ complete -F _grub_get_kernel_settings -o filenames ${__grub_get_kernel_settings_program} unset __grub_get_kernel_settings_program # # grub-install # _grub_install () { local cur prev last split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} last=$(__grub_get_last_option) _split_longopt && split=true case "$prev" in --boot-directory) _filedir -d return ;; --disk-module) __grubcomp "biosdisk ata" return ;; esac $split && return 0 if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else case "$last" in --modules) __grub_list_modules return ;; esac # Default complete with a filename _filedir fi } __grub_install_program="grub2-install" have ${__grub_install_program} && \ complete -F _grub_install -o filenames ${__grub_install_program} unset __grub_install_program # # grub-mkfont # _grub_mkfont () { local cur COMPREPLY=() cur=`_get_cword` if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a filename _filedir fi } __grub_mkfont_program="grub2-mkfont" have ${__grub_mkfont_program} && \ complete -F _grub_mkfont -o filenames ${__grub_mkfont_program} unset __grub_mkfont_program # # grub-mkrescue # _grub_mkrescue () { local cur prev last COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} last=$(__grub_get_last_option) if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else case "$last" in --modules) __grub_list_modules return ;; esac # Default complete with a filename _filedir fi } __grub_mkrescue_program="grub2-mkrescue" have ${__grub_mkrescue_program} && \ complete -F _grub_mkrescue -o filenames ${__grub_mkrescue_program} unset __grub_mkrescue_program # # grub-mkimage # _grub_mkimage () { local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} _split_longopt && split=true case "$prev" in -d|--directory|-p|--prefix) _filedir -d return ;; -O|--format) # Get available format from help local prog=${COMP_WORDS[0]} __grubcomp "$(LC_ALL=C $prog --help | \ awk -F ":" '/available formats/ { print $2 }' | \ sed 's/, / /g')" return ;; esac $split && return 0 if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a filename _filedir fi } __grub_mkimage_program="grub2-mkimage" have ${__grub_mkimage_program} && \ complete -F _grub_mkimage -o filenames ${__grub_mkimage_program} unset __grub_mkimage_program # # grub-mkpasswd-pbkdf2 # _grub_mkpasswd_pbkdf2 () { local cur COMPREPLY=() cur=`_get_cword` if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a filename _filedir fi } __grub_mkpasswd_pbkdf2_program="grub2-mkpasswd-pbkdf2" have ${__grub_mkpasswd_pbkdf2_program} && \ complete -F _grub_mkpasswd_pbkdf2 -o filenames ${__grub_mkpasswd_pbkdf2_program} unset __grub_mkpasswd_pbkdf2_program # # grub-probe # _grub_probe () { local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} _split_longopt && split=true case "$prev" in -t|--target) # Get target type from help local prog=${COMP_WORDS[0]} __grubcomp "$(LC_ALL=C $prog --help | \ awk -F "[()]" '/--target=/ { print $2 }' | \ sed 's/|/ /g')" return ;; esac $split && return 0 if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a filename _filedir fi } __grub_probe_program="grub2-probe" have ${__grub_probe_program} && \ complete -F _grub_probe -o filenames ${__grub_probe_program} unset __grub_probe_program # # grub-script-check # _grub_script_check () { local cur COMPREPLY=() cur=`_get_cword` if [[ "$cur" == -* ]]; then __grubcomp "$(__grub_get_options_from_help)" else # Default complete with a filename _filedir fi } __grub_script_check_program="grub2-script-check" have ${__grub_script_check_program} && \ complete -F _grub_script_check -o filenames ${__grub_script_check_program} # Local variables: # mode: shell-script # sh-basic-offset: 4 # sh-indent-comment: t # indent-tabs-mode: nil # End: # ex: ts=4 sw=4 et filetype=sh completions/groupdel 0000644 00000000206 14720751124 0010645 0 ustar 00 # groupdel(8) completion -*- shell-script -*- complete -g groupdel # ex: ts=4 sw=4 et filetype=sh completions/kernel-install 0000644 00000003400 14720751124 0011747 0 ustar 00 # kernel-install(8) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2013 Kay Sievers # Copyright 2013 Harald Hoyer # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. _kernel_install() { local comps local MACHINE_ID local cur=${COMP_WORDS[COMP_CWORD]} case $COMP_CWORD in 1) comps="add remove" ;; 2) comps=$(cd /lib/modules; echo [0-9]*) if [[ ${COMP_WORDS[1]} == "remove" ]] && [[ -f /etc/machine-id ]]; then read MACHINE_ID < /etc/machine-id if [[ $MACHINE_ID ]] && ( [[ -d /boot/$MACHINE_ID ]] || [[ -L /boot/$MACHINE_ID ]] ); then comps=$(cd "/boot/$MACHINE_ID"; echo [0-9]*) fi fi ;; 3) [[ "$cur" ]] || cur=/boot/vmlinuz-${COMP_WORDS[2]} comps=$(compgen -f -- "$cur") compopt -o filenames ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _kernel_install kernel-install completions/fsck.minix 0000644 00000000623 14720751124 0011100 0 ustar 00 _fsck.minix_module() { local cur prev OPTS DEVS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-V'|'--version') return 0 ;; esac while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) OPTS="-l -a -r -v -s -m -f --version" COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) ) return 0 } complete -F _fsck.minix_module fsck.minix completions/mkfs.cramfs 0000644 00000001465 14720751124 0011246 0 ustar 00 _mkfs.cramfs_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-b') COMPREPLY=( $(compgen -W "blksize" -- $cur) ) return 0 ;; '-e') COMPREPLY=( $(compgen -W "edition" -- $cur) ) return 0 ;; '-N') COMPREPLY=( $(compgen -W "big little host" -- $cur) ) return 0 ;; '-i') COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-n') COMPREPLY=( $(compgen -W "name" -- $cur) ) return 0 ;; '-h'|'-V') return 0 ;; esac case $cur in -*) OPTS="-h -v -E -b -e -N -i -n -p -s -z" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _mkfs.cramfs_module mkfs.cramfs completions/lscpu 0000644 00000001475 14720751124 0010163 0 ustar 00 _lscpu_module() { local cur OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '--extended'|'=') cur=${cur#=} # FIXME: how to append to a string with compgen? OPTS="CPU, CORE, SOCKET, NODE, BOOK, CACHE, POLARIZATION, ADDRESS, CONFIGURED, ONLINE," compopt -o nospace COMPREPLY=( $(compgen -W "$OPTS" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--all --online --offline --extended= --parse= --sysroot --hex --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _lscpu_module lscpu completions/losetup 0000644 00000002740 14720751124 0010524 0 ustar 00 _losetup_module() { local cur prev OPTS ARG COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-d'|'--detach') ARG="$(losetup --output NAME | awk '{if (1 < NR) {print}}')" COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) return 0 ;; '-j'|'--associated') ARG="$(losetup --output BACK-FILE | awk '{if (1 < NR) {print}}')" COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) return 0 ;; '-c'|'--set-capacity') ARG="$(for I in /dev/loop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)" COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) return 0 ;; '-o'|'--offset'|'--sizelimit') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; '-O'|'--output') # FIXME: how to append to a string with compgen? local OUTPUT OUTPUT="NAME AUTOCLEAR BACK-FILE BACK-INO BACK-MAJ:MIN MAJ:MIN OFFSET PARTSCAN RO SIZELIMIT" compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--all --detach --detach-all --find --set-capacity --associated --list --offset --output --sizelimit --partscan --read-only --show --verbose --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _losetup_module losetup completions/addpart 0000644 00000001010 14720751124 0010435 0 ustar 00 _addpart_module() { local cur prev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" case $COMP_CWORD in 1) local DEVS='' while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) OPTS="--help --version $DEVS" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) ;; 2) # FIXME: how to determine next free partition number ;; 3) COMPREPLY=( $(compgen -W "start" -- $cur) ) ;; 4) COMPREPLY=( $(compgen -W "length" -- $cur) ) ;; esac return 0 } complete -F _addpart_module addpart completions/timedatectl 0000644 00000005024 14720751124 0011326 0 ustar 00 # timedatectl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } _timedatectl() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --adjust-system-clock --no-pager --no-ask-password -H --host --machine' if __contains_word "$prev" $OPTS; then case $prev in --host|-H) comps='' ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi local -A VERBS=( [BOOLEAN]='set-local-rtc set-ntp' [STANDALONE]='status set-time list-timezones' [TIMEZONES]='set-timezone' [TIME]='set-time' ) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[BOOLEAN]}; then comps='true false' elif __contains_word "$verb" ${VERBS[TIMEZONES]}; then comps=$(command timedatectl list-timezones) elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[TIME]}; then comps='' fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _timedatectl timedatectl completions/gsettings 0000644 00000005415 14720751124 0011042 0 ustar 00 # Check for bash [ -z "$BASH_VERSION" ] && return #################################################################################################### __gsettings() { local choices coffset schemadir if [ ${COMP_CWORD} -gt 2 ]; then if [ ${COMP_WORDS[1]} = --schemadir ]; then # this complexity is needed to perform correct tilde expansion schemadir=$(eval "echo --schemadir ${COMP_WORDS[2]}") coffset=2 else coffset=0 fi else coffset=0 fi case "$((${COMP_CWORD}-$coffset))" in 1) choices=$'--schemadir\n--version\nhelp \nlist-schemas\nlist-relocatable-schemas\nlist-keys \nlist-children \nlist-recursively \nget \nrange \nset \nreset \nreset-recursively \nwritable \nmonitor \ndescribe ' ;; 2) case "${COMP_WORDS[$(($coffset+1))]}" in --schemadir) COMPREPLY=($(compgen -o dirnames -- ${COMP_WORDS[${COMP_CWORD}]})) return 0 ;; help) choices=$'list-schemas\nlist-relocatable-schemas\nlist-keys\nlist-children\nlist-recursively\nget\nrange\nset\nreset\nreset-recursively\nwritable\nmonitor' ;; list-keys|list-children|list-recursively|reset-recursively) choices="$(gsettings $schemadir list-schemas 2> /dev/null)"$'\n'"$(gsettings $schemadir list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')" ;; list-schemas) COMPREPLY=($(compgen -W "--print-paths" -- ${COMP_WORDS[${COMP_CWORD}]})) return 0 ;; get|range|set|reset|writable|monitor|describe) choices="$(gsettings $schemadir list-schemas 2> /dev/null | sed -e 's.$. .')"$'\n'"$(gsettings $schemadir list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')" ;; esac ;; 3) case "${COMP_WORDS[$(($coffset+1))]}" in set) choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null | sed -e 's.$. .')" ;; get|range|reset|writable|monitor|describe) choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null)" ;; esac ;; 4) case "${COMP_WORDS[$(($coffset+2))]}" in set) range=($(gsettings $schemadir range ${COMP_WORDS[$(($coffset+2))]} ${COMP_WORDS[$(($coffset+3))]} 2> /dev/null)) case "${range[0]}" in enum) unset range[0] ;; *) unset range ;; esac local IFS=$'\n' choices="${range[*]}" ;; esac ;; esac local IFS=$'\n' COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}")) } #################################################################################################### complete -o nospace -F __gsettings gsettings completions/prlimit 0000644 00000002244 14720751124 0010510 0 ustar 00 _prlimit_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-p'|'--pid') PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; '-o'|'--output') # FIXME: how to append to a string with compgen? local OUTPUT OUTPUT="DESCRIPTION RESOURCE SOFT HARD UNITS" compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in '=') cur=${cur#=} # FIXME: is there anything what could be printed # as limit value(s) ;; -*) OPTS="--pid --output --noheadings --raw --verbose --help --version --core= --data= --nice= --fsize= --sigpending= --memlock= --rss= --nofile= --msgqueue= --rtprio= --stack= --cpu= --nproc= --as= --locks= --rttime=" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 } complete -F _prlimit_module prlimit completions/mdadm 0000644 00000010645 14720751124 0010116 0 ustar 00 # bash completion for mdadm -*- shell-script -*- _mdadm_raid_level() { local mode for (( i=1; i < cword; i++ )); do case ${words[i]} in -C|--create) mode=create break ;; -B|--build) mode=build break ;; esac done case $mode in create) COMPREPLY=( $( compgen -W 'linear raid0 0 stripe raid1 1 mirror raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' \ -- "$cur" ) ) ;; build) COMPREPLY=( $( compgen -W 'linear stripe raid0 0 raid1 multipath mp faulty' -- "$cur" ) ) ;; esac } _mdadm_raid_layout() { local level for (( i=1; i < cword; i++ )); do if [[ "${words[i]}" == -@(l|-level) ]]; then level=${words[i+1]} break fi done case $level in raid5) COMPREPLY=( $( compgen -W 'left-asymmetric left-symmetric right-asymmetric right-symmetric la ra ls rs' -- "$cur" ) ) ;; raid10) COMPREPLY=( $( compgen -W 'n o p' -- "$cur" ) ) ;; faulty) COMPREPLY=( $( compgen -W 'write-transient wt read-transient rt write-persistent wp read-persistent rp write-all read-fixable rf clear flush none' -- "$cur" ) ) ;; esac } _mdadm_auto_flag() { COMPREPLY=( $( compgen -W 'no yes md mdp part p' -- "$cur" ) ) } _mdadm_update_flag() { COMPREPLY=( $( compgen -W 'sparc2.2 summaries uuid name homehost resync byteorder super-minor' -- "$cur" ) ) } _mdadm() { local cur prev words cword split _init_completion -s || return case $prev in -c|--config|-b|--bitmap|--backup-file) _filedir return 0 ;; -l|--level) _mdadm_raid_level return 0 ;; -p|--layout|--parity) _mdadm_raid_layout return 0 ;; -a|--auto) _mdadm_auto_flag return 0 ;; -U|--update) _mdadm_update_flag return 0 ;; esac $split && return 0 local options='--help --help-options --version --verbose --quiet --brief --force --config= --scan --metadata= --homehost=' if [[ "$cur" == -* ]]; then if [[ $cword -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$options --assemble --build --create --monitor --grow" -- "$cur" ) ) else case ${words[cword-1]} in -A|--assemble) COMPREPLY=( $( compgen -W "$options --uuid= --super-minor= --name= --force --run --no-degraded --auto= --bitmap= --backup-file= --update= --auto-update-homehost" \ -- "$cur" ) ) ;; -B|-C|-G|--build|--create|--grow) COMPREPLY=( $( compgen -W "$options --raid-devices= --spare-devices= --size= --chunk= --rounding= --level= --layout= --parity= --bitmap= --bitmap-chunk= --write-mostly --write-behind= --assume-clean --backup-file= --name= --run --force --auto=" \ -- "$cur" ) ) ;; -F|--follow|--monitor) COMPREPLY=( $( compgen -W "$options --mail --program --alert --syslog --delay --daemonise --pid-file --oneshot --test" -- "$cur" ) ) ;; /dev/*|--add|--fail|--remove) COMPREPLY=( $( compgen -W "$options --add --re-add --remove --fail --set-faulty" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$options --query --detail --examine --sparc2.2 --examine-bitmap --run --stop --readonly --readwrite --zero-superblock --test" \ -- "$cur" ) ) ;; esac fi [[ $COMPREPLY == *= ]] && compopt -o nospace else cur=${cur:=/dev/} _filedir fi } && complete -F _mdadm mdadm # ex: ts=4 sw=4 et filetype=sh completions/ipcrm 0000644 00000002617 14720751124 0010146 0 ustar 00 _ipcrm_module() { local cur prev OPTS KEYIDS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-m'|'--shmem-id') KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $2}}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-M'|'--shmem-key') KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $1}}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-q'|'--queue-id') KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $2}}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-Q'|'--queue-key') KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $1}}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-s'|'--semaphore-id') KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $2}}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-S'|'--semaphore-key') KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $1}}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in '=') cur=${cur#=} COMPREPLY=( $(compgen -W "shm msg sem" -- $cur) ) return 0 ;; esac OPTS=" --shmem-id --shmem-key --queue-id --queue-key --semaphore-id --semaphore-key --all= --verbose --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _ipcrm_module ipcrm completions/hostnamectl 0000644 00000004245 14720751124 0011354 0 ustar 00 # hostnamectl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2010 Ran Benita # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } _hostnamectl() { local i verb comps local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local OPTS='-h --help --version --transient --static --pretty --no-ask-password -H --host --machine' if [[ $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi local -A VERBS=( [STANDALONE]='status' [ICONS]='set-icon-name' [NAME]='set-hostname set-deployment' [CHASSIS]='set-chassis' ) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then verb=${COMP_WORDS[i]} break fi done if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[CHASSIS]}; then comps='desktop laptop server tablet handset watch embedded vm container' elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[ICONS]} ${VERBS[NAME]}; then comps='' fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _hostnamectl hostnamectl completions/semanage 0000644 00000014651 14720751124 0010615 0 ustar 00 # This file is part of systemd. # # Copyright 2011-2013 Dan Walsh # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local word=$1; shift for w in $*; do [[ $w = $word ]] && return 0; done return 1 } ALL_OPTS='-l --list -S -o -n --noheading -h --help' MANAGED_OPTS='-a --add -m --modify -d --delete -D --deleteall -C --locallist ' __get_all_stores () { dir -1 -F /etc/selinux/ | grep '/' | cut -d'/' -f 1 } __get_all_ftypes () { echo '-- -d -c -b -s -l -p' } __get_all_users () { seinfo -u 2> /dev/null | tail -n +3 } __get_all_types () { seinfo -t 2> /dev/null | tail -n +3 } __get_all_port_types () { seinfo -aport_type -x 2>/dev/null | tail -n +2 } __get_all_domains () { seinfo -adomain -x 2>/dev/null | tail -n +2 } __get_all_node_types () { seinfo -anode_type -x 2>/dev/null | tail -n +2 } __get_all_file_types () { seinfo -afile_type -x 2>/dev/null | tail -n +2 } __get_all_roles () { seinfo -r 2> /dev/null | tail -n +3 } __get_all_stores () { dir -1 -F /etc/selinux/ | grep '/' | cut -d'/' -f 1 } __get_import_opts () { echo '$ALL_OPTS --f --input_file' ; } __get_export_opts () { echo '$ALL_OPTS --f --output_file' ; } __get_boolean_opts () { echo '$ALL_OPTS --on -off -1 -0' ; } __get_user_opts () { echo '$ALL_OPTS $MANAGED_OPTS -L --level -r --range -R --role '; } __get_login_opts () { echo '$ALL_OPTS $MANAGED_OPTS -s --seuser -r --range'; } __get_port_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t -type -r --range -p --proto'; } __get_interface_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t --type '; } __get_node_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t --type -M --mask -p --proto'; } __get_fcontext_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t --type -e --equal -f --ftype '; } __get_module_opts () { echo '$ALL_OPTS $MANAGED_OPTS --enable --disable '; } __get_dontaudit_opts () { echo '-S on off' ; } __get_permissive_opts () { echo '$ALL_OPTS -a --add -d --delete' ; } _semanage () { local command=${COMP_WORDS[1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local verb comps local -A VERBS=( [BOOLEAN]='boolean' [DONTAUDIT]='dontaudit' [EXPORT]='export' [FCONTEXT]='fcontext' [IMPORT]='import' [INTERFACE]='interface' [LOGIN]='login' [MODULE]='module' [NODE]='node' [PERMISSIVE]='permissive' [PORT]='port' [USER]='user' ) if [ "$prev" = "-a" -a "$command" = "permissive" ]; then COMPREPLY=( $(compgen -W "$( __get_all_domains ) " -- "$cur") ) return 0 fi if [ "$verb" = "" -a "$prev" = "semanage" ]; then comps="${VERBS[*]}" elif [ "$verb" = "" -a "$prev" = "-S" -o "$prev" = "--store" ]; then COMPREPLY=( $(compgen -W "$( __get_all_stores ) " -- "$cur") ) return 0 elif [ "$verb" = "" -a "$prev" = "-p" -o "$prev" = "--proto" ]; then COMPREPLY=( $(compgen -W "tcp udp" -- "$cur") ) return 0 elif [ "$verb" = "" -a "$prev" = "-R" -o "$prev" = "-r" -o "$prev" = "--role" ]; then if [ "$command" != "user" -o "$prev" != "-r" ]; then COMPREPLY=( $(compgen -W "$( __get_all_roles ) " -- "$cur") ) return 0 else return 0 fi elif [ "$verb" = "" -a "$prev" = "-s" -o "$prev" = "--seuser" ]; then COMPREPLY=( $(compgen -W "$( __get_all_users ) " -- "$cur") ) return 0 elif [ "$verb" = "" -a "$prev" = "-f" -o "$prev" = "--ftype" ]; then COMPREPLY=( $(compgen -W "$( __get_all_ftypes ) " -- "$cur") ) return 0 elif [ "$verb" = "" -a "$prev" = "-t" -o "$prev" = "--types" ]; then if [ "$command" = "port" ]; then COMPREPLY=( $(compgen -W "$( __get_all_port_types ) " -- "$cur") ) return 0 fi if [ "$command" = "fcontext" ]; then COMPREPLY=( $(compgen -W "$( __get_all_file_types ) " -- "$cur") ) return 0 fi COMPREPLY=( $(compgen -W "$( __get_all_types ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[LOGIN]} ; then COMPREPLY=( $(compgen -W "$( __get_login_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[USER]} ; then COMPREPLY=( $(compgen -W "$( __get_user_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[PORT]} ; then COMPREPLY=( $(compgen -W "$( __get_port_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[INTERFACE]} ; then COMPREPLY=( $(compgen -W "$( __get_interface_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[MODULE]} ; then COMPREPLY=( $(compgen -W "$( __get_module_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[NODE]} ; then COMPREPLY=( $(compgen -W "$( __get_node_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[FCONTEXT]} ; then COMPREPLY=( $(compgen -W "$( __get_fcontext_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[BOOLEAN]} ; then COMPREPLY=( $(compgen -W "$( __get_boolean_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[PERMISSIVE]} ; then COMPREPLY=( $(compgen -W "$( __get_permissive_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[DONTAUDIT]} ; then COMPREPLY=( $(compgen -W "$( __get_dontaudit_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[IMPORT]} ; then COMPREPLY=( $(compgen -W "$( __get_import_opts ) " -- "$cur") ) return 0 elif __contains_word "$command" ${VERBS[EXPORT]} ; then COMPREPLY=( $(compgen -W "$( __get_export_opts ) " -- "$cur") ) return 0 fi COMPREPLY=( $(compgen -W "$comps" -- "$cur") ) return 0 } complete -F _semanage semanage completions/swapon 0000644 00000002505 14720751124 0010337 0 ustar 00 _swapon_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-p'|'--priority') # Priority range is -1 to 32767. Perhaps these # few are enough. COMPREPLY=( $(compgen -W "{-1..9} 32767" -- $cur) ) return 0 ;; '--show') # FIXME: how to append to a string with compgen? local OUTPUT OUTPUT="NAME TYPE SIZE USED PRIO" compopt -o nospace COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) return 0 ;; '-U') local UUIDS UUIDS="$(lsblk -nrp -o FSTYPE,UUID | awk '$1 ~ /swap/ { print $2 }')" COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) ) return 0 ;; '-L') local LABELS LABELS="$(lsblk -nrp -o FSTYPE,LABEL | awk '$1 ~ /swap/ { print $2 }')" COMPREPLY=( $(compgen -W "$LABELS" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--all --discard --ifexists --fixpgsz --priority --summary --show --noheadings --raw --bytes --verbose --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEVS DEVS="$(lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }')" COMPREPLY=( $(compgen -W "$DEVS" -- $cur) ) return 0 } complete -F _swapon_module swapon completions/ip 0000644 00000023046 14720751124 0007443 0 ustar 00 # ip(8) completion -*- shell-script -*- _iproute2_etc() { COMPREPLY+=( $( compgen -W \ "$( awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null )" \ -- "$cur" ) ) } _ip() { local cur prev words cword _init_completion || return case $prev in -V|-Version|-rc|-rcvbuf) return 0 ;; -f|-family) COMPREPLY=( $( compgen -W 'inet inet6 ipx dnet link' -- "$cur" ) ) return 0 ;; -b|-batch) _filedir return 0 ;; -force) COMPREPLY=( $( compgen -W '-batch' -- "$cur" ) ) return 0 ;; esac local subcword cmd subcmd for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do [[ ${words[subcword]} == -b?(atch) ]] && return 0 [[ -n $cmd ]] && subcmd=${words[subcword]} && break [[ ${words[subcword]} != -* && \ ${words[subcword-1]} != -@(f?(amily)|rc?(vbuf)) ]] && \ cmd=${words[subcword]} done if [[ -z $cmd ]]; then case $cur in -*) local c="-Version -statistics -details -resolve -family -oneline -timestamp -batch -rcvbuf" [[ $cword -eq 1 ]] && c+=" -force" COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) return 0 ;; *) COMPREPLY=( $( compgen -W "help $( ip help 2>&1 | \ sed -e '/OBJECT := /,/}/!d' \ -e 's/.*{//' -e 's/}.*//' -e 's/|//g' )" -- "$cur" ) ) return 0 ;; esac fi [[ $subcmd == help ]] && return 0 case $cmd in link) case $subcmd in add) # TODO ;; delete) case $(($cword-$subcword)) in 1) _available_interfaces ;; 2) COMPREPLY=( $( compgen -W 'type' -- "$cur" ) ) ;; 3) [[ $prev == type ]] && \ COMPREPLY=( $( compgen -W 'vlan veth vcan dummy ifb macvlan can' -- "$cur" ) ) ;; esac ;; set) if [[ $cword-$subcword -eq 1 ]]; then _available_interfaces else case $prev in arp|dynamic|multicast|allmulticast|promisc|\ trailers) COMPREPLY=( $( compgen -W 'on off' \ -- "$cur" ) ) ;; txqueuelen|name|address|broadcast|mtu|netns|alias) ;; *) local c="arp dynamic multicast allmulticast promisc trailers txqueuelen name address broadcast mtu netns alias" [[ $prev != @(up|down) ]] && c+=" up down" COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) ;; esac fi ;; show) if [[ $cword -eq $subcword+1 ]]; then _available_interfaces COMPREPLY+=( $( compgen -W 'dev group up' -- "$cur" ) ) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == group ]]; then _iproute2_etc group fi ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add delete set show' \ -- "$cur" ) ) ;; esac ;; addr) case $subcmd in add|change|replace) # TODO ;; del) # TODO ;; show|flush) if [[ $cword -eq $subcword+1 ]]; then _available_interfaces COMPREPLY+=( $( compgen -W 'dev scope to label dynamic permanent tentative deprecated dadfailed temporary primary secondary up' -- "$cur" ) ) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == scope ]]; then _iproute2_etc rt_scopes fi ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add change replace del show flush' -- "$cur" ) ) ;; esac ;; addrlabel) case $subcmd in list|add|del|flush) # TODO ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help list add del flush' \ -- "$cur" ) ) ;; esac ;; route) case $subcmd in list|flush) # TODO ;; get) # TODO ;; add|del|change|append|replace|monitor) # TODO ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help list flush get add del change append replace monitor' -- "$cur" ) ) ;; esac ;; rule) case $subcmd in add|del) # TODO ;; flush|show|list|lst) ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help list add del flush' \ -- "$cur" ) ) ;; esac ;; neigh) case $subcmd in add|del|change|replace) # TODO ;; show|flush) # TODO ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add del change replace show flush' -- "$cur" ) ) ;; esac ;; ntable) case $subcmd in change) # TODO ;; show) # TODO ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help change show' \ -- "$cur" ) ) ;; esac ;; tunnel) case $subcmd in show) ;; add|change|del|prl|6rd) # TODO ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add change del show prl 6rd' -- "$cur" ) ) ;; esac ;; maddr) case $subcmd in add|del) # TODO ;; show) if [[ $cword -eq $subcword+1 || $prev == dev ]]; then _available_interfaces [[ $prev != dev ]] && \ COMPREPLY=( $( compgen -W '${COMPREPLY[@]} dev' \ -- "$cur" ) ) fi ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help add del show' \ -- "$cur" ) ) ;; esac ;; mroute) case $subcmd in show) # TODO ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help show' -- "$cur" ) ) ;; esac ;; monitor) case $subcmd in all) ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'help all' -- "$cur" ) ) ;; esac ;; xfrm) case $subcmd in state|policy|monitor) # TODO ;; *) [[ $cword -eq $subcword ]] && \ COMPREPLY=( $( compgen -W 'state policy monitor' \ -- "$cur" ) ) ;; esac ;; esac } && complete -F _ip ip # ex: ts=4 sw=4 et filetype=sh completions/taskset 0000644 00000002073 14720751124 0010506 0 ustar 00 _taskset_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-c'|'--cpu-list') local CPULIST # FIXME: will propose only binding to a cpu. # Maybe this should add comma, and continue? CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online) COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) ) return 0 ;; '-p'|'--pid') local PIDS # FIXME: the pid argument is ambiguous. When # setting an affinity the optarg has to be cpu # mask. The following is good only for getting # affinity. PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done) COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--all-tasks --pid --cpu-list --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 } complete -F _taskset_module taskset completions/busctl 0000644 00000017044 14720751124 0010330 0 ustar 00 # busctl(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2013 Zbigniew Jędrzejewski-Szmek # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word () { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __get_machines() { local a b machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } __get_busnames() { local mode=$1 local a b busctl $mode list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } __get_objects() { local mode=$1 local busname=$2 local a b busctl $mode tree --list --no-legend --no-pager $busname | { while read a b; do echo " $a"; done; }; } __get_interfaces() { local mode=$1 local busname=$2 local path=$3 local a b busctl $mode introspect --list --no-legend --no-pager $busname $path | { while read a b c; do [[ "$b" == "interface" ]] && echo " $a"; done; }; } __get_members() { local mode=$1 local busname=$2 local path=$3 local interface=$4 local type=$5 local a b busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c; do [[ "$b" == "$type" ]] && echo " $a"; done; }; } __get_signature() { local mode=$1 local busname=$2 local path=$3 local interface=$4 local member=$5 local a b busctl $mode introspect --list --no-legend --no-pager $busname $path $interface | sed -e 's/^\.//' | { while read a b c d; do [[ "$a" == "$member" ]] && echo " \"$c\""; done; }; } _busctl() { local i verb comps mode local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-h --help --version --no-pager --no-legend --system --show-machine --unique --acquired --activatable --list --quiet --verbose --expect-reply=no --auto-start=no --allow-interactive-authorization=yes --augment-creds=no' [ARG]='-H --host -M --machine --address --match --timeout' ) if __contains_word "--user" ${COMP_WORDS[*]}; then mode=--user else mode=--system fi if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --host|-H) comps=$(compgen -A hostname) ;; --machine|-M) comps=$( __get_machines ) esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ "$cur" = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi local -A VERBS=( [STANDALONE]='list help' [BUSNAME]='status monitor capture tree' [OBJECT]='introspect' [METHOD]='call' [PROPERTY_GET]='get-property' [PROPERTY_SET]='set-property' ) for ((i=0; i < COMP_CWORD; i++)); do if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then verb=${COMP_WORDS[i]} break fi done n=$(($COMP_CWORD - $i)) if [[ -z $verb ]]; then comps=${VERBS[*]} elif __contains_word "$verb" ${VERBS[STANDALONE]}; then comps='' elif __contains_word "$verb" ${VERBS[BUSNAME]}; then comps=$( __get_busnames $mode) elif __contains_word "$verb" ${VERBS[OBJECT]}; then if [[ $n -eq 1 ]] ; then comps=$( __get_busnames $mode) elif [[ $n -eq 2 ]] ; then comps=$( __get_objects $mode ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 3 ]] ; then comps=$( __get_interfaces $mode ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) else comps='' fi elif __contains_word "$verb" ${VERBS[METHOD]}; then if [[ $n -eq 1 ]] ; then comps=$( __get_busnames $mode) elif [[ $n -eq 2 ]] ; then comps=$( __get_objects $mode ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 3 ]] ; then comps=$( __get_interfaces $mode ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 4 ]] ; then comps=$( __get_members $mode ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]} method) elif [[ $n -eq 5 ]] ; then comps=$( __get_signature $mode ${COMP_WORDS[COMP_CWORD-4]} ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) else comps='' fi elif __contains_word "$verb" ${VERBS[PROPERTY_GET]}; then if [[ $n -eq 1 ]] ; then comps=$( __get_busnames $mode) elif [[ $n -eq 2 ]] ; then comps=$( __get_objects $mode ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 3 ]] ; then comps=$( __get_interfaces $mode ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 4 ]] ; then comps=$( __get_members $mode ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]} property) else comps='' fi elif __contains_word "$verb" ${VERBS[PROPERTY_SET]}; then if [[ $n -eq 1 ]] ; then comps=$( __get_busnames $mode) elif [[ $n -eq 2 ]] ; then comps=$( __get_objects $mode ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 3 ]] ; then comps=$( __get_interfaces $mode ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) elif [[ $n -eq 4 ]] ; then comps=$( __get_members $mode ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]} property) elif [[ $n -eq 5 ]] ; then comps=$( __get_signature $mode ${COMP_WORDS[COMP_CWORD-4]} ${COMP_WORDS[COMP_CWORD-3]} ${COMP_WORDS[COMP_CWORD-2]} ${COMP_WORDS[COMP_CWORD-1]}) else comps='' fi fi COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 } complete -F _busctl busctl completions/wipefs 0000644 00000001370 14720751124 0010324 0 ustar 00 _wipefs_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-o'|'--offset') COMPREPLY=( $(compgen -W "offset" -- $cur) ) return 0 ;; '-t'|'--types') local TYPES TYPES="$(blkid -k)" COMPREPLY=( $(compgen -W "$TYPES" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--all --force --help --no-act --offset --parsable --quiet --types --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEVS DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) COMPREPLY=( $(compgen -W "$DEVS" -- $cur) ) return 0 } complete -F _wipefs_module wipefs completions/utmpdump 0000644 00000000722 14720751124 0010702 0 ustar 00 _utmpdump_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--follow --reverse --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _utmpdump_module utmpdump completions/tcpdump 0000644 00000002016 14720751124 0010501 0 ustar 00 # bash completion for tcpdump -*- shell-script -*- _tcpdump() { local cur prev words cword _init_completion || return case $prev in -r|-w|-F) _filedir return 0 ;; -i) _available_interfaces -a return 0 ;; -m) _filedir mib return 0 ;; -T) COMPREPLY=( $( compgen -W 'aodv cnfp rpc rtp rtcp snmp tftp vat wb' -- "$cur" ) ) return 0 ;; -z) compopt -o filenames COMPREPLY=( $( compgen -c -- "$cur" ) ) return 0 ;; -Z) _allowed_users return 0 ;; -B|-c|-C|-D|-E|-G|-M|-s|-W|-y) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) fi } && complete -F _tcpdump tcpdump # ex: ts=4 sw=4 et filetype=sh completions/usermod 0000644 00000002457 14720751124 0010514 0 ustar 00 # usermod(8) completion -*- shell-script -*- _usermod() { local cur prev words cword split _init_completion -s || return # TODO: if -o/--non-unique is given, could complete on existing uids # with -u/--uid case $prev in -c|--comment|-d|--home|-e|--expiredate|-f|--inactive|-h|--help|\ -l|--login|-p|--password|-u|--uid|-Z|--selinux-user) return 0 ;; -g|--gid) _gids COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \ -- "$cur" ) ) return 0 ;; -G|--groups) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) return 0 ;; -R|--root) _filedir -d return 0 ;; -s|--shell) _shells return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then # TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) return 0 fi COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _usermod usermod # ex: ts=4 sw=4 et filetype=sh completions/isosize 0000644 00000000652 14720751124 0010516 0 ustar 00 _isosize_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-d'|'--divisor') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS='--divisor --sectors --help --version' COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _isosize_module isosize completions/useradd 0000644 00000002323 14720751124 0010455 0 ustar 00 # useradd(8) completion -*- shell-script -*- _useradd() { local cur prev words cword split _init_completion -s || return # TODO: if -o/--non-unique is given, could complete on existing uids # with -u/--uid case $prev in -c|--comment|-h|--help|-e|--expiredate|-f|--inactive|-K|--key|\ -p|--password|-u|--uid|-Z|--selinux-user) return 0 ;; -b|--base-dir|-d|--home-dir|-k|--skel|-R|--root) _filedir -d return 0 ;; -g|--gid) _gids COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \ -- "$cur" ) ) return 0 ;; -G|--groups) local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," COMPREPLY=( $( compgen -P "$prefix" -g -- "${cur##*,}" ) ) return 0 ;; -s|--shell) _shells return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) return 0 fi } && complete -F _useradd useradd # ex: ts=4 sw=4 et filetype=sh completions/col 0000644 00000000714 14720751124 0007605 0 ustar 00 _col_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-l'|'--lines') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; '-H'|'--help'|'-V'|'--version') return 0 ;; esac OPTS="--no-backspaces --fine --pass --tabs --spaces --lines --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _col_module col completions/systemd-cgls 0000644 00000003400 14720751124 0011441 0 ustar 00 # systemd-cgls(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word() { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __get_machines() { local a b machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } _systemd_cgls() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps local -A OPTS=( [STANDALONE]='-h --help --version --all -l --full -k --no-pager' [ARG]='-M --machine' ) _init_completion || return if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --machine|-M) comps=$( __get_machines ) ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) } complete -F _systemd_cgls systemd-cgls completions/rtcwake 0000644 00000001511 14720751124 0010464 0 ustar 00 _rtcwake_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-d'|'--device') local RTC_DEVS RTC_DEVS=$(cd /sys/class/rtc/ && echo *) COMPREPLY=( $(compgen -W "$RTC_DEVS" -- $cur) ) return 0 ;; '-m'|'--mode') COMPREPLY=( $(compgen -W "standby mem disk off no on disable show" -- $cur) ) return 0 ;; '-s'|'--seconds') COMPREPLY=( $(compgen -W "seconds" -- $cur) ) return 0 ;; '-t'|'--time') COMPREPLY=( $(compgen -W "time_t" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS="--device --dry-run --local --mode --seconds --time --utc --verbose --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _rtcwake_module rtcwake completions/script 0000644 00000001233 14720751124 0010331 0 ustar 00 _script_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-c'|'--command') compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in '=') cur=${cur#=} ;; -*) OPTS="--append --command --return --flush --force --quiet --timing= --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 } complete -F _script_module script completions/fsck.cramfs 0000644 00000000774 14720751124 0011236 0 ustar 00 _fsck.cramfs_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-x'|'--destination') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac OPTS='--verbose --destination --help --version file' COMPREPLY=( $(compgen -W "${OPTS[*]}" -S ' ' -- $cur) ) return 0 } complete -F _fsck.cramfs_module fsck.cramfs completions/find 0000644 00000007612 14720751124 0007754 0 ustar 00 # bash completion for GNU find -*- shell-script -*- # This makes heavy use of ksh style extended globs and contains Linux specific # code for completing the parameter to the -fstype option. _find() { local cur prev words cword _init_completion || return case $prev in -maxdepth|-mindepth) COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) ) return 0 ;; -newer|-anewer|-cnewer|-fls|-fprint|-fprint0|-fprintf|-name|-iname|\ -lname|-ilname|-wholename|-iwholename|-samefile) _filedir return 0 ;; -fstype) _fstypes [[ $OSTYPE == *bsd* ]] && \ COMPREPLY+=( $( compgen -W 'local rdonly' -- "$cur" ) ) return 0 ;; -gid) _gids return 0 ;; -group) COMPREPLY=( $( compgen -g -- "$cur" 2>/dev/null) ) return 0 ;; -xtype|-type) COMPREPLY=( $( compgen -W 'b c d p f l s' -- "$cur" ) ) return 0 ;; -uid) _uids return 0 ;; -user) COMPREPLY=( $( compgen -u -- "$cur" ) ) return 0 ;; -exec|-execdir|-ok|-okdir) words=(words[0] "$cur") cword=1 _command return 0 ;; -[acm]min|-[acm]time|-iname|-lname|-wholename|-iwholename|-lwholename|\ -ilwholename|-inum|-path|-ipath|-regex|-iregex|-links|-perm|-size|\ -used|-printf|-context) # do nothing, just wait for a parameter to be given return 0 ;; -regextype) COMPREPLY=( $( compgen -W 'emacs posix-awk posix-basic posix-egrep posix-extended' -- "$cur" ) ) return 0 ;; esac _expand || return 0 local i exprfound=false # set exprfound to true if there is already an expression present for i in ${words[@]}; do [[ "$i" = [-\(\),\!]* ]] && exprfound=true && break done # handle case where first parameter is not a dash option if ! $exprfound && [[ "$cur" != [-\(\),\!]* ]]; then _filedir -d return 0 fi # complete using basic options COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -ignore_readdir_race -maxdepth -mindepth -mindepth -mount -noignore_readdir_race -noleaf -regextype -version -warn -nowarn -xdev -amin -anewer -atime -cmin -cnewer -ctime -empty -executable -false -fstype -gid -group -ilname -iname -inum -ipath -iregex -iwholename -links -lname -mmin -mtime -name -newer -nogroup -nouser -path -perm -readable -regex -samefile -size -true -type -uid -used -user -wholename -writable -xtype -context -delete -exec -execdir -fls -fprint -fprint0 -fprintf -ls -ok -okdir -print -print0 -printf -prune -quit' -- "$cur" ) ) if [[ ${#COMPREPLY[@]} -ne 0 ]]; then # this removes any options from the list of completions that have # already been specified somewhere on the command line, as long as # these options can only be used once (in a word, "options", in # opposition to "tests" and "actions", as in the find(1) manpage). local -A onlyonce=( [-daystart]=1 [-depth]=1 [-follow]=1 [-help]=1 [-ignore_readdir_race]=1 [-maxdepth]=1 [-mindepth]=1 [-mount]=1 [-noignore_readdir_race]=1 [-noleaf]=1 [-nowarn]=1 [-regextype]=1 [-version]=1 [-warn]=1 [-xdev]=1 ) local j for i in "${words[@]}"; do [[ $i && ${onlyonce[$i]} ]] || continue for j in ${!COMPREPLY[@]}; do [[ ${COMPREPLY[j]} == $i ]] && unset COMPREPLY[j] done done fi _filedir return 0 } && complete -F _find find # ex: ts=4 sw=4 et filetype=sh completions/umount 0000644 00000001015 14720751124 0010352 0 ustar 00 # umount(8) completion -*- shell-script -*- if [[ $OSTYPE == *linux* ]]; then . "$BASH_SOURCE.linux" return fi # umount(8) completion. This relies on the mount point being the third # space-delimited field in the output of mount(8) # _umount() { local cur prev words cword _init_completion || return local IFS=$'\n' COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) ) } && complete -F _umount -o dirnames umount # ex: ts=4 sw=4 et filetype=sh completions/colrm 0000644 00000000775 14720751124 0010153 0 ustar 00 _colrm_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac case $COMP_CWORD in 1) COMPREPLY=( $(compgen -W "startcol" -- $cur) ) ;; 2) COMPREPLY=( $(compgen -W "endcol" -- $cur) ) ;; esac return 0 } complete -F _colrm_module colrm completions/chfn 0000644 00000000675 14720751124 0007754 0 ustar 00 _chfn_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-u'|'--help'|'-v'|'--version') return 0 ;; esac case $cur in -*) OPTS="--full-name --office --office-phone --home-phone --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac COMPREPLY=( $(compgen -u -- $cur) ) return 0 } complete -F _chfn_module chfn completions/chage 0000644 00000001127 14720751124 0010076 0 ustar 00 # chage(1) completion -*- shell-script -*- _chage() { local cur prev words cword split _init_completion -s || return case $prev in -d|--lastday|-E|--expiredate|-h|--help|-I|--inactive|-m|--mindays|\ -M|--maxdays|-W|--warndays) return 0 ;; esac $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) return 0 fi COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _chage chage # ex: ts=4 sw=4 et filetype=sh completions/userdel 0000644 00000001052 14720751124 0010467 0 ustar 00 # userdel(8) completion -*- shell-script -*- _userdel() { local cur prev words cword _init_completion || return case $prev in -h|--help) return ;; -R|--root) _filedir -d return ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) return 0 fi COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _userdel userdel # ex: ts=4 sw=4 et filetype=sh completions/blockdev 0000644 00000001371 14720751124 0010621 0 ustar 00 _blockdev_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name) OPTS="-h -V -q --report --getsz --setro --setrw --getro --getdiscardzeroes --getss --getpbsz --getiomin --getioopt --getalignoff --getmaxsect --getbsz --setbsz --getsize64 --setra --getra --setfra --getfra --flushbufs --rereadpt $DEVS" case $prev in '--setbsz') COMPREPLY=( $(compgen -W "bytes" -- $cur) ) return 0 ;; '--setbsz'|'--setfra') COMPREPLY=( $(compgen -W "sectors" -- $cur) ) return 0 ;; esac COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 } complete -F _blockdev_module blockdev completions/passwd 0000644 00000001002 14720751124 0010320 0 ustar 00 # passwd(1) completion -*- shell-script -*- _passwd() { local cur prev words cword _init_completion || return case $prev in -n|--minimum|-x|--maximum|-w|--warning|-i|--inactive|-\?|--help|--usage) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) return 0 fi _allowed_users } && complete -F _passwd passwd # ex: ts=4 sw=4 et filetype=sh completions/delpart 0000644 00000001211 14720751124 0010454 0 ustar 00 _delpart_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $COMP_CWORD in 1) local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'disk' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) OPTS="--help --version $DEVICES" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) ;; 2) prev="${COMP_WORDS[COMP_CWORD-1]}" COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) ) ;; esac return 0 } complete -F _delpart_module delpart completions/systemd-nspawn 0000644 00000013364 14720751124 0012031 0 ustar 00 # systemd-nspawn(1) completion -*- shell-script -*- # # This file is part of systemd. # # Copyright 2014 Thomas H.P. Andersen # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # systemd is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see <http://www.gnu.org/licenses/>. __contains_word() { local w word=$1; shift for w in "$@"; do [[ $w = "$word" ]] && return done } __get_users() { local a b loginctl list-users --no-legend --no-pager | { while read a b; do echo " $b"; done; }; } __get_slices() { local a b systemctl list-units -t slice --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } __get_machines() { local a b machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } __get_env() { local a env | { while read a; do echo " ${a%%=*}"; done; }; } __get_interfaces(){ cut -f 1 -d ' ' /proc/net/dev | tail -n +3 | tr -s '\n' | tr -d ':' | xargs } _systemd_nspawn() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps local -A OPTS=( [STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit --network-veth -j' [ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine -S --slice --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge --personality -i --image --tmpfs --volatile --network-macvlan' ) _init_completion || return if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --directory|-D) compopt -o nospace comps=$(compgen -S/ -A directory -- "$cur" ) ;; --user|-u) comps=$( __get_users ) ;; --uuid) comps='' ;; --capability) comps='CAP_BLOCK_SUSPEND CAP_IPC_LOCK CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_SYS_MODULE CAP_SYS_PACCT CAP_SYS_RAWIO CAP_SYS_TIME CAP_SYSLOG CAP_WAKE_ALARM CAP_NET_ADMIN' ;; --drop-capability) comps='CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_FSETID CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE CAP_MKNOD CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETFCAP CAP_SETGID CAP_SETPCAP CAP_SETUID CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_RESOURCE CAP_SYS_TTY_CONFIG' ;; --link-journal) comps='no auto guest host' ;; --bind|--bind-ro) compopt -o nospace comps=$(compgen -S/ -A directory -- "$cur" ) ;; --tmpfs) compopt -o nospace comps=$(compgen -S/ -A directory -- "$cur" ) ;; --machine|-M) comps=$( __get_machines ) ;; --slice|-S) comps=$( __get_slices ) ;; --setenv) comps=$( __get_env ) ;; --selinux-context|-Z) comps='' ;; --selinux-apifs-context|-L) comps='' ;; --register) comps='yes no' ;; --network-interface) comps=$(__get_interfaces) ;; --network-bridge) comps='' ;; --network-macvlan) comps='' ;; --personality) comps='x86 x86-64' ;; --volatile) comps='yes state no' ;; --image|-i) compopt -o nospace comps=$( compgen -A file -- "$cur" ) ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) } complete -F _systemd_nspawn systemd-nspawn completions/unshare 0000644 00000000760 14720751124 0010476 0 ustar 00 _unshare_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--mount --uts --ipc --net --pid --user --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac compopt -o bashdefault COMPREPLY=( $(compgen -c -- $cur) ) return 0 } complete -F _unshare_module unshare completions/blkid 0000644 00000002746 14720751124 0010124 0 ustar 00 _blkid_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-c') local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) return 0 ;; '-o') COMPREPLY=( $(compgen -W "value device export full" -- $cur) ) return 0 ;; '-s') COMPREPLY=( $(compgen -W "tag" -- $cur) ) return 0 ;; '-t') COMPREPLY=( $(compgen -W "token" -- $cur) ) return 0 ;; '-L') COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-label/ 2>/dev/null && echo *)" -- $cur) ) return 0 ;; '-U') COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-uuid/ 2>/dev/null && echo *)" -- $cur) ) return 0 ;; '-s') COMPREPLY=( $(compgen -W "size" -- $cur) ) return 0 ;; '-O') COMPREPLY=( $(compgen -W "offset" -- $cur) ) return 0 ;; '-u') COMPREPLY=( $(compgen -W "filesystem raid crypto other nofilesystem noraid nocrypto noother" -- $cur) ) return 0 ;; '-n') COMPREPLY=( $(compgen -W "$(awk '{print $NF}' /proc/filesystems)" -- $cur) ) return 0 ;; '-h'|'-V') return 0 ;; esac case $cur in -*) OPTS="-c -d -h -g -o -k -s -t -l -L -U -V -p -i -S -O -u -n" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac local DEV TYPE DEVICES='' while read DEV TYPE; do [ $TYPE = 'part' ] && DEVICES+="$DEV " done < <(lsblk -pnro name,type) COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) ) return 0 } complete -F _blkid_module blkid completions/dracut 0000644 00000007000 14720751124 0010305 0 ustar 00 # # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # # Copyright 2013 Red Hat, Inc. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # __contains_word () { local word=$1; shift for w in $*; do [[ $w = $word ]] && return 0; done return 1 } _dracut() { local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local -A OPTS=( [STANDALONE]='-f -v -q -l -H -h -M -N --ro-mnt --force --kernel-only --no-kernel --strip --nostrip --hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf --lvmconf --nolvmconf --debug --profile --verbose --quiet --local --hostonly --no-hostonly --fstab --help --bzip2 --lzma --xz --no-compress --gzip --list-modules --show-modules --keep --printsize --regenerate-all --noimageifnotneeded --early-microcode --no-early-microcode --print-cmdline --prelink --noprelink' [ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers --omit-drivers --modules --omit --drivers --filesystems --install --fwdir --libdirs --fscks --add-fstab --mount --device --nofscks --kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix --kernel-cmdline --sshkey --persistent-policy --install-optional' ) if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --kmoddir|-k|--fwdir|--confdir|--tmpdir) comps=$(compgen -d -- "$cur") compopt -o filenames ;; -c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional) comps=$(compgen -f -- "$cur") compopt -o filenames ;; -a|-m|-o|--add|--modules|--omit) comps=$(dracut --list-modules 2>/dev/null) ;; --persistent-policy) comps=$(cd /dev/disk/; echo *) ;; --kver) comps=$(cd /lib/modules; echo [0-9]*) ;; *) return 0 ;; esac COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) return 0 fi if [[ $cur = -* ]]; then COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) return 0 fi } complete -F _dracut dracut completions/rename 0000644 00000001170 14720751124 0010274 0 ustar 00 _rename_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--verbose --symlink --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac case $COMP_CWORD in 1) COMPREPLY=( $(compgen -W "expression" -- $cur) ) ;; 2) COMPREPLY=( $(compgen -W "replacement" -- $cur) ) ;; *) local IFS=$'\n' compopt -o filenames COMPREPLY=( $(compgen -f -- $cur) ) ;; esac return 0 } complete -F _rename_module rename completions/uuidgen 0000644 00000000600 14720751124 0010462 0 ustar 00 _uuidgen_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--random --time --version --help" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac return 0 } complete -F _uuidgen_module uuidgen completions/getopt 0000644 00000001457 14720751124 0010337 0 ustar 00 _getopt_module() { local cur prev OPTS COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-l'|'--longoptions') COMPREPLY=( $(compgen -W "longopts" -- $cur) ) return 0 ;; '-n'|'--name') COMPREPLY=( $(compgen -W "name" -- $cur) ) return 0 ;; '-o'|'--options') COMPREPLY=( $(compgen -W "optstring" -- $cur) ) return 0 ;; '-s'|'--shell') COMPREPLY=( $(compgen -W "sh bash csh tcsh" -- $cur) ) return 0 ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac case $cur in -*) OPTS="--alternative --help --longoptions --name --options --quiet --quiet-output --shell --test --unquoted --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) return 0 ;; esac return 0 } complete -F _getopt_module getopt
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Génération de la page: 0.04 |
proxy
|
phpinfo
|
Réglages