diff --git a/cygwin/bin/files-here.txt b/cygwin/bin/files-here.txt new file mode 100644 index 0000000..8d30963 --- /dev/null +++ b/cygwin/bin/files-here.txt @@ -0,0 +1,187 @@ +bashbug +bash.exe +cat.exe +clear.exe +cut.exe +cygass-9.dll +cygasyncns-0.dll +cygattr-1.dll +cygavcodec-58.dll +cygavdevice-58.dll +cygavfilter-7.dll +cygavformat-58.dll +cygavresample-4.dll +cygavutil-56.dll +cygbrotlicommon-1.dll +cygbrotlidec-1.dll +cygbs2b-0.dll +cygbz2-1.dll +cygcaca-0.dll +cygcairo-2.dll +cygcom_err-2.dll +cygcroco-0.6-3.dll +cygcrypto-1.1.dll +cygdatrie-1.dll +cygdbus-1-3.dll +cygexpat-1.dll +cygffi-6.dll +cygFLAC-8.dll +cygflite-1.dll +cygflite_cmulex-1.dll +cygflite_cmu_us_awb-1.dll +cygflite_cmu_us_kal16-1.dll +cygflite_cmu_us_kal-1.dll +cygflite_cmu_us_rms-1.dll +cygflite_cmu_us_slt-1.dll +cygflite_usenglish-1.dll +cygfontconfig-1.dll +cygfreetype-6.dll +cygfribidi-0.dll +cyggcc_s-1.dll +cyggdk_pixbuf-2.0-0.dll +cyggio-2.0-0.dll +cygGL-1.dll +cygglapi-0.dll +cygglib-2.0-0.dll +cygGLU-1.dll +cygglut-3.dll +cyggme-0.dll +cyggmodule-2.0-0.dll +cyggmp-10.dll +cyggnutls-30.dll +cyggobject-2.0-0.dll +cyggomp-1.dll +cyggraphite2-3.dll +cyggsm-1.dll +cyggssapi_krb5-2.dll +cygharfbuzz-0.dll +cyghogweed-4.dll +cygiconv-2.dll +cygidn2-0.dll +cygintl-8.dll +cygk5crypto-3.dll +cygkrb5-3.dll +cygkrb5support-0.dll +cyglz4-1.dll +cyglzma-5.dll +cygmagic-1.dll +cygmp3lame-0.dll +cygncursesw-10.dll +cygnettle-6.dll +cygogg-0.dll +cygopenal-1.dll +cygopenjp2-7.dll +cygopus-0.dll +cygp11-kit-0.dll +cygpango-1.0-0.dll +cygpangocairo-1.0-0.dll +cygpangoft2-1.0-0.dll +cygpcre-1.dll +cygpixman-1-0.dll +cygpng16-16.dll +cygpopt-0.dll +cygpostproc-55.dll +cygpulse-0.dll +cygpulsecommon-11.1.dll +cygreadline7.dll +cygrsvg-2-2.dll +cygSDL2-2-0-0.dll +cygsnappy-1.dll +cygsndfile-1.dll +cygsodium-23.dll +cygsoxr-0.dll +cygssh-4.dll +cygstdc++-6.dll +cygswresample-3.dll +cygswscale-5.dll +cygtasn1-6.dll +cygthai-0.dll +cygtheoradec-1.dll +cygtheoraenc-1.dll +cygtwolame-0.dll +cygunistring-2.dll +cyguuid-1.dll +cygvorbis-0.dll +cygvorbisenc-2.dll +cygvpx-5.dll +cygwavpack-1.dll +cygwebp-7.dll +cygwebpmux-3.dll +cygwin1.dll +cygwin-console-helper.exe +cygwin-path +cygwrap-0.dll +cygX11-6.dll +cygX11-xcb-1.dll +cygXau-6.dll +cygxcb-1.dll +cygxcb-glx-0.dll +cygxcb-render-0.dll +cygxcb-shm-0.dll +cygXdmcp-6.dll +cygXext-6.dll +cygXi-6.dll +cygxml2-2.dll +cygXrandr-2.dll +cygXrender-1.dll +cygz.dll +cygzmq-5.dll +cygzstd-1.dll +date.exe +echo.exe +expr.exe +ffmpeg.exe +ffplay.exe +ffprobe.exe +file.exe +files-here.txt +find.exe +ftp.exe +grep.exe +head.exe +ks-avi +ks-avi-wrapper +ks-mix +ks-mp3 +ks-mp3-album +ks-mp4 +ks-mp4k +ks-mp4k-wrapper +ks-mp4s +ks-mp4s-folder +ks-mp4s-wrapper +ks-mp4-wrapper +ks-oga +ks-oga-album +ks-upa +ks-upf +ks-upr +ks-upv +ks-vob +ks-vob-wrapper +ldd.exe +libx264-159.dll +ls.exe +md5sum.exe +mintty.exe +mkdir.exe +mv.exe +pwd.exe +rm.exe +rsync.exe +scp.exe +sed.exe +sleep.exe +ssh-add.exe +ssh-agent.exe +ssh.exe +ssh-keygen.exe +ssh-keyscan.exe +sshpass.exe +tail.exe +touch.exe +tr.exe +wc.exe +x264.exe +xvidcore.dll +zenity.exe diff --git a/cygwin/usr/share/bash-completion/completions/blkid b/cygwin/usr/share/bash-completion/completions/blkid new file mode 100644 index 0000000..57b34c3 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/blkid @@ -0,0 +1,98 @@ +_blkid_module() +{ + local cur prev OPTS OUTPUT_ALL + OUTPUT_ALL='' + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + case $prev in + '-c'|'--cache-file') + local IFS=$'\n' + compopt -o filenames + COMPREPLY=( $(compgen -f -- $cur) ) + return 0 + ;; + '-o'|'--output') + COMPREPLY=( $(compgen -W "value device export full" -- $cur) ) + return 0 + ;; + '-s'|'--match-tag') + COMPREPLY=( $(compgen -W "tag" -- $cur) ) + return 0 + ;; + '-t'|'--match-token') + COMPREPLY=( $(compgen -W "TYPE= LABEL= UUID=" -- $cur) ) + return 0 + ;; + '-L'|'--label') + COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-label/ 2>/dev/null && echo *)" -- $cur) ) + return 0 + ;; + '-U'|'--uuid') + COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-uuid/ 2>/dev/null && echo *)" -- $cur) ) + return 0 + ;; + '-S'|'--size') + COMPREPLY=( $(compgen -W "size" -- $cur) ) + return 0 + ;; + '-O'|'--offset') + COMPREPLY=( $(compgen -W "offset" -- $cur) ) + return 0 + ;; + '-u'|'--usages') + OUTPUT_ALL={,no}{filesystem,raid,crypto,other} + ;; + '-n'|'--match-types') + OUTPUT_ALL=" + $(awk '{print $NF}' /proc/filesystems) + $(\ls /lib/modules/$(uname -r)/kernel/fs) + " + ;; + '-h'|'--help'|'-V'|'--version') + return 0 + ;; + esac + if [ -n "$OUTPUT_ALL" ]; then + local prefix realcur OUTPUT_ALL OUTPUT + realcur="${cur##*,}" + prefix="${cur%$realcur}" + 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 + fi + case $cur in + -*) + OPTS=" + --cache-file + --no-encoding + --garbage-collect + --output + --list-filesystems + --match-tag + --match-token + --list-one + --label + --uuid + --probe + --info + --size + --offset + --usages + --match-types + --help + --version + " + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) ) + return 0 +} +complete -F _blkid_module blkid diff --git a/cygwin/usr/share/bash-completion/completions/cal b/cygwin/usr/share/bash-completion/completions/cal new file mode 100644 index 0000000..e627bdb --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/cal @@ -0,0 +1,29 @@ +_cal_module() +{ + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + case $cur in + -*) + OPTS=" --one + --three + --months + --sunday + --span + --monday + --julian + --year + --twelve + --week + --color=auto + --color=always + --color=never + --version + --help" + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + return 0 + ;; + esac + return 0 +} +complete -F _cal_module cal diff --git a/cygwin/usr/share/bash-completion/completions/cfdisk b/cygwin/usr/share/bash-completion/completions/cfdisk new file mode 100644 index 0000000..8921fa3 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/cfdisk @@ -0,0 +1,29 @@ +_cfdisk_module() +{ + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + case $prev in + '-L'|'--color') + COMPREPLY=( $(compgen -W "auto never always" -- $cur) ) + return 0 + ;; + '-V'|'--version'|'h'|'--help') + return 0 + ;; + esac + case $cur in + -*) + OPTS=" --color + --zero + --help + --version" + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) ) + return 0 +} +complete -F _cfdisk_module cfdisk diff --git a/cygwin/usr/share/bash-completion/completions/col b/cygwin/usr/share/bash-completion/completions/col new file mode 100644 index 0000000..cea57b5 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/col @@ -0,0 +1,27 @@ +_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 diff --git a/cygwin/usr/share/bash-completion/completions/colcrt b/cygwin/usr/share/bash-completion/completions/colcrt new file mode 100644 index 0000000..c66d7e6 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/colcrt @@ -0,0 +1,27 @@ +_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 diff --git a/cygwin/usr/share/bash-completion/completions/colrm b/cygwin/usr/share/bash-completion/completions/colrm new file mode 100644 index 0000000..622dbaa --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/colrm @@ -0,0 +1,29 @@ +_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 diff --git a/cygwin/usr/share/bash-completion/completions/column b/cygwin/usr/share/bash-completion/completions/column new file mode 100644 index 0000000..c5a998b --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/column @@ -0,0 +1,62 @@ +_column_module() +{ + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + case $prev in + '-c'|'--output-width') + COMPREPLY=( $(compgen -W "number" -- $cur) ) + return 0 + ;; + '-s'|'--separator'|'-o'|'--output-separator'|'-n'|'--table-name'|'-O') + COMPREPLY=( $(compgen -W "string" -- $cur) ) + return 0 + ;; + '-O'|'--table-order'|'-N'|'--table-columns'|'-E'|'--table-noextreme'|'-H'|'--table-hide'|'-R'|'--table-right'|'-T'|'--table-truncate'|'-W'|'--table-wrap') + COMPREPLY=( $(compgen -W "string" -- $cur) ) + return 0 + ;; + '-r'|'--tree'|'-i'|'--tree-id'|'-p'|'--tree-parent') + COMPREPLY=( $(compgen -W "string" -- $cur) ) + return 0 + ;; + '-h'|'--help'|'-V'|'--version') + return 0 + ;; + esac + case $cur in + -*) + OPTS="--columns + --table + --table-name + --table-order + --table-columns + --table-noextreme + --table-noheadings + --table-header-repeat + --table-hide + --table-right + --table-truncate + --table-wrap + --table-empty-lines + --json + --tree + --tree-id + --tree-parent + --output-width + --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 diff --git a/cygwin/usr/share/bash-completion/completions/fdisk b/cygwin/usr/share/bash-completion/completions/fdisk new file mode 100644 index 0000000..855de14 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/fdisk @@ -0,0 +1,97 @@ +_fdisk_module() +{ + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + case $prev in + '-s'|'--getsz') + COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) ) + return 0 + ;; + '-b'|'--sector-size') + COMPREPLY=( $(compgen -W "512 1024 2048 4096" -- $cur) ) + return 0 + ;; + '-c'|'--compatibility') + COMPREPLY=( $(compgen -W "dos nondos" -- $cur) ) + return 0 + ;; + '-L'|'--color') + COMPREPLY=( $(compgen -W "auto never always" -- $cur) ) + return 0 + ;; + '--output') + local prefix realcur OUTPUT_ALL OUTPUT + realcur="${cur##*,}" + prefix="${cur%$realcur}" + OUTPUT_ALL=" + Attrs + Boot + Bsize + Cpg + Cylinders + Device + End + End-C/H/S + Flags + Fsize + Id + Name + Sectors + Size + Slice + Start + Start-C/H/S + Type + Type-UUID + UUID + " + 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 + ;; + '-u'|'--units') + COMPREPLY=( $(compgen -W "cylinders sectors" -- $cur) ) + return 0 + ;; + '-C'|'--cylinders'|'-H'|'--heads'|'-S'|'--sectors') + COMPREPLY=( $(compgen -W "number" -- $cur) ) + return 0 + ;; + '-h'|'--help'|'-v'|'--version'|'-V'|'--list') + return 0 + ;; + esac + case $cur in + -*) + OPTS="--sector-size + --protect-boot + --compatibility + --color + --list + --output + --type + --units + --getsz + --bytes + --wipe + --wipe-partitions + --cylinders + --heads + --sectors + --help + --version" + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) ) + return 0 +} +complete -F _fdisk_module fdisk diff --git a/cygwin/usr/share/bash-completion/completions/findfs b/cygwin/usr/share/bash-completion/completions/findfs new file mode 100644 index 0000000..5297b86 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/findfs @@ -0,0 +1,34 @@ +_findfs_module() +{ + local cur prev OPTS findable + 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 + for i in $(lsblk -rpno label); do + findable+=" LABEL=$i" + done + for i in $(lsblk -rpno uuid); do + findable+=" UUID=$i" + done + for i in $(lsblk -rpno partlabel); do + findable+=" PARTLABEL=$i" + done + for i in $(lsblk -rpno partuuid); do + findable+=" PARTUUID=$i" + done + COMPREPLY=( $(compgen -W "$findable" -- $cur) ) + return 0 +} +complete -F _findfs_module findfs diff --git a/cygwin/usr/share/bash-completion/completions/flock b/cygwin/usr/share/bash-completion/completions/flock new file mode 100644 index 0000000..cb68245 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/flock @@ -0,0 +1,47 @@ +_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 + --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 _flock_module flock diff --git a/cygwin/usr/share/bash-completion/completions/fsck.cramfs b/cygwin/usr/share/bash-completion/completions/fsck.cramfs new file mode 100644 index 0000000..d17d2fe --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/fsck.cramfs @@ -0,0 +1,33 @@ +_fsck.cramfs_module() +{ + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + case $prev in + '-b'|'--blocksize') + COMPREPLY=( $(compgen -W "size" -- $cur) ) + return 0 + ;; + '--extract') + local IFS=$'\n' + compopt -o filenames + COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) ) + return 0 + ;; + '-h'|'--help'|'-V'|'--version') + return 0 + ;; + esac + case $cur in + -*) + COMPREPLY=( $(compgen -W "--verbose --blocksize --extract --help --version" -- $cur) ) + return 0 + ;; + esac + local IFS=$'\n' + compopt -o filenames + COMPREPLY=( $(compgen -f -- $cur) ) + return 0 +} +complete -F _fsck.cramfs_module fsck.cramfs diff --git a/cygwin/usr/share/bash-completion/completions/fsck.minix b/cygwin/usr/share/bash-completion/completions/fsck.minix new file mode 100644 index 0000000..ac4571e --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/fsck.minix @@ -0,0 +1,16 @@ +_fsck.minix_module() +{ + local cur OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + case $cur in + -*) + OPTS="--list --auto --repair --verbose --super --uncleared --force --help --version" + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + return 0 + ;; + esac + COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) ) + return 0 +} +complete -F _fsck.minix_module fsck.minix diff --git a/cygwin/usr/share/bash-completion/completions/getopt b/cygwin/usr/share/bash-completion/completions/getopt new file mode 100644 index 0000000..5e3fca6 --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/getopt @@ -0,0 +1,37 @@ +_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 diff --git a/cygwin/usr/share/bash-completion/completions/git b/cygwin/usr/share/bash-completion/completions/git new file mode 100644 index 0000000..499e56f --- /dev/null +++ b/cygwin/usr/share/bash-completion/completions/git @@ -0,0 +1,3055 @@ +# bash/zsh completion support for core Git. +# +# Copyright (C) 2006,2007 Shawn O. Pearce +# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). +# Distributed under the GNU General Public License, version 2.0. +# +# The contained completion routines provide support for completing: +# +# *) local and remote branch names +# *) local and remote tag names +# *) .git/remotes file names +# *) git 'subcommands' +# *) git email aliases for git-send-email +# *) tree paths within 'ref:path/to/file' expressions +# *) file paths within current working directory and index +# *) common --long-options +# +# To use these routines: +# +# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). +# 2) Add the following line to your .bashrc/.zshrc: +# source ~/.git-completion.bash +# 3) Consider changing your PS1 to also show the current branch, +# see git-prompt.sh for details. +# +# If you use complex aliases of form '!f() { ... }; f', you can use the null +# command ':' as the first command in the function body to declare the desired +# completion style. For example '!f() { : git commit ; ... }; f' will +# tell the completion to use commit completion. This also works with aliases +# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". +# +# Compatible with bash 3.2.57. +# +# You can set the following environment variables to influence the behavior of +# the completion routines: +# +# GIT_COMPLETION_CHECKOUT_NO_GUESS +# +# When set to "1", do not include "DWIM" suggestions in git-checkout +# completion (e.g., completing "foo" when "origin/foo" exists). + +case "$COMP_WORDBREAKS" in +*:*) : great ;; +*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" +esac + +# Discovers the path to the git repository taking any '--git-dir=' and +# '-C ' options into account and stores it in the $__git_repo_path +# variable. +__git_find_repo_path () +{ + if [ -n "$__git_repo_path" ]; then + # we already know where it is + return + fi + + if [ -n "${__git_C_args-}" ]; then + __git_repo_path="$(git "${__git_C_args[@]}" \ + ${__git_dir:+--git-dir="$__git_dir"} \ + rev-parse --absolute-git-dir 2>/dev/null)" + elif [ -n "${__git_dir-}" ]; then + test -d "$__git_dir" && + __git_repo_path="$__git_dir" + elif [ -n "${GIT_DIR-}" ]; then + test -d "${GIT_DIR-}" && + __git_repo_path="$GIT_DIR" + elif [ -d .git ]; then + __git_repo_path=.git + else + __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" + fi +} + +# Deprecated: use __git_find_repo_path() and $__git_repo_path instead +# __gitdir accepts 0 or 1 arguments (i.e., location) +# returns location of .git repo +__gitdir () +{ + if [ -z "${1-}" ]; then + __git_find_repo_path || return 1 + echo "$__git_repo_path" + elif [ -d "$1/.git" ]; then + echo "$1/.git" + else + echo "$1" + fi +} + +# Runs git with all the options given as argument, respecting any +# '--git-dir=' and '-C ' options present on the command line +__git () +{ + git ${__git_C_args:+"${__git_C_args[@]}"} \ + ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null +} + +# Removes backslash escaping, single quotes and double quotes from a word, +# stores the result in the variable $dequoted_word. +# 1: The word to dequote. +__git_dequote () +{ + local rest="$1" len ch + + dequoted_word="" + + while test -n "$rest"; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + $'\n') + ;; + *) + dequoted_word="$dequoted_word$ch" + ;; + esac + rest="${rest:2}" + ;; + \') + rest="${rest:1}" + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%\'*}" + rest="${rest:$((${#dequoted_word}-$len+1))}" + ;; + \") + rest="${rest:1}" + while test -n "$rest" ; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + \"|\\|\$|\`) + dequoted_word="$dequoted_word$ch" + ;; + $'\n') + ;; + *) + dequoted_word="$dequoted_word\\$ch" + ;; + esac + rest="${rest:2}" + ;; + \") + rest="${rest:1}" + break + ;; + esac + done + ;; + esac + done +} + +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald +# © 2009-2010, Bash Completion Maintainers +# +# +# 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, see . +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function can be used to access a tokenized list of words +# on the command line: +# +# __git_reassemble_comp_words_by_ref '=:' +# if test "${words_[cword_-1]}" = -w +# then +# ... +# fi +# +# The argument should be a collection of characters from the list of +# word completion separators (COMP_WORDBREAKS) to treat as ordinary +# characters. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude those characters. The intent is to +# make option types like --date= and : easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. +# +# Output: words_, cword_, cur_. + +__git_reassemble_comp_words_by_ref() +{ + local exclude i j first + # Which word separators to exclude? + exclude="${1//[^$COMP_WORDBREAKS]}" + cword_=$COMP_CWORD + if [ -z "$exclude" ]; then + words_=("${COMP_WORDS[@]}") + return + fi + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + return + fi + done + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + done +} + +if ! type _get_comp_words_by_ref >/dev/null 2>&1; then +_get_comp_words_by_ref () +{ + local exclude cur_ words_ cword_ + if [ "$1" = "-n" ]; then + exclude=$2 + shift 2 + fi + __git_reassemble_comp_words_by_ref "$exclude" + cur_=${words_[cword_]} + while [ $# -gt 0 ]; do + case "$1" in + cur) + cur=$cur_ + ;; + prev) + prev=${words_[$cword_-1]} + ;; + words) + words=("${words_[@]}") + ;; + cword) + cword=$cword_ + ;; + esac + shift + done +} +fi + +# Fills the COMPREPLY array with prefiltered words without any additional +# processing. +# Callers must take care of providing only words that match the current word +# to be completed and adding any prefix and/or suffix (trailing space!), if +# necessary. +# 1: List of newline-separated matching completion words, complete with +# prefix and suffix. +__gitcomp_direct () +{ + local IFS=$'\n' + + COMPREPLY=($1) +} + +__gitcompappend () +{ + local x i=${#COMPREPLY[@]} + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +__gitcompadd () +{ + COMPREPLY=() + __gitcompappend "$@" +} + +# Generates completion reply, appending a space to possible completion words, +# if necessary. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp () +{ + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + --no-*) + local c i=0 IFS=$' \t\n' + for c in $1; do + if [[ $c == "--" ]]; then + continue + fi + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; + *) + local c i=0 IFS=$' \t\n' + for c in $1; do + if [[ $c == "--" ]]; then + c="--no-...${4-}" + if [[ $c == "$cur_"* ]]; then + COMPREPLY[i++]="${2-}$c " + fi + break + fi + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; + esac +} + +# Clear the variables caching builtins' options when (re-)sourcing +# the completion script. +if [[ -n ${ZSH_VERSION-} ]]; then + unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null +else + unset $(compgen -v __gitcomp_builtin_) +fi + +# This function is equivalent to +# +# __gitcomp "$(git xxx --git-completion-helper) ..." +# +# except that the output is cached. Accept 1-3 arguments: +# 1: the git command to execute, this is also the cache key +# 2: extra options to be added on top (e.g. negative forms) +# 3: options to be excluded +__gitcomp_builtin () +{ + # spaces must be replaced with underscore for multi-word + # commands, e.g. "git remote add" becomes remote_add. + local cmd="$1" + local incl="$2" + local excl="$3" + + local var=__gitcomp_builtin_"${cmd/-/_}" + local options + eval "options=\$$var" + + if [ -z "$options" ]; then + # leading and trailing spaces are significant to make + # option removal work correctly. + options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " + for i in $excl; do + options="${options/ $i / }" + done + eval "$var=\"$options\"" + fi + + __gitcomp "$options" +} + +# Variation of __gitcomp_nl () that appends to the existing list of +# completion candidates, COMPREPLY. +__gitcomp_nl_append () +{ + local IFS=$'\n' + __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words, separated by a single newline. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word instead of +# the default space (optional). If specified but empty, nothing is +# appended. +__gitcomp_nl () +{ + COMPREPLY=() + __gitcomp_nl_append "$@" +} + +# Fills the COMPREPLY array with prefiltered paths without any additional +# processing. +# Callers must take care of providing only paths that match the current path +# to be completed and adding any prefix path components, if necessary. +# 1: List of newline-separated matching paths, complete with all prefix +# path components. +__gitcomp_file_direct () +{ + local IFS=$'\n' + + COMPREPLY=($1) + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + __gitcompadd "$1" "${2-}" "${3-$cur}" "" + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Execute 'git ls-files', unless the --committable option is specified, in +# which case it runs 'git diff-index' to find out the files that can be +# committed. It return paths relative to the directory specified in the first +# argument, and using the options specified in the second argument. +__git_ls_files_helper () +{ + if [ "$2" == "--committable" ]; then + __git -C "$1" -c core.quotePath=false diff-index \ + --name-only --relative HEAD -- "${3//\\/\\\\}*" + else + # NOTE: $2 is not quoted in order to support multiple options + __git -C "$1" -c core.quotePath=false ls-files \ + --exclude-standard $2 -- "${3//\\/\\\\}*" + fi +} + + +# __git_index_files accepts 1 or 2 arguments: +# 1: Options to pass to ls-files (required). +# 2: A directory path (optional). +# If provided, only files within the specified directory are listed. +# Sub directories are never recursed. Path must have a trailing +# slash. +# 3: List only paths matching this path component (optional). +__git_index_files () +{ + local root="$2" match="$3" + + __git_ls_files_helper "$root" "$1" "$match" | + awk -F / -v pfx="${2//\\/\\\\}" '{ + paths[$1] = 1 + } + END { + for (p in paths) { + if (substr(p, 1, 1) != "\"") { + # No special characters, easy! + print pfx p + continue + } + + # The path is quoted. + p = dequote(p) + if (p == "") + continue + + # Even when a directory name itself does not contain + # any special characters, it will still be quoted if + # any of its (stripped) trailing path components do. + # Because of this we may have seen the same direcory + # both quoted and unquoted. + if (p in paths) + # We have seen the same directory unquoted, + # skip it. + continue + else + print pfx p + } + } + function dequote(p, bs_idx, out, esc, esc_idx, dec) { + # Skip opening double quote. + p = substr(p, 2) + + # Interpret backslash escape sequences. + while ((bs_idx = index(p, "\\")) != 0) { + out = out substr(p, 1, bs_idx - 1) + esc = substr(p, bs_idx + 1, 1) + p = substr(p, bs_idx + 2) + + if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { + # C-style one-character escape sequence. + out = out substr("\a\b\t\v\f\r\"\\", + esc_idx, 1) + } else if (esc == "n") { + # Uh-oh, a newline character. + # We cant reliably put a pathname + # containing a newline into COMPREPLY, + # and the newline would create a mess. + # Skip this path. + return "" + } else { + # Must be a \nnn octal value, then. + dec = esc * 64 + \ + substr(p, 1, 1) * 8 + \ + substr(p, 2, 1) + out = out sprintf("%c", dec) + p = substr(p, 3) + } + } + # Drop closing double quote, if there is one. + # (There isnt any if this is a directory, as it was + # already stripped with the trailing path components.) + if (substr(p, length(p), 1) == "\"") + out = out substr(p, 1, length(p) - 1) + else + out = out p + + return out + }' +} + +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local dequoted_word pfx="" cur_ + + __git_dequote "$cur" + + case "$dequoted_word" in + ?*/*) + pfx="${dequoted_word%/*}/" + cur_="${dequoted_word##*/}" + ;; + *) + cur_="$dequoted_word" + esac + + __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" +} + +# Lists branches from the local repository. +# 1: A prefix to be added to each listed branch (optional). +# 2: List only branches matching this word (optional; list all branches if +# unset or empty). +# 3: A suffix to be appended to each listed branch (optional). +__git_heads () +{ + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + + __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ + "refs/heads/$cur_*" "refs/heads/$cur_*/**" +} + +# Lists tags from the local repository. +# Accepts the same positional parameters as __git_heads() above. +__git_tags () +{ + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + + __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ + "refs/tags/$cur_*" "refs/tags/$cur_*/**" +} + +# Lists refs from the local (by default) or from a remote repository. +# It accepts 0, 1 or 2 arguments: +# 1: The remote to list refs from (optional; ignored, if set but empty). +# Can be the name of a configured remote, a path, or a URL. +# 2: In addition to local refs, list unique branches from refs/remotes/ for +# 'git checkout's tracking DWIMery (optional; ignored, if set but empty). +# 3: A prefix to be added to each listed ref (optional). +# 4: List only refs matching this word (optional; list all refs if unset or +# empty). +# 5: A suffix to be appended to each listed ref (optional; ignored, if set +# but empty). +# +# Use __git_complete_refs() instead. +__git_refs () +{ + local i hash dir track="${2-}" + local list_refs_from=path remote="${1-}" + local format refs + local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" + local match="${4-}" + local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers + + __git_find_repo_path + dir="$__git_repo_path" + + if [ -z "$remote" ]; then + if [ -z "$dir" ]; then + return + fi + else + if __git_is_configured_remote "$remote"; then + # configured remote takes precedence over a + # local directory with the same name + list_refs_from=remote + elif [ -d "$remote/.git" ]; then + dir="$remote/.git" + elif [ -d "$remote" ]; then + dir="$remote" + else + list_refs_from=url + fi + fi + + if [ "$list_refs_from" = path ]; then + if [[ "$cur_" == ^* ]]; then + pfx="$pfx^" + fer_pfx="$fer_pfx^" + cur_=${cur_#^} + match=${match#^} + fi + case "$cur_" in + refs|refs/*) + format="refname" + refs=("$match*" "$match*/**") + track="" + ;; + *) + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do + case "$i" in + $match*) + if [ -e "$dir/$i" ]; then + echo "$pfx$i$sfx" + fi + ;; + esac + done + format="refname:strip=2" + refs=("refs/tags/$match*" "refs/tags/$match*/**" + "refs/heads/$match*" "refs/heads/$match*/**" + "refs/remotes/$match*" "refs/remotes/$match*/**") + ;; + esac + __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ + "${refs[@]}" + if [ -n "$track" ]; then + # employ the heuristic used by git checkout + # Try to find a remote branch that matches the completion word + # but only output if the branch name is unique + __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + --sort="refname:strip=3" \ + "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \ + uniq -u + fi + return + fi + case "$cur_" in + refs|refs/*) + __git ls-remote "$remote" "$match*" | \ + while read -r hash i; do + case "$i" in + *^{}) ;; + *) echo "$pfx$i$sfx" ;; + esac + done + ;; + *) + if [ "$list_refs_from" = remote ]; then + case "HEAD" in + $match*) echo "${pfx}HEAD$sfx" ;; + esac + __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + "refs/remotes/$remote/$match*" \ + "refs/remotes/$remote/$match*/**" + else + local query_symref + case "HEAD" in + $match*) query_symref="HEAD" ;; + esac + __git ls-remote "$remote" $query_symref \ + "refs/tags/$match*" "refs/heads/$match*" \ + "refs/remotes/$match*" | + while read -r hash i; do + case "$i" in + *^{}) ;; + refs/*) echo "$pfx${i#refs/*/}$sfx" ;; + *) echo "$pfx$i$sfx" ;; # symbolic refs + esac + done + fi + ;; + esac +} + +# Completes refs, short and long, local and remote, symbolic and pseudo. +# +# Usage: __git_complete_refs [