📄 bash_completion
字号:
--tar-only --config-file --option --auto-remove' -- $cur ) ) else COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \ dist-upgrade install remove purge source \ build-dep check clean autoclean autoremove' \ -- $cur ) ) fi return 0} &&complete -F _apt_get $filenames apt-get# Debian apt-cache(8) completion.#have apt-cache &&_apt_cache(){ local cur prev special i COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} if [ "$cur" != show ]; then for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|rdepends|madison|show?(pkg|src|)) ]]; then special=${COMP_WORDS[i]} fi done fi if [ -n "$special" ]; then case $special in add) _filedir return 0 ;; *) COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) return 0 ;; esac fi case "$prev" in -@(c|p|s|-config-file|-@(pkg|src)-cache)) _filedir return 0 ;; search) if [[ "$cur" != -* ]]; then return 0 fi ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \ -o --help --version --pkg-cache --src-cache \ --quiet --important --full --all-versions \ --no-all-versions --generate --no-generate \ --names-only --all-names --recurse \ --config-file --option' -- $cur ) ) else COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc \ stats dump dumpavail unmet search search \ depends rdepends pkgnames dotty xvcg \ policy madison' -- $cur ) ) fi return 0} &&complete -F _apt_cache $filenames apt-cache# Debian aptitude(1) completion#have aptitude && {have grep-status && {_comp_dpkg_hold_packages(){ grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package}} || {_comp_dpkg_hold_packages(){ grep -B 2 'hold' /var/lib/dpkg/status | grep "Package: $1" \ | cut -d\ -f2}}_aptitude(){ local cur dashoptions prev special i COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} dashoptions='-S -u -i -h --help --version -s --simulate -d \ --download-only -P --prompt -y --assume-yes -F \ --display-format -O --sort -w --width -f -r -g \ --with-recommends --with-suggests -R -G \ --without-recommends --without-suggests -t \ --target-release -V --show-versions -D --show-deps\ -Z -v --verbose --purge-unused' for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do if [[ ${COMP_WORDS[i]} == @(install|reinstall|hold|unhold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|forbid-version|purge|remove|changelog|why|why-not|keep|keep-all) ]]; then special=${COMP_WORDS[i]} fi #exclude some mutually exclusive options [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i} [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u} done if [[ -n "$special" ]]; then case $special in @(install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|changelog|why|why-not)) COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) return 0 ;; @(purge|remove|reinstall|forbid-version)) COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) ) return 0 ;; unhold) COMPREPLY=( $( _comp_dpkg_hold_packages $cur ) ) return 0 ;; esac fi case $prev in # don't complete anything if these options are found @(autoclean|clean|forget-new|search|upgrade|safe-upgrade|update|keep-all)) return 0 ;; -S) _filedir return 0 ;; -@(t|-target-release|-default-release)) COMPREPLY=( $( apt-cache policy | \ grep "release.o=Debian,a=$cur" | \ sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) ) else COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new clean \ autoclean install reinstall remove \ hold unhold purge markauto unmarkauto why why-not \ dist-upgrade full-upgrade download search show \ forbid-version changelog keep-all' -- $cur ) ) fi return 0}complete -F _aptitude $default aptitude}# Debian apt-build(1) completion.#have apt-build &&_apt_build(){ local cur prev special i COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then special=${COMP_WORDS[i]} fi done if [ -n "$special" ]; then case $special in @(install|source|info)) COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) ) return 0 ;; remove) COMPREPLY=( $( _comp_dpkg_installed_packages \ $cur ) ) return 0 ;; *) return 0 ;; esac fi case "$prev" in --@(patch|build-dir|repository-dir)) _filedir return 0 ;; -@(h|-help)) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \ --repository-dir --build-only \ --build-command --reinstall --rebuild \ --remove-builddep --no-wrapper --purge \ --patch --patch-strip -p --yes -y \ --version -v --no-source' -- $cur ) ) else COMPREPLY=( $( compgen -W 'update upgrade install remove \ source dist-upgrade world clean info \ clean-build update-repository ' -- $cur ) ) fi return 0} &&complete -F _apt_build $filenames apt-build# chsh(1) completion#_chsh(){ local cur prev COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} if [ "$prev" = "-s" ]; then if [ -f /etc/debian_version ]; then COMPREPLY=( $( </etc/shells ) ) else COMPREPLY=( $( chsh -l | grep "^$cur" ) ) fi else COMPREPLY=( $( compgen -u -- $cur ) ) fi return 0}complete -F _chsh chsh# chkconfig(8) completion#have chkconfig &&_chkconfig(){ local cur prev COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} case "$prev" in @([1-6]|--@(list|add|del))) _services return 0 ;; --level) COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--list --add --del --level' -- $cur ) ) else if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) ) else _services fi fi} &&complete -F _chkconfig chkconfig# This function provides simple user@host completion#_user_at_host() { local cur COMPREPLY=() cur=`_get_cword` if [[ $cur == *@* ]]; then _known_hosts else COMPREPLY=( $( compgen -u -- "$cur" ) ) fi return 0}shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger# This function performs host completion based on ssh's known_hosts files,# defaulting to standard host completion if they don't exist.#_known_hosts(){ local cur curd ocur user suffix aliases global_kh user_kh hosts i host local -a kh khd config COMPREPLY=() cur=`_get_cword` ocur=$cur [ "$1" = -a ] || [ "$2" = -a ] && aliases='yes' [ "$1" = -c ] || [ "$2" = -c ] && suffix=':' [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@} kh=() # ssh config files [ -r /etc/ssh/ssh_config ] && config=( "${config[@]}" "/etc/ssh/ssh_config" ) [ -r "${HOME}/.ssh/config" ] && config=( "${config[@]}" "${HOME}/.ssh/config" ) [ -r "${HOME}/.ssh2/config" ] && config=( "${config[@]}" "${HOME}/.ssh2/config" ) if [ ${#config[@]} -gt 0 ]; then # expand path (if present) to global known hosts file global_kh=$( eval echo $( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) ) # expand path (if present) to user known hosts file user_kh=$( eval echo $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) ) fi # Global known_hosts files [ -r "$global_kh" ] && kh=( "${kh[@]}" "$global_kh" ) [ -r /etc/ssh/ssh_known_hosts ] && kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts ) [ -r /etc/ssh/ssh_known_hosts2 ] && kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 ) [ -r /etc/known_hosts ] && kh=( "${kh[@]}" /etc/known_hosts ) [ -r /etc/known_hosts2 ] && kh=( "${kh[@]}" /etc/known_hosts2 ) [ -d /etc/ssh2/knownhosts ] && khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub ) # User known_hosts files [ -r "$user_kh" ] && kh=( "${kh[@]}" "$user_kh" ) [ -r ~/.ssh/known_hosts ] && kh=( "${kh[@]}" ~/.ssh/known_hosts ) [ -r ~/.ssh/known_hosts2 ] && kh=( "${kh[@]}" ~/.ssh/known_hosts2 ) [ -d ~/.ssh2/hostkeys ] && khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub ) # If we have known_hosts files to use if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then # Escape slashes and dots in paths for awk cur=${cur//\//\\\/} cur=${cur//\./\\\.} curd=$cur if [[ "$cur" == [0-9]*.* ]]; then # Digits followed by a dot - just search for that cur="^$cur.*" elif [[ "$cur" == [0-9]* ]]; then # Digits followed by no dot - search for digits followed # by a dot cur="^$cur.*\." elif [ -z "$cur" ]; then # A blank - search for a dot or an alpha character cur="[a-z.]" else cur="^$cur" fi if [ ${#kh[@]} -gt 0 ]; then # FS needs to look for a comma separated list COMPREPLY=( $( awk 'BEGIN {FS=","} /^[^|]/ {for (i=1; i<=2; ++i) { \ gsub(" .*$", "", $i); \ if ($i ~ /'$cur'/) {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=( "${COMPREPLY[@]}" $host ) fi done fi # append any available aliases from config files if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" ) hosts=$( compgen -W "$host_aliases" -- $ocur ) COMPREPLY=( "${COMPREPLY[@]}" $hosts ) fi # Now add results of normal hostname completion COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ) ) # apply suffix for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do COMPREPLY[i]=$user${COMPREPLY[i]}$suffix done else # Just do normal hostname completion COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) ) fi return 0}complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \ ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr# ssh(1) completion#have ssh && {_ssh(){ local cur prev local -a config COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} case "$prev" in -*c) COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \ arcfour cast128-cbc' -- $cur ) ) ;; -*i) _filedir ;; -*l) COMPREPLY=( $( compgen -u -- $cur ) ) ;; *) _known_hosts -a [ $COMP_CWORD -eq 1 ] || \ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) ) esac return 0}shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh# scp(1) completion#_scp(){ local cur userhost path COMPREPLY=() cur=`_get_cword` _expand || return 0 if [[ "$cur" == *:* ]]; then local IFS=$'\t\n' # remove backslash escape from : cur=${cur/\\:/:} userhost=${cur%%?(\\):*} path=${cur#*:} # unescape spaces path=${path//\\\\\\\\ / } if [ -z "$path" ]; then # default to home dir of specified user on remote host path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null) fi # escape spaces; remove executables, aliases, pipes and sockets; # add space at end of file names COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \ command ls -aF1d "$path*" 2>/dev/null | \ sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \ -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) ) return 0 fi [[ "$cur" == */* ]] || _known_hosts -c -a local IFS=$'\t\n' COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \ 2>/dev/null | sed \ -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \ -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) ) return 0}complete -F _scp $nospace scp}# rsync(1) completion#have rsync &&_rsync(){ local cur prev shell i userhost path COMPREPLY=() cur=`_get_cword` prev
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -