]> git.zndr.dk Git - dotfiles.git/commitdiff
Add bash files
authorJannik Zander <jannikz@Janniks-MBP.opasia.dk>
Sun, 1 May 2016 07:28:41 +0000 (09:28 +0200)
committerJannik Zander <jannikz@Janniks-MBP.opasia.dk>
Mon, 2 May 2016 19:34:22 +0000 (21:34 +0200)
200 files changed:
.bash/aliases [new file with mode: 0644]
.bash/bash_completion [new file with mode: 0644]
.bash/bash_completion.d/abook [new file with mode: 0644]
.bash/bash_completion.d/ant [new file with mode: 0644]
.bash/bash_completion.d/apache2ctl [new file with mode: 0644]
.bash/bash_completion.d/apt [new file with mode: 0644]
.bash/bash_completion.d/apt-build [new file with mode: 0644]
.bash/bash_completion.d/aptitude [new file with mode: 0644]
.bash/bash_completion.d/aspell [new file with mode: 0644]
.bash/bash_completion.d/autoconf [new file with mode: 0644]
.bash/bash_completion.d/automake [new file with mode: 0644]
.bash/bash_completion.d/autorpm [new file with mode: 0644]
.bash/bash_completion.d/bash-builtins [new file with mode: 0644]
.bash/bash_completion.d/bind-utils [new file with mode: 0644]
.bash/bash_completion.d/bitkeeper [new file with mode: 0644]
.bash/bash_completion.d/bittorrent [new file with mode: 0644]
.bash/bash_completion.d/bluez [new file with mode: 0644]
.bash/bash_completion.d/brctl [new file with mode: 0644]
.bash/bash_completion.d/bzip2 [new file with mode: 0644]
.bash/bash_completion.d/cardctl [new file with mode: 0644]
.bash/bash_completion.d/cfengine [new file with mode: 0644]
.bash/bash_completion.d/chkconfig [new file with mode: 0644]
.bash/bash_completion.d/chsh [new file with mode: 0644]
.bash/bash_completion.d/cksfv [new file with mode: 0644]
.bash/bash_completion.d/clisp [new file with mode: 0644]
.bash/bash_completion.d/configure [new file with mode: 0644]
.bash/bash_completion.d/coreutils [new file with mode: 0644]
.bash/bash_completion.d/cowsay [new file with mode: 0644]
.bash/bash_completion.d/cpan2dist [new file with mode: 0644]
.bash/bash_completion.d/cpio [new file with mode: 0644]
.bash/bash_completion.d/crontab [new file with mode: 0644]
.bash/bash_completion.d/cryptsetup [new file with mode: 0644]
.bash/bash_completion.d/cups [new file with mode: 0644]
.bash/bash_completion.d/cvs [new file with mode: 0644]
.bash/bash_completion.d/cvsps [new file with mode: 0644]
.bash/bash_completion.d/dd [new file with mode: 0644]
.bash/bash_completion.d/dhclient [new file with mode: 0644]
.bash/bash_completion.d/dict [new file with mode: 0644]
.bash/bash_completion.d/dpkg [new file with mode: 0644]
.bash/bash_completion.d/dselect [new file with mode: 0644]
.bash/bash_completion.d/dsniff [new file with mode: 0644]
.bash/bash_completion.d/dvd+rw-tools [new file with mode: 0644]
.bash/bash_completion.d/e2fsprogs [new file with mode: 0644]
.bash/bash_completion.d/findutils [new file with mode: 0644]
.bash/bash_completion.d/freeciv [new file with mode: 0644]
.bash/bash_completion.d/freerdp [new file with mode: 0644]
.bash/bash_completion.d/fuse [new file with mode: 0644]
.bash/bash_completion.d/gcc [new file with mode: 0644]
.bash/bash_completion.d/gcl [new file with mode: 0644]
.bash/bash_completion.d/gdb [new file with mode: 0644]
.bash/bash_completion.d/gdbus [new file with mode: 0644]
.bash/bash_completion.d/genisoimage [new file with mode: 0644]
.bash/bash_completion.d/getent [new file with mode: 0644]
.bash/bash_completion.d/git [new file with mode: 0644]
.bash/bash_completion.d/gkrellm [new file with mode: 0644]
.bash/bash_completion.d/gnatmake [new file with mode: 0644]
.bash/bash_completion.d/gpg [new file with mode: 0644]
.bash/bash_completion.d/gpg2 [new file with mode: 0644]
.bash/bash_completion.d/gresource [new file with mode: 0644]
.bash/bash_completion.d/gsettings [new file with mode: 0644]
.bash/bash_completion.d/gvim-completion [new file with mode: 0644]
.bash/bash_completion.d/gzip [new file with mode: 0644]
.bash/bash_completion.d/heimdal [new file with mode: 0644]
.bash/bash_completion.d/helpers/perl [new file with mode: 0644]
.bash/bash_completion.d/hping2 [new file with mode: 0644]
.bash/bash_completion.d/iconv [new file with mode: 0644]
.bash/bash_completion.d/iftop [new file with mode: 0644]
.bash/bash_completion.d/ifupdown [new file with mode: 0644]
.bash/bash_completion.d/imagemagick [new file with mode: 0644]
.bash/bash_completion.d/info [new file with mode: 0644]
.bash/bash_completion.d/ipmitool [new file with mode: 0644]
.bash/bash_completion.d/iproute2 [new file with mode: 0644]
.bash/bash_completion.d/ipsec [new file with mode: 0644]
.bash/bash_completion.d/iptables [new file with mode: 0644]
.bash/bash_completion.d/ipv6calc [new file with mode: 0644]
.bash/bash_completion.d/isql [new file with mode: 0644]
.bash/bash_completion.d/jar [new file with mode: 0644]
.bash/bash_completion.d/java [new file with mode: 0644]
.bash/bash_completion.d/k3b [new file with mode: 0644]
.bash/bash_completion.d/kldload [new file with mode: 0644]
.bash/bash_completion.d/larch [new file with mode: 0644]
.bash/bash_completion.d/ldapvi [new file with mode: 0644]
.bash/bash_completion.d/lftp [new file with mode: 0644]
.bash/bash_completion.d/lilo [new file with mode: 0644]
.bash/bash_completion.d/links [new file with mode: 0644]
.bash/bash_completion.d/lintian [new file with mode: 0644]
.bash/bash_completion.d/lisp [new file with mode: 0644]
.bash/bash_completion.d/lrzip [new file with mode: 0644]
.bash/bash_completion.d/lsof [new file with mode: 0644]
.bash/bash_completion.d/lvm [new file with mode: 0644]
.bash/bash_completion.d/lzma [new file with mode: 0644]
.bash/bash_completion.d/lzop [new file with mode: 0644]
.bash/bash_completion.d/mailman [new file with mode: 0644]
.bash/bash_completion.d/make [new file with mode: 0644]
.bash/bash_completion.d/man [new file with mode: 0644]
.bash/bash_completion.d/mc [new file with mode: 0644]
.bash/bash_completion.d/mcrypt [new file with mode: 0644]
.bash/bash_completion.d/mdadm [new file with mode: 0644]
.bash/bash_completion.d/medusa [new file with mode: 0644]
.bash/bash_completion.d/minicom [new file with mode: 0644]
.bash/bash_completion.d/mkinitrd [new file with mode: 0644]
.bash/bash_completion.d/module-init-tools [new file with mode: 0644]
.bash/bash_completion.d/monodevelop [new file with mode: 0644]
.bash/bash_completion.d/mount [new file with mode: 0644]
.bash/bash_completion.d/mplayer [new file with mode: 0644]
.bash/bash_completion.d/msynctool [new file with mode: 0644]
.bash/bash_completion.d/mtx [new file with mode: 0644]
.bash/bash_completion.d/munin-node [new file with mode: 0644]
.bash/bash_completion.d/mutt [new file with mode: 0644]
.bash/bash_completion.d/mysqladmin [new file with mode: 0644]
.bash/bash_completion.d/ncftp [new file with mode: 0644]
.bash/bash_completion.d/net-tools [new file with mode: 0644]
.bash/bash_completion.d/nmap [new file with mode: 0644]
.bash/bash_completion.d/ntpdate [new file with mode: 0644]
.bash/bash_completion.d/open-iscsi [new file with mode: 0644]
.bash/bash_completion.d/openldap [new file with mode: 0644]
.bash/bash_completion.d/openssl [new file with mode: 0644]
.bash/bash_completion.d/p4 [new file with mode: 0644]
.bash/bash_completion.d/perl [new file with mode: 0644]
.bash/bash_completion.d/pine [new file with mode: 0644]
.bash/bash_completion.d/pkg-config [new file with mode: 0644]
.bash/bash_completion.d/pkg_install [new file with mode: 0644]
.bash/bash_completion.d/pkgtools [new file with mode: 0644]
.bash/bash_completion.d/pm-utils [new file with mode: 0644]
.bash/bash_completion.d/portupgrade [new file with mode: 0644]
.bash/bash_completion.d/postfix [new file with mode: 0644]
.bash/bash_completion.d/postgresql [new file with mode: 0644]
.bash/bash_completion.d/povray [new file with mode: 0644]
.bash/bash_completion.d/procps [new file with mode: 0644]
.bash/bash_completion.d/python [new file with mode: 0644]
.bash/bash_completion.d/qdbus [new file with mode: 0644]
.bash/bash_completion.d/qemu [new file with mode: 0644]
.bash/bash_completion.d/quota-tools [new file with mode: 0644]
.bash/bash_completion.d/rcs [new file with mode: 0644]
.bash/bash_completion.d/rdesktop [new file with mode: 0644]
.bash/bash_completion.d/reportbug [new file with mode: 0644]
.bash/bash_completion.d/resolvconf [new file with mode: 0644]
.bash/bash_completion.d/rfkill [new file with mode: 0644]
.bash/bash_completion.d/ri [new file with mode: 0644]
.bash/bash_completion.d/rpcdebug [new file with mode: 0644]
.bash/bash_completion.d/rpm [new file with mode: 0644]
.bash/bash_completion.d/rpmcheck [new file with mode: 0644]
.bash/bash_completion.d/rrdtool [new file with mode: 0644]
.bash/bash_completion.d/rsync [new file with mode: 0644]
.bash/bash_completion.d/rtcwake [new file with mode: 0644]
.bash/bash_completion.d/samba [new file with mode: 0644]
.bash/bash_completion.d/sbcl [new file with mode: 0644]
.bash/bash_completion.d/screen [new file with mode: 0644]
.bash/bash_completion.d/service [new file with mode: 0644]
.bash/bash_completion.d/sh [new file with mode: 0644]
.bash/bash_completion.d/shadow [new file with mode: 0644]
.bash/bash_completion.d/sitecopy [new file with mode: 0644]
.bash/bash_completion.d/smartctl [new file with mode: 0644]
.bash/bash_completion.d/snownews [new file with mode: 0644]
.bash/bash_completion.d/source-highlight [new file with mode: 0644]
.bash/bash_completion.d/sqlite3 [new file with mode: 0644]
.bash/bash_completion.d/ssh [new file with mode: 0644]
.bash/bash_completion.d/sshfs [new file with mode: 0644]
.bash/bash_completion.d/strace [new file with mode: 0644]
.bash/bash_completion.d/svk [new file with mode: 0644]
.bash/bash_completion.d/sysbench [new file with mode: 0644]
.bash/bash_completion.d/sysctl [new file with mode: 0644]
.bash/bash_completion.d/sysv-rc [new file with mode: 0644]
.bash/bash_completion.d/tar [new file with mode: 0644]
.bash/bash_completion.d/tcpdump [new file with mode: 0644]
.bash/bash_completion.d/unace [new file with mode: 0644]
.bash/bash_completion.d/unrar [new file with mode: 0644]
.bash/bash_completion.d/update-alternatives [new file with mode: 0644]
.bash/bash_completion.d/util-linux [new file with mode: 0644]
.bash/bash_completion.d/vim-completion [new file with mode: 0644]
.bash/bash_completion.d/vncviewer [new file with mode: 0644]
.bash/bash_completion.d/vpnc [new file with mode: 0644]
.bash/bash_completion.d/wireless-tools [new file with mode: 0644]
.bash/bash_completion.d/wodim [new file with mode: 0644]
.bash/bash_completion.d/wol [new file with mode: 0644]
.bash/bash_completion.d/wtf [new file with mode: 0644]
.bash/bash_completion.d/wvdial [new file with mode: 0644]
.bash/bash_completion.d/xhost [new file with mode: 0644]
.bash/bash_completion.d/xm [new file with mode: 0644]
.bash/bash_completion.d/xmllint [new file with mode: 0644]
.bash/bash_completion.d/xmlwf [new file with mode: 0644]
.bash/bash_completion.d/xmms [new file with mode: 0644]
.bash/bash_completion.d/xmodmap [new file with mode: 0644]
.bash/bash_completion.d/xrandr [new file with mode: 0644]
.bash/bash_completion.d/xrdb [new file with mode: 0644]
.bash/bash_completion.d/xsltproc [new file with mode: 0644]
.bash/bash_completion.d/xz [new file with mode: 0644]
.bash/bash_completion.d/yp-tools [new file with mode: 0644]
.bash/bash_completion.d/yum-arch [new file with mode: 0644]
.bash/completion [new file with mode: 0644]
.bash/dircolors [new file with mode: 0644]
.bash/exports [new file with mode: 0644]
.bash/extra [new file with mode: 0644]
.bash/functions [new file with mode: 0644]
.bash/options [new file with mode: 0644]
.bash/paths [new file with mode: 0644]
.bash/prompt [new file with mode: 0644]
.bash_profile [new file with mode: 0644]
.bashrc [new file with mode: 0644]
.profile [new file with mode: 0644]

diff --git a/.bash/aliases b/.bash/aliases
new file mode 100644 (file)
index 0000000..d2600d3
--- /dev/null
@@ -0,0 +1,110 @@
+# Easier navigation: .., ..., ...., ....., ~ and -
+alias ..="cd .."
+alias ...="cd ../.."
+alias ....="cd ../../.."
+alias .....="cd ../../../.."
+alias ~="cd ~" # `cd` is probably faster to type though
+alias -- -="cd -"
+alias cd=cd_func
+alias -- --="cd --"
+alias -- -0="cd -0"
+alias -- -1="cd -1"
+alias -- -2="cd -2"
+alias -- -3="cd -3"
+alias -- -4="cd -4"
+alias -- -5="cd -5"
+alias -- -6="cd -6"
+alias -- -7="cd -7"
+alias -- -8="cd -8"
+alias -- -9="cd -9"
+# alias ++ pushd
+# alias -- popd
+
+# Secure settings
+alias rm='rm -i'
+alias cp='cp -i'
+alias mv='mv -i'
+
+
+alias info='info --vi-keys'
+#alias less='less -rX'                         # raw control characters, don't clear the screen after quitting
+alias whence='type -a'                        # where, of a sort
+alias grep='grep --color'                     # show differences in color
+alias egrep='egrep --color=auto'              # show differences in color
+alias fgrep='fgrep --color=auto'              # show differences in color
+
+# Shortcuts
+alias d="cd ~/Documents"
+alias dl="cd ~/Downloads"
+alias dt="cd ~/Desktop"
+alias w="cd ~/work"
+alias g="git"
+alias h="history"
+alias j="jobs"
+
+
+LS_COMMON="-hF"
+#LS_COMMON="$LS_COMMON -I NTUSER.\* -I ntuser.\*"
+
+# Detect which `ls` flavor is in use
+if whence dircolors > /dev/null 2>&1; then # GNU `ls`
+       eval $(dircolors -b $HOME/.bash/dircolors)
+       colorflag="--color"
+else # OS X `ls`
+       #eval $(gdircolors $HOME/.bash/dircolors)
+       export CLICOLOR=1
+       colorflag="-G"
+fi
+
+# Always list colorized
+LS_COMMON="$LS_COMMON $colorflag"
+alias ls="command ls $LS_COMMON"
+
+# List all files excl. dotfiles
+alias l="ls"
+
+# List all files in long format excl. dotfiles
+alias ll="ls -l"
+
+# List all files in long format, incl. dotfiles
+alias la="ls -la"
+
+# List only directories
+alias lsd="ls -l | grep --color=never '^d'"
+
+# List only dotfiles
+alias l.="ls -d .*"
+
+# Enable aliases to be sudo'ed
+alias sudo='sudo '
+
+# Get week number
+alias week='date +%V'
+
+# Stopwatch
+alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
+
+# Intuitive map function
+# For example, to list all directories that contain a certain file:
+# find . -name .gitattributes | map dirname
+alias map="xargs -n1"
+
+for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
+       alias "$method"="lwp-request -m '$method'"
+done
+
+# Reload the shell (i.e. invoke as a login shell)
+alias reload="exec $SHELL -l"
+
+# Update dotfiles
+alias pull.='pushd ~/.dotfiles && git pull && stow -vR * && popd'
+alias push.='pushd ~/.dotfiles && git commit -a && git push && popd'
+
+# alias bashhere='chere -il -t mintty -s bash'
+alias newterm='mintty /bin/env CHERE_INVOKING=1 /bin/bash -l &'
+alias gtypist='gtypist -wi'
+alias startxwin='run /usr/bin/bash.exe -l -c "/usr/bin/startxwin -- -nolock -unixkill"'
+alias sumatra='startSumatra.sh'
+alias lynx='lynx -use_mouse'
+alias startvnc='vncserver -geometry 1870x980 -depth 24'
+alias startvnc4='vnc4server -geometry 1870x980 -depth 24'
diff --git a/.bash/bash_completion b/.bash/bash_completion
new file mode 100644 (file)
index 0000000..5441277
--- /dev/null
@@ -0,0 +1,1690 @@
+#
+#   bash_completion - programmable completion functions for bash 3.2+
+#
+#   Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
+#             © 2009-2011, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#   The latest version of this software can be obtained here:
+#
+#   http://bash-completion.alioth.debian.org/
+#
+#   RELEASE: 1.3
+
+if [[ $- == *v* ]]; then
+    BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
+else
+    BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
+fi
+
+if [[ -n $BASH_COMPLETION_DEBUG ]]; then
+    set -v
+else
+    set +v
+fi
+
+# Alter the following to reflect the location of this file.
+#
+[ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=$HOME/.bash/bash_completion
+[ -n "$BASH_COMPLETION_DIR" ] || BASH_COMPLETION_DIR=$HOME/.bash/bash_completion.d
+[ -n "$BASH_COMPLETION_COMPAT_DIR" ] || BASH_COMPLETION_COMPAT_DIR=$HOME/.bash/bash_completion.d
+readonly BASH_COMPLETION BASH_COMPLETION_DIR BASH_COMPLETION_COMPAT_DIR
+
+# Set a couple of useful vars
+#
+UNAME=$( uname -s )
+# strip OS type and version under Cygwin (e.g. CYGWIN_NT-5.1 => Cygwin)
+UNAME=${UNAME/CYGWIN_*/Cygwin}
+
+case ${UNAME} in
+    Linux|GNU|GNU/*) USERLAND=GNU ;;
+    *) USERLAND=${UNAME} ;;
+esac
+
+# 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
+
+# The following section lists completions that are redefined later
+# Do NOT break these over multiple lines.
+#
+# START exclude -- do NOT remove this line
+# bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510
+complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat
+complete -f -X '!*.@(zip|[ejw]ar|exe|pk3|wsz|zargo|xpi|sxw|o[tx]t|od[fgpst]|epub|apk)' unzip zipinfo
+complete -f -X '*.Z' compress znew
+# zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510
+complete -f -X '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat unpigz
+complete -f -X '!*.Z' uncompress
+# lzcmp, lzdiff intentionally not here, see Debian: #455510
+complete -f -X '!*.@(tlz|lzma)' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma
+complete -f -X '!*.@(?(t)xz|tlz|lzma)' unxz xzcat
+complete -f -X '!*.lrz' lrunzip
+complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)' ee
+complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm)' xv qiv
+complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
+complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi kdvi
+complete -f -X '!*.dvi' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
+complete -f -X '!*.[pf]df' acroread gpdf xpdf
+complete -f -X '!*.@(?(e)ps|pdf)' kpdf
+complete -f -X '!*.@(@(?(e)ps|?(E)PS|[pf]df|[PF]DF|dvi|DVI)?(.gz|.GZ|.bz2|.BZ2)|cb[rz]|djv?(u)|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|fdf)' evince
+complete -f -X '!*.@(okular|@(?(e|x)ps|?(E|X)PS|pdf|PDF|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|fdf|FDF)?(.?(gz|GZ|bz2|BZ2)))' okular
+complete -f -X '!*.@(?(e)ps|pdf)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr
+complete -f -X '!*.texi*' makeinfo texi2html
+complete -f -X '!*.@(?(la)tex|texi|dtx|ins|ltx)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
+complete -f -X '!*.mp3' mpg123 mpg321 madplay
+complete -f -X '!*@(.@(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
+complete -f -X '!*@(.@(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
+complete -f -X '!*.@(avi|asf|wmv)' aviplay
+complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
+complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim
+complete -f -X '!*.@(ogg|m3u|flac|spx)' ogg123
+complete -f -X '!*.@(mp3|ogg|pls|m3u)' gqmpeg freeamp
+complete -f -X '!*.fig' xfig
+complete -f -X '!*.@(mid?(i)|cmf)' playmidi
+complete -f -X '!*.@(mid?(i)|rmi|rcp|[gr]36|g18|mod|xm|it|x3m|s[3t]m|kar)' timidity
+complete -f -X '!*.@(m[eo]d|s[3t]m|xm|it)' modplugplay modplug123
+complete -f -X '*.@(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
+complete -f -X '!*.@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR])' wine
+complete -f -X '!*.@(zip|z|gz|tgz)' bzme
+# konqueror not here on purpose, it's more than a web/html browser
+complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon dillo elinks amaya firefox mozilla-firefox iceweasel google-chrome chromium-browser epiphany
+complete -f -X '!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|odt|ott|odm)' oowriter
+complete -f -X '!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|odp|otp)' ooimpress
+complete -f -X '!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|ods|ots)' oocalc
+complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw
+complete -f -X '!*.@(sxm|smf|mml|odf)' oomath
+complete -f -X '!*.odb' oobase
+complete -f -X '!*.[rs]pm' rpm2cpio
+complete -f -X '!*.aux' bibtex
+complete -f -X '!*.po' poedit gtranslator kbabel lokalize
+complete -f -X '!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])' harbour gharbour hbpp
+complete -f -X '!*.[Hh][Rr][Bb]' hbrun
+complete -f -X '!*.ly' lilypond ly2dvi
+complete -f -X '!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))' cdiff
+complete -f -X '!*.lyx' lyx
+complete -f -X '!@(*.@(ks|jks|jceks|p12|pfx|bks|ubr|gkr|cer|crt|cert|p7b|pkipath|pem|p10|csr|crl)|cacerts)' portecle
+complete -f -X '!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)' kid3 kid3-qt
+# FINISH exclude -- do not remove this line
+
+# start of section containing compspecs that can be handled within bash
+
+# user commands see only users
+complete -u su write chfn groups slay w sux runuser
+
+# 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
+
+# This function checks whether we have a given program on the system.
+# No need for bulky functions in memory if we don't.
+#
+have()
+{
+    unset -v have
+    # Completions for system administrator commands are installed as well in
+    # case completion is attempted via `sudo command ...'.
+    PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
+    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()
+{
+    echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
+}
+
+# @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 echo "$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 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;
+        # 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?
+            while [[ $i -gt 0 && ${COMP_WORDS[$i]} &&
+                ${COMP_WORDS[$i]//[^$exclude]} == ${COMP_WORDS[$i]}
+            ]]; do
+                [ $j -ge 2 ] && ((j--))
+                # Append word separator to current word
+                ref="$2[$j]"
+                eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
+                # Indicate new cword
+                [ $i = $COMP_CWORD ] && eval $3=$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]}
+            # Indicate new cword
+            [[ $i == $COMP_CWORD ]] && eval $3=$j
+        done
+    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.  Bash-3 doesn't do word splitting, so this
+#     ensures we get the same word on both bash-3 and bash-4.
+# @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 ___get_cword_at_cursor_by_ref()
+__get_cword_at_cursor_by_ref() {
+    local cword words=()
+    __reassemble_comp_words_by_ref "$1" words cword
+
+    local i cur2
+    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
+        cur2=${words[cword]}
+    else
+        cur2=${cur:0:$index}
+    fi
+
+    local "$2" "$3" "$4" &&
+        _upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "$cur2"
+}
+
+
+# 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.  Bash-3
+#                 doesn't do word splitting, so this ensures we get the same
+#                 word on both bash-3 and bash-4.
+#     -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  ]] && { 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.  Bash-3 doesn't do word splitting, so this
+#     ensures we get the same word on both bash-3 and bash-4.
+# @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.
+# On bash-3, and bash-4 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 word-to-complete contains a colon,
+    # and bash-version < 4,
+    # or bash-version >= 4 and COMP_WORDBREAKS contains a colon
+    if [[
+        "$1" == *:* && (
+            ${BASH_VERSINFO[0]} -lt 4 ||
+            (${BASH_VERSINFO[0]} -ge 4 && "$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 (bash-4)
+#     a\'b/c
+#     $ compgen -f "a\\\\\'b/"  # Good (bash-3)
+#     a\'b/c
+#
+# On bash-3, special characters need to be escaped extra.  This is
+# unless the first character is a single quote (').  If the single
+# quote appears further down the string, bash default completion also
+# fails, e.g.:
+#
+#     $ ls 'a&b/'
+#     f
+#     $ foo 'a&b/<TAB>  # Becomes: foo 'a&b/f'
+#     $ foo a'&b/<TAB>  # Nothing happens
+#
+# 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:0:1} == "'" ]]; then
+        if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
+            # Leave out first character
+            printf -v $2 %s "${1:1}"
+        else
+            # Quote word, leaving out first character
+            printf -v $2 %q "${1:1}"
+            # Double-quote word (bash-3)
+            printf -v $2 %q ${!2}
+        fi
+    elif [[ ${BASH_VERSINFO[0]} -le 3 && ${1:0:1} == '"' ]]; then
+        printf -v $2 %q "${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:0:1} == '$' ]] && eval $2=${!2}
+} # _quote_readline_by_ref()
+
+
+# This function turns on "-o filenames" behavior dynamically. It is present
+# for bash < 4 reasons. See http://bugs.debian.org/272660#64 for info about
+# the bash < 4 compgen hack.
+_compopt_o_filenames()
+{
+    # We test for compopt availability first because directly invoking it on
+    # bash < 4 at this point may cause terminal echo to be turned off for some
+    # reason, see https://bugzilla.redhat.com/653669 for more info.
+    type compopt &>/dev/null && compopt -o filenames 2>/dev/null || \
+        compgen -f /non-existing-dir/ >/dev/null
+}
+
+
+# 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 tmp
+
+    _quote_readline_by_ref "$cur" quoted
+    toks=( ${toks[@]-} $(
+        compgen -d -- "$quoted" | {
+            while read -r tmp; do
+                # TODO: I have removed a "[ -n $tmp ] &&" before 'printf ..',
+                #       and everything works again. If this bug suddenly
+                #       appears again (i.e. "cd /b<TAB>" becomes "cd /"),
+                #       remember to check for other similar conditionals (here
+                #       and _filedir_xspec()). --David
+                printf '%s\n' $tmp
+            done
+        }
+    ))
+
+    if [[ "$1" != -d ]]; then
+        # Munge xspec to contain uppercase version too
+        [[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
+            xspec=${1:+"!*.@($1|${1^^})"} || \
+            xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
+        toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) )
+    fi
+    [ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
+
+    COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
+} # _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.
+# 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
+}
+
+# This function tries to parse the help output of the given command.
+# @param $1  command
+# @param $2  command options (default: --help)
+#
+_parse_help() {
+    $1 ${2:---help} 2>&1 | sed -e '/^[[:space:]]*-/!d' -e 's|[,/]| |g' | \
+        awk '{ print $1; if ($2 ~ /^-/) { print $2 } }' | sed -e 's|[<=].*||'
+}
+
+# This function completes on signal names
+#
+_signals()
+{
+    local i
+
+    # standard signal completion is rather braindead, so we need
+    # to hack around to get what we want here, which is to
+    # complete on a dash, followed by the signal name minus
+    # the SIG prefix
+    COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
+    for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
+        COMPREPLY[i]=-${COMPREPLY[i]#SIG}
+    done
+}
+
+# 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 (Linux only?)
+    COMPREPLY=( "${COMPREPLY[@]}" $( ifconfig -a 2>/dev/null | sed -ne \
+        "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" ) )
+
+    # ARP cache
+    COMPREPLY=( "${COMPREPLY[@]}" $( arp -an 2>/dev/null | sed -ne \
+        "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne \
+        "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" ) )
+
+    # /etc/ethers
+    COMPREPLY=( "${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
+}
+
+# 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
+
+    if [ "${1:-}" = -w ]; then
+        cmd="iwconfig"
+    elif [ "${1:-}" = -a ]; then
+        cmd="ifconfig"
+    else
+        cmd="ifconfig -a"
+    fi
+
+    COMPREPLY=( $( eval PATH="$PATH:/sbin" $cmd 2>/dev/null | \
+        awk '/^[^ \t]/ { print $1 }' ) )
+    COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) )
+}
+
+
+# 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
+    # Does $1 start with tilde (~) and doesn't contain slash (/)?
+    if [[ ${1:0:1} == "~" && $1 == ${1//\/} ]]; then
+        _compopt_o_filenames
+        # Try generate username completions
+        COMPREPLY=( $( compgen -P '~' -u "${1#\~}" ) )
+        result=${#COMPREPLY[@]}
+    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:0:1}" = "~" ]; then
+        # Does $1 contain slash (/)?
+        if [ "${!1}" != "${!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="$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
+    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.
+[[ $UNAME == SunOS || $UNAME == 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.
+[[ $UNAME == SunOS || $UNAME == 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.
+[[ $UNAME == SunOS || $UNAME == 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
+}
+
+# This function completes on services
+#
+_services()
+{
+    local sysvdir famdir
+    [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
+    famdir=/etc/xinetd.d
+    COMPREPLY=( $( printf '%s\n' \
+        $sysvdir/!(*.rpm@(orig|new|save)|*~|functions) ) )
+
+    if [ -d $famdir ]; then
+        COMPREPLY=( "${COMPREPLY[@]}" $( printf '%s\n' \
+            $famdir/!(*.rpm@(orig|new|save)|*~) ) )
+    fi
+
+    COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- "$cur" ) )
+}
+
+# This function completes on modules
+#
+_modules()
+{
+    local modpath
+    modpath=/lib/modules/$1
+    COMPREPLY=( $( compgen -W "$( command ls -R $modpath | \
+        sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.gz\)\{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()
+{
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
+        '$( command grep "^[[:space:]]*/" /etc/shells 2>/dev/null )' \
+        -- "$cur" ) )
+}
+
+# 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=( "${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 readlink > /dev/null; then
+            readlink -f "$(type -P "$1")"
+        else
+            type -P "$1"
+        fi
+    }
+}
+
+# This function returns the first arugment, 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=( ${COMPREPLY[@]:-} $( compgen -W \
+        "$( PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur" ) )
+}
+
+# This function completes on USB IDs
+#
+_usb_ids()
+{
+    COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W \
+        "$( PATH="$PATH:/sbin" lsusb | awk '{print $6}' )" -- "$cur" ) )
+}
+
+# CD device names
+_cd_devices()
+{
+    COMPREPLY=( "${COMPREPLY[@]}"
+        $( compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}" ) )
+}
+
+# DVD device names
+_dvd_devices()
+{
+    COMPREPLY=( "${COMPREPLY[@]}"
+        $( compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}" ) )
+}
+
+# start of section containing completion functions for external programs
+
+# a little help for FreeBSD ports users
+[ $UNAME = 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
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur
+
+    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 options
+    COMPREPLY=()
+
+    # NOTE: Using `_known_hosts' as a helper function and passing options
+    #       to `_known_hosts' is deprecated: Use `_known_hosts_real' instead.
+    [[ "$1" == -a || "$2" == -a ]] && options=-a
+    [[ "$1" == -c || "$2" == -c ]] && options="$options -c"
+    _known_hosts_real $options "$(_get_cword :)"
+} # _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=( "${config[@]}" "$configfile" )
+    else
+        for i in /etc/ssh/ssh_config "${HOME}/.ssh/config" \
+            "${HOME}/.ssh2/config"; do
+            [ -r $i ] && config=( "${config[@]}" "$i" )
+        done
+    fi
+
+    # Known hosts files from configs
+    if [ ${#config[@]} -gt 0 ]; then
+        local OIFS=$IFS IFS=$'\n'
+        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 ) )
+        for i in "${tmpkh[@]}"; do
+            # Remove possible quotes
+            i=${i//\"}
+            # Eval/expand possible `~' or `~user'
+            __expand_tilde_by_ref i
+            [ -r "$i" ] && kh=( "${kh[@]}" "$i" )
+        done
+        IFS=$OIFS
+    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=( "${kh[@]}" $i )
+        done
+        for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do
+            [ -d $i ] && khd=( "${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=( "${COMPREPLY[@]}" $( awk 'BEGIN {FS=","}
+            /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
+            sub(" .*$", "", $i); \
+            sub("^\\[", "", $i); sub("\\](:[0-9]+)?$", "", $i); \
+            if ($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=( "${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=( "${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=( "${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 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=( "${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 ping \
+    ping6 fping fping6 telnet host nslookup 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 IFS=$'\n' i j k
+    _get_comp_words_by_ref cur
+
+    # try to allow variable completion
+    if [[ "$cur" == ?(\\)\$* ]]; then
+        COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
+        return 0
+    fi
+
+    _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="${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 - currently not quite foolproof (e.g. mount and umount
+# don't work properly), but still quite useful.
+#
+_command_offset()
+{
+    local cur func cline cspec noglob cmd i char_offset word_offset \
+        _COMMAND_FUNC _COMMAND_FUNC_ARGS
+
+    word_offset=$1
+
+    # rewrite current completion context before invoking
+    # actual command completion
+
+    # find new first word position, then
+    # rewrite COMP_LINE and adjust COMP_POINT
+    local first_word=${COMP_WORDS[$word_offset]}
+    for (( i=0; i <= ${#COMP_LINE}; i++ )); do
+        if [[ "${COMP_LINE:$i:${#first_word}}" == "$first_word" ]]; then
+            char_offset=$i
+            break
+        fi
+    done
+    COMP_LINE=${COMP_LINE:$char_offset}
+    COMP_POINT=$(( COMP_POINT - $char_offset ))
+
+    # 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=$(( $COMP_CWORD - $word_offset ))
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ $COMP_CWORD -eq 0 ]]; then
+        _compopt_o_filenames
+        COMPREPLY=( $( compgen -c -- "$cur" ) )
+    else
+        cmd=${COMP_WORDS[0]}
+        if complete -p ${cmd##*/} &>/dev/null; then
+            cspec=$( complete -p ${cmd##*/} )
+            if [ "${cspec#* -F }" != "$cspec" ]; then
+                # complete -F <function>
+
+                # get function name
+                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
+
+                # remove any \: generated by a command that doesn't
+                # default to filenames or dirnames (e.g. sudo chown)
+                # FIXME: I'm pretty sure this does not work!
+                if [ "${cspec#*-o }" != "$cspec" ]; then
+                    cspec=${cspec#*-o }
+                    cspec=${cspec%% *}
+                    if [[ "$cspec" != @(dir|file)names ]]; then
+                        COMPREPLY=("${COMPREPLY[@]//\\\\:/:}")
+                    else
+                        _compopt_o_filenames
+                    fi
+                fi
+            elif [ -n "$cspec" ]; then
+                cspec=${cspec#complete};
+                cspec=${cspec%%${cmd##*/}};
+                COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) );
+            fi
+        elif [ ${#COMPREPLY[@]} -eq 0 ]; then
+            _filedir
+        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 $1 $2 $3
+}
+complete -F _root_command fakeroot gksu gksudo kdesudo really sudo
+
+# Return true if the completion should be treated as running as root
+_complete_as_root()
+{
+    [[ $EUID -eq 0 || ${root_command:-} ]]
+}
+
+_longopt()
+{
+    local cur prev split=false
+    _get_comp_words_by_ref -n = cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --*[Dd][Ii][Rr]*)
+            _filedir -d
+            return 0
+            ;;
+        --*[Ff][Ii][Ll][Ee]*|--*[Pp][Aa][Tt][Hh]*)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
+            sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}\).*/\1/p' | sort -u )" \
+            -- "$cur" ) )
+    elif [[ "$1" == @(mk|rm)dir ]]; then
+        _filedir -d
+    else
+        _filedir
+    fi
+}
+# makeinfo and texi2dvi are defined elsewhere.
+for i in a2ps awk bash bc bison cat colordiff cp csplit \
+    curl cut date df diff dir du enscript env expand fmt fold gperf gprof \
+    grep grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod \
+    mv netstat nl nm objcopy objdump od paste patch pr ptx readelf rm rmdir \
+    sed seq sha{,1,224,256,384,512}sum shar sort split strip tac tail tee \
+    texindex touch tr uname unexpand uniq units vdir wc wget who; do
+    have $i && complete -F _longopt -o default $i
+done
+unset i
+
+_filedir_xspec()
+{
+    local IFS cur xspec
+
+    IFS=$'\n'
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _expand || return 0
+
+    # get first exclusion compspec that matches this command
+    xspec=$( awk "/^complete[ \t]+.*[ \t]${1##*/}([ \t]|\$)/ { print \$0; exit }" \
+        "$BASH_COMPLETION" )
+    # prune to leave nothing but the -X spec
+    xspec=${xspec#*-X }
+    xspec=${xspec%% *}
+
+    local -a toks
+    local tmp
+
+    toks=( ${toks[@]-} $(
+        compgen -d -- "$(quote_readline "$cur")" | {
+        while read -r tmp; do
+            # see long TODO comment in _filedir() --David
+            printf '%s\n' $tmp
+        done
+        }
+        ))
+
+    # Munge xspec to contain uppercase version too
+    eval xspec="${xspec}"
+    local matchop=!
+    if [[ $xspec == !* ]]; then
+        xspec=${xspec#!}
+        matchop=@
+    fi
+    [[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
+        xspec="$matchop($xspec|${xspec^^})" || \
+        xspec="$matchop($xspec|$(printf %s $xspec | tr '[:lower:]' '[:upper:]'))"
+
+    toks=( ${toks[@]-} $(
+        eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | {
+        while read -r tmp; do
+            [ -n $tmp ] && printf '%s\n' $tmp
+        done
+        }
+        ))
+
+    [ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
+    COMPREPLY=( "${toks[@]}" )
+}
+list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' "$BASH_COMPLETION" | \
+    # read exclusion compspecs
+    (
+    while read line
+    do
+        # ignore compspecs that are commented out
+        if [ "${line#\#}" != "$line" ]; then continue; fi
+        line=${line%# START exclude*}
+        line=${line%# FINISH exclude*}
+        line=${line##*\'}
+        list=( "${list[@]}" $line )
+    done
+    printf '%s ' "${list[@]}"
+    )
+    ) )
+# remove previous compspecs
+if [ ${#list[@]} -gt 0 ]; then
+    eval complete -r ${list[@]}
+    # install new compspecs
+    eval complete -F _filedir_xspec "${list[@]}"
+fi
+unset list
+
+# source 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##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)|Makefile*) \
+            && -f $i && -r $i ]] && . "$i"
+    done
+fi
+if [[ $BASH_COMPLETION_DIR != $BASH_COMPLETION_COMPAT_DIR && \
+    -d $BASH_COMPLETION_DIR && -r $BASH_COMPLETION_DIR && \
+    -x $BASH_COMPLETION_DIR ]]; then
+    for i in $(LC_ALL=C command ls "$BASH_COMPLETION_DIR"); do
+        i=$BASH_COMPLETION_DIR/$i
+        [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)|Makefile*) \
+            && -f $i && -r $i ]] && . "$i"
+    done
+fi
+unset i
+
+# source user completion file
+[[ $BASH_COMPLETION != ~/.bash_completion && -r ~/.bash_completion ]] \
+    && . ~/.bash_completion
+unset -f have
+unset UNAME USERLAND have
+
+set $BASH_COMPLETION_ORIGINAL_V_VALUE
+unset BASH_COMPLETION_ORIGINAL_V_VALUE
+
+# 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
diff --git a/.bash/bash_completion.d/abook b/.bash/bash_completion.d/abook
new file mode 100644 (file)
index 0000000..f09c8b5
--- /dev/null
@@ -0,0 +1,62 @@
+# abook(1) completion
+
+have abook &&
+_abook()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    # abook only takes options, tabbing after command name adds a single
+    # dash (bash4)
+    [[ ${BASH_VERSINFO[0]} -ge 4 && $COMP_CWORD -eq 1 && -z "$cur" ]] &&
+    {
+        compopt -o nospace
+        COMPREPLY=( "-" )
+        return 0
+    }
+
+    case $cur in
+        -*)
+            _longopt abook
+            return 0
+            ;;
+    esac
+
+    case $prev in
+        --informat)
+            COMPREPLY=( $( compgen -W "$(abook --formats | \
+                sed -n -e 's/^\t\([a-z]*\).*/\1/p' -e '/^$/q')" -- "$cur" ) )
+            return 0
+            ;;
+        --outformat)
+            COMPREPLY=( $( compgen -W "$(abook --formats | \
+                sed -n -e '/^$/,$s/^\t\([a-z]*\).*/\1/p')" -- "$cur" ) )
+            return 0
+            ;;
+        --infile)
+            COMPREPLY=( $( compgen -W stdin -- "$cur" ) )
+            _filedir
+            return 0
+            ;;
+        --outfile)
+            COMPREPLY=( $( compgen -W stdout -- "$cur" ) )
+            _filedir
+            return 0
+            ;;
+        --config|--datafile)
+            _filedir
+            return 0
+            ;;
+    esac
+} &&
+complete -F _abook abook
+
+# 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
diff --git a/.bash/bash_completion.d/ant b/.bash/bash_completion.d/ant
new file mode 100644 (file)
index 0000000..132c439
--- /dev/null
@@ -0,0 +1,70 @@
+# bash completion for ant
+
+have ant &&
+{
+_ant()
+{
+    local cur prev buildfile i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -buildfile|-file|-f)
+            _filedir 'xml'
+            return 0
+            ;;
+        -logfile|-l)
+            _filedir
+            return 0
+            ;;
+        -propertyfile)
+            _filedir properties
+            return 0
+            ;;
+        -nice)
+            COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9 10' -- "$cur" ) )
+            return 0
+            ;;
+        -lib|-logger|-listener|-D|-inputhandler|-main)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-help -projecthelp -version -diagnostics \
+            -quiet -verbose -debug -emacs -lib -logfile -logger -listener \
+            -noinput -buildfile -D -keep-going -propertyfile -inputhandler \
+            -find -s -nice -nouserlib -noclasspath -autoproxy -main' \
+            -- "$cur" ) )
+    else
+        # available targets completion
+        # find which buildfile to use
+        buildfile=build.xml
+        for (( i=1; i < COMP_CWORD; i++ )); do
+            if [[ "${COMP_WORDS[i]}" == -@(?(build)file|f) ]]; then
+                buildfile=${COMP_WORDS[i+1]}
+                break
+            fi
+        done
+        [ ! -f $buildfile ] && return 0
+
+        # parse buildfile for targets
+        # some versions of sed complain if there's no trailing linefeed,
+        # hence the 2>/dev/null
+        COMPREPLY=( $( compgen -W "$( cat $buildfile | tr "'\t\n>" "\"  \n" | \
+            sed -ne 's/.*<target .*name="\([^"]*\).*/\1/p' 2>/dev/null )" \
+            -- "$cur" ) )
+        fi
+}
+have complete-ant-cmd.pl && \
+     complete -C complete-ant-cmd.pl -F _ant ant || complete -F _ant ant
+}
+
+# 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
diff --git a/.bash/bash_completion.d/apache2ctl b/.bash/bash_completion.d/apache2ctl
new file mode 100644 (file)
index 0000000..287443a
--- /dev/null
@@ -0,0 +1,24 @@
+# apache2ctl(1) completion
+
+have apache2ctl && {
+_apache2ctl() {
+    local APWORDS cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    APWORDS=$(apache2ctl 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | \
+        tr "|" " ")
+
+    COMPREPLY=( $( compgen -W "$APWORDS" -- "$cur" ) )
+}
+complete -F _apache2ctl apache2ctl
+}
+
+# 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
diff --git a/.bash/bash_completion.d/apt b/.bash/bash_completion.d/apt
new file mode 100644 (file)
index 0000000..84811ae
--- /dev/null
@@ -0,0 +1,157 @@
+# Debian apt-get(8) completion.
+
+have apt-get &&
+_apt_get()
+{
+    local cur prev special i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        if [[ ${COMP_WORDS[i]} == @(install|remove|autoremove|purge|source|build-dep) ]]; then
+            special=${COMP_WORDS[i]}
+        fi
+    done
+
+    if [ -n "$special" ]; then
+        case $special in
+            remove|autoremove|purge)
+                if [ -f /etc/debian_version ]; then
+                    # Debian system
+                    COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
+                else
+                    # assume RPM based
+                    _rpm_installed_packages
+                fi
+                return 0
+                ;;
+            source)
+                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+                    2> /dev/null ) $( apt-cache dumpavail | \
+                    command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
+                return 0
+                ;;
+            *)
+                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+                    2> /dev/null ) )
+                return 0
+                ;;
+        esac
+    fi
+
+    case $prev in
+        -c|--config-file)
+             _filedir
+             return 0
+             ;;
+        -t|--target-release|--default-release)
+             COMPREPLY=( $( apt-cache policy | \
+                 command 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 '-d -f -h -v -m -q -s -y -u -t -b -c -o \
+            --download-only --fix-broken --help --version --ignore-missing \
+            --fix-missing --no-download --quiet --simulate --just-print \
+            --dry-run --recon --no-act --yes --assume-yes --show-upgraded \
+            --only-source --compile --build --ignore-hold --target-release \
+            --no-upgrade --force-yes --print-uris --purge --reinstall \
+            --list-cleanup --default-release --trivial-only --no-remove \
+            --diff-only --no-install-recommends --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 apt-get
+
+# Debian apt-cache(8) completion.
+#
+have apt-cache &&
+_apt_cache()
+{
+    local cur prev special i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [ "$cur" != show ]; then
+        for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then
+            special=${COMP_WORDS[i]}
+        fi
+        done
+    fi
+
+
+    if [ -n "$special" ]; then
+        case $special in
+        add)
+            _filedir
+            return 0
+            ;;
+
+        showsrc)
+            COMPREPLY=( $( apt-cache dumpavail | \
+                command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
+            return 0
+            ;;
+
+        *)
+            COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" 2> /dev/null ) )
+            return 0
+            ;;
+
+        esac
+    fi
+
+
+    case $prev in
+         -c|-p|-s|--config-file|--pkg-cache|--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 --installed' -- "$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 apt-cache
+
+# 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
diff --git a/.bash/bash_completion.d/apt-build b/.bash/bash_completion.d/apt-build
new file mode 100644 (file)
index 0000000..d875a98
--- /dev/null
@@ -0,0 +1,66 @@
+# Debian apt-build(1) completion.
+
+have apt-build &&
+_apt_build()
+{
+    local cur prev special i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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 apt-build
+
+# 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
diff --git a/.bash/bash_completion.d/aptitude b/.bash/bash_completion.d/aptitude
new file mode 100644 (file)
index 0000000..c00ad40
--- /dev/null
@@ -0,0 +1,98 @@
+# 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()
+{
+    command grep -B 2 'hold' /var/lib/dpkg/status | \
+        command grep "Package: $1" | cut -d\  -f2
+}
+}
+
+_aptitude()
+{
+    local cur dashoptions prev special i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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 -R -G --without-recommends -t \
+        --target-release -V --show-versions -D --show-deps\
+        -Z -v --verbose --purge-unused --schedule-only'
+
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        if [[ ${COMP_WORDS[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag) ]]; 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|build-dep|add-user-tag| \
+           remove-user-tag)
+               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|safe-upgrade|upgrade|update|keep-all)
+            return 0
+            ;;
+        -S)
+            _filedir
+            return 0
+            ;;
+        -t|--target-release|--default-release)
+            COMPREPLY=( $( apt-cache policy | \
+                command 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 build-dep \
+            add-user-tag remove-user-tag' -- "$cur" ) )
+    fi
+
+    return 0
+}
+complete -F _aptitude -o default aptitude
+}
+
+# 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
diff --git a/.bash/bash_completion.d/aspell b/.bash/bash_completion.d/aspell
new file mode 100644 (file)
index 0000000..5254eee
--- /dev/null
@@ -0,0 +1,96 @@
+# bash completion for aspell
+
+have aspell && {
+_aspell_dictionary()
+{
+    local datadir
+    datadir=$( aspell config data-dir 2>/dev/null || echo /usr/lib/aspell )
+    # First, get aliases (dicts dump does not list them)
+    COMPREPLY=( $( command ls $datadir/*.alias 2>/dev/null ) )
+    COMPREPLY=( ${COMPREPLY[@]%.alias} )
+    COMPREPLY=( ${COMPREPLY[@]#$datadir/} )
+    # Then, add the canonical dicts
+    COMPREPLY=( "${COMPREPLY[@]}" $( aspell dicts 2>/dev/null ) )
+    COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
+}
+
+_aspell()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -c|-p|check|--conf|--personal|--repl|--per-conf)
+            _filedir
+            return 0
+            ;;
+        --conf-dir|--data-dir|--dict-dir|--home-dir|--local-data-dir|--prefix)
+            _filedir -d
+            return 0
+            ;;
+        dump|create|merge)
+            COMPREPLY=( $( compgen -W 'master personal repl' -- "$cur" ) )
+            return 0
+            ;;
+        --mode)
+            COMPREPLY=( $( compgen -W 'none url email sgml tex' -- "$cur" ) )
+            return 0
+            ;;
+        --sug-mode)
+            COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' -- "$cur" ) )
+            return 0
+            ;;
+        --keymapping)
+            COMPREPLY=( $( compgen -W 'aspell ispell' -- "$cur" ) )
+            return 0
+            ;;
+        -d|--master)
+            _aspell_dictionary
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--conf --conf-dir --data-dir --dict-dir \
+            --encoding --add-filter --rem-filter --mode \
+            --add-extra-dicts --rem-extra-dicts \
+            --home-dir --ignore --ignore-accents \
+            --dont-ignore-accents --ignore-case --dont-ignore-case \
+            --ignore-repl --dont-ignore-repl --jargon --keyboard \
+            --lang --language-tag --local-data-dir --master \
+            --module --add-module-search-order \
+            --rem-module-search-order --per-conf --personal \
+            --prefix --repl --run-together --dont-run-together \
+            --run-together-limit --run-together-min --save-repl \
+            --dont-save-repl --set-prefix --dont-set-prefix --size \
+            --spelling --strip-accents --dont-strip-accents \
+            --sug-mode --add-word-list-path --rem-word-list-path \
+            --backup --dont-backup --reverse --dont-reverse \
+            --time --dont-time --keymapping --add-email-quote \
+            --rem-email-quote --email-margin --add-tex-command \
+            --rem-tex-command --tex-check-comments \
+            --dont-tex-check-comments --add-tex-extension \
+            --rem-tex-extension --add-sgml-check --rem-sgml-check \
+            --add-sgml-extension --rem-sgml-extension' -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -W 'usage help check pipe list \
+            config soundslike filter version dump create merge' -- "$cur" ) )
+    fi
+
+}
+complete -F _aspell aspell
+}
+
+# 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
diff --git a/.bash/bash_completion.d/autoconf b/.bash/bash_completion.d/autoconf
new file mode 100644 (file)
index 0000000..c8f1b19
--- /dev/null
@@ -0,0 +1,124 @@
+# Completions for autoconf tools
+
+have autoconf &&
+_autoconf()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|-h|--version|-V|--trace|-t)
+            return 0
+            ;;
+        --output|-o)
+            _filedir
+            return 0
+            ;;
+        --warnings|-W)
+            local cats=( cross obsolete syntax )
+            COMPREPLY=( $( compgen -W \
+                '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) )
+            return 0
+            ;;
+        --prepend-include|-B|--include|-I)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        _longopt $1
+        return
+    fi
+
+    _filedir '@(ac|in)'
+} &&
+complete -F _autoconf autoconf
+
+have autoreconf || have autoheader &&
+_autoreconf()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|-h|--version|-V)
+            return 0
+            ;;
+        --warnings|-W)
+            local cats=( cross gnu obsolete override portability syntax \
+                unsupported )
+            COMPREPLY=( $( compgen -W \
+                '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) )
+            return 0
+            ;;
+        --prepend-include|-B|--include|-I)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        _longopt $1
+        return 0
+    fi
+
+    if [[ $1 == autoheader ]] ; then
+        _filedir '@(ac|in)'
+    else
+        _filedir -d
+    fi
+} &&
+complete -F _autoreconf autoreconf autoheader
+
+have autoscan || have autoupdate &&
+_autoscan()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|-h|--version|-V)
+            return 0
+            ;;
+        --prepend-include|-B|--include|-I)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        _longopt $1
+        return 0
+    fi
+
+    if [[ $1 == autoupdate ]] ; then
+        _filedir '@(ac|in)'
+    else
+        _filedir -d
+    fi
+} &&
+complete -F _autoscan autoscan autoupdate
+
+# 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
diff --git a/.bash/bash_completion.d/automake b/.bash/bash_completion.d/automake
new file mode 100644 (file)
index 0000000..7ed8745
--- /dev/null
@@ -0,0 +1,80 @@
+# Completions for automake tools
+
+have automake &&
+_automake()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|--version)
+            return 0
+            ;;
+        --warnings|-W)
+            local cats=( gnu obsolete override portability syntax unsupported )
+            COMPREPLY=( $( compgen -W \
+                '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) )
+            return 0
+            ;;
+        --libdir)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        _longopt $1
+        return
+    fi
+
+    _filedir
+} &&
+complete -F _automake automake automake-1.11
+
+have aclocal &&
+_aclocal()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|--print-ac-dir|--version)
+            return 0
+            ;;
+        --acdir|-I)
+            _filedir -d
+            return 0
+            ;;
+        --output)
+            _filedir
+            return 0
+            ;;
+        --warnings|-W)
+            local cats=( syntax unsupported )
+            COMPREPLY=( $( compgen -W \
+                '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    _longopt $1
+} &&
+complete -F _aclocal aclocal aclocal-1.11
+
+# 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
diff --git a/.bash/bash_completion.d/autorpm b/.bash/bash_completion.d/autorpm
new file mode 100644 (file)
index 0000000..6a5f762
--- /dev/null
@@ -0,0 +1,23 @@
+# autorpm(8) completion
+
+have autorpm &&
+_autorpm()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    COMPREPLY=( $( compgen -W '--notty --debug --help --version auto add \
+        fullinfo info help install list remove set' -- "$cur" ) )
+
+} &&
+complete -F _autorpm autorpm
+
+# 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
diff --git a/.bash/bash_completion.d/bash-builtins b/.bash/bash_completion.d/bash-builtins
new file mode 100644 (file)
index 0000000..3eba8a1
--- /dev/null
@@ -0,0 +1,128 @@
+# bash alias completion
+#
+_alias()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    case $COMP_LINE in
+        *[^=])
+            COMPREPLY=( $( compgen -A alias -- "$cur" ) )
+            ;;
+        *=)
+            COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | sed \
+                -e 's|^alias '"$cur"'\(.*\)$|\1|' )" )
+            ;;
+    esac
+}
+complete -F _alias -o nospace alias
+
+# bash export completion
+#
+_export()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    case $COMP_LINE in
+        *=\$*)
+            COMPREPLY=( $( compgen -v -P '$' -- "${cur#*=\$}" ) )
+            ;;
+        *[^=])
+            COMPREPLY=( $( compgen -v -S '=' -- "$cur" ) )
+            ;;
+        *=)
+            COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" |
+                ( echo -n \'
+                  sed -e 's/'\''/'\''\\\'\'''\''/g'
+                  echo -n \' ) )" )
+            ;;
+    esac
+}
+complete -F _export -o default -o nospace export
+
+# bash shell function completion
+#
+_function()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [[ $1 == @(declare|typeset) ]]; then
+        if [ "$prev" = -f ]; then
+            COMPREPLY=( $( compgen -A function -- "$cur" ) )
+        elif [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) )
+        fi
+    elif [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -A function -- "$cur" ) )
+    else
+        COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
+    fi
+}
+complete -F _function function declare typeset
+
+# bash complete completion
+#
+_complete()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -o)
+            COMPREPLY=( $( compgen -W 'bashdefault default dirnames filenames \
+                nospace plusdirs' -- "$cur" ) )
+            return 0
+            ;;
+
+        -A)
+            COMPREPLY=( $( compgen -W 'alias arrayvar binding builtin command \
+                directory disabled enabled export file function group \
+                helptopic hostname job keyword running service setopt shopt \
+                signal stopped user variable' -- "$cur" ) )
+            return 0
+            ;;
+
+        -C)
+            COMPREPLY=( $( compgen -A command -- "$cur" ) )
+            return 0
+            ;;
+        -F)
+            COMPREPLY=( $( compgen -A function -- "$cur" ) )
+            return 0
+            ;;
+        -p|-r)
+            COMPREPLY=( $( complete -p | sed -e 's|.* ||' ) )
+            COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
+            return 0
+            ;;
+
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        # relevant options completion
+        local opts="-a -b -c -d -e -f -g -j -k -o -s -u -v -A -G -W -P -S -X"
+        [[ $1 != compgen ]] && opts="$opts -F -C"
+        COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -A command -- "$cur" ) )
+    fi
+}
+complete -F _complete compgen complete
+
+# 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
diff --git a/.bash/bash_completion.d/bind-utils b/.bash/bash_completion.d/bind-utils
new file mode 100644 (file)
index 0000000..040d197
--- /dev/null
@@ -0,0 +1,23 @@
+# bash completion for nslookup
+
+have nslookup &&
+_nslookup()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= srchlist= \
+        defname search port= querytype= type= recurse retry root timeout vc \
+        ignoretc' -- "$cur" ) )
+} &&
+complete -F _nslookup nslookup
+
+# 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
diff --git a/.bash/bash_completion.d/bitkeeper b/.bash/bash_completion.d/bitkeeper
new file mode 100644 (file)
index 0000000..4c312a1
--- /dev/null
@@ -0,0 +1,26 @@
+# BitKeeper completion adapted from code by  Bart Trojanowski <bart@jukie.net>
+
+have bk &&
+_bk() {
+    local BKCMDS
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    BKCMDS="$( bk help topics | awk '/^  bk/ { print $4 }' | \
+        xargs printf '%s ' )"
+
+    COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) )
+    _filedir
+
+    return 0
+} &&
+complete -F _bk bk
+
+# 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
diff --git a/.bash/bash_completion.d/bittorrent b/.bash/bash_completion.d/bittorrent
new file mode 100644 (file)
index 0000000..761d083
--- /dev/null
@@ -0,0 +1,41 @@
+# btdownloadheadless(1) completion
+
+have btdownloadheadless.py || have btdownloadcurses.py || \
+have btdownloadgui.py &&
+_btdownload()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --responsefile|--saveas)
+            _filedir
+            return 0
+            ;;
+    esac
+
+     if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--max_uploads --keepalive_interval \
+            --download_slice_size --request_backlog --max_message_length \
+            --ip --minport --maxport --responsefile --url --saveas --timeout \
+            --timeout_check_interval --max_slice_length --max_rate_period \
+            --bind --upload_rate_fudge --display_interval --rerequest_interval \
+            --min_peers --http_timeout --max_initiate --max_allow_in \
+            --check_hashes --max_upload_rate --snub_time --spew \
+            --rarest_first_cutoff --min_uploads --report_hash_failures' \
+            -- "$cur" ) )
+    else
+        _filedir
+    fi
+} &&
+complete -F _btdownload btdownloadheadless.py btdownloadcurses.py btdownloadgui.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
diff --git a/.bash/bash_completion.d/bluez b/.bash/bash_completion.d/bluez
new file mode 100644 (file)
index 0000000..7a2b1e5
--- /dev/null
@@ -0,0 +1,432 @@
+# bash completion for bluez utils
+
+have hcitool && {
+_bluetooth_adresses()
+{
+    if [ -n "${COMP_BLUETOOTH_SCAN:-}" ]; then
+        COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "$( hcitool scan | \
+            awk '/^\t/{print $1}' )" -- "$cur" ) )
+    fi
+}
+
+_bluetooth_devices()
+{
+    COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "$( hcitool dev | \
+        awk '/^\t/{print $1}' )" -- "$cur" ) )
+}
+
+_bluetooth_services()
+{
+    COMPREPLY=( $( compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG \
+        SAP NAP GN PANU HCRP HID CIP A2SRC A2SNK AVRCT AVRTG UDIUE \
+        UDITE SYNCML' -- "$cur" ) )
+}
+
+_bluetooth_packet_types()
+{
+    COMPREPLY=( $( compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \
+        -- "$cur" ) )
+}
+
+_hcitool()
+{
+    local cur prev split=false arg
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -i)
+            _bluetooth_devices
+            return 0;
+            ;;
+        --role)
+            COMPREPLY=( $( compgen -W 'm s' -- "$cur" ) )
+            return 0;
+            ;;
+        --pkt-type)
+            _bluetooth_packet_types
+            return 0;
+            ;;
+    esac
+
+    $split && return 0
+
+    _get_first_arg
+    if [ -z $arg ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help -i' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -W 'dev inq scan name info \
+                spinq epinq cmd con cc dc sr cpt rssi lq tpl \
+                afh lst auth enc key clkoff clock' -- "$cur" ) )
+        fi
+    else
+        case $arg in
+            name|info|dc|rssi|lq|afh|auth|key|clkoff|lst)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    _bluetooth_adresses
+                fi
+                ;;
+            cc)
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W '--role --pkt-type' -- "$cur" ) )
+                else
+                    _count_args
+                    if [ $args -eq 2 ]; then
+                        _bluetooth_adresses
+                    fi
+                fi
+                ;;
+            sr)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    _bluetooth_adresses
+                else
+                    COMPREPLY=( $( compgen -W 'master slave' -- "$cur" ) )
+                fi
+                ;;
+            cpt)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    _bluetooth_adresses
+                else
+                    _bluetooth_packet_types
+                fi
+                ;;
+            tpl|enc|clock)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    _bluetooth_adresses
+                else
+                    COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
+                fi
+                ;;
+        esac
+    fi
+}
+complete -F _hcitool hcitool
+
+_sdptool()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        --bdaddr)
+            _bluetooth_adresses
+            return 0;
+            ;;
+    esac
+
+    $split && return 0
+
+    _get_first_arg
+    if [ -z $arg ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -W 'search browse records add \
+                del get setattr setseq' -- "$cur" ) )
+        fi
+    else
+        case $arg in
+            search)
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W '--bdaddr \
+                        --tree --raw --xml' -- "$cur" ) )
+                else
+                    _bluetooth_services
+                fi
+                ;;
+            browse|records)
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W '--tree --raw --xml' -- "$cur" ) )
+                else
+                    _bluetooth_adresses
+                fi
+                ;;
+            add)
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W '--handle --channel' -- "$cur" ) )
+                else
+                    _bluetooth_services
+                fi
+                ;;
+            get)
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W '--bdaddr \
+                        --tree --raw --xml' -- "$cur" ) )
+                fi
+                ;;
+        esac
+    fi
+}
+complete -F _sdptool sdptool
+
+_l2ping()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _bluetooth_devices
+            return 0;
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-i -s -c -t -f -r' -- "$cur" ) )
+    else
+        _bluetooth_adresses
+    fi
+
+}
+complete -F _l2ping l2ping
+
+_rfcomm()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f|--config)
+            _filedir
+            return 0;
+            ;;
+        -i)
+            _bluetooth_devices
+            _bluetooth_adresses
+            return 0;
+            ;;
+    esac
+
+    _get_first_arg
+    if [ -z $arg ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help -a --raw \
+                --config -i --auth --encrypt --secure --master' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -W 'show connect listen watch \
+                bind release' -- "$cur" ) )
+        fi
+    else
+        _count_args
+        if [ $args -eq 2 ]; then
+            _bluetooth_devices
+        else
+            case $arg in
+                connect|bind)
+                    if [ $args -eq 3 ]; then
+                        _bluetooth_adresses
+                    fi
+                    ;;
+            esac
+        fi
+    fi
+}
+complete -F _rfcomm rfcomm
+
+_ciptool()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _bluetooth_devices
+            _bluetooth_adresses
+            return 0;
+            ;;
+    esac
+
+    _get_first_arg
+    if [ -z $arg ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help -i' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -W 'show search connect release \
+                loopback' -- "$cur" ) )
+        fi
+    else
+        case $arg in
+            connect|release|loopback)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    _bluetooth_adresses
+                fi
+                ;;
+        esac
+    fi
+}
+complete -F _ciptool ciptool
+
+_dfutool()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -d|--device)
+            _bluetooth_devices
+            return 0;
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --device' -- "$cur" ) )
+    else
+        _count_args
+        case $args in
+            1)
+                COMPREPLY=( $( compgen -W 'verify modify \
+                    upgrade archive' -- "$cur" ) )
+                ;;
+            2)
+                _filedir
+                ;;
+        esac
+    fi
+}
+complete -F _dfutool dfutool
+
+_hciconfig()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _get_first_arg
+    if [ -z $arg ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help --all' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -W 'up down reset rstat auth \
+                noauth encrypt noencrypt secmgr nosecmgr \
+                piscan noscan iscan pscan ptype name class \
+                voice iac inqmode inqdata inqtype inqparams \
+                pageparms pageto afhmode aclmtu scomtu putkey \
+                delkey commands features version revision lm' \
+                -- "$cur" ) )
+        fi
+    else
+        case $arg in
+            putkey|delkey)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    _bluetooth_adresses
+                fi
+                ;;
+            lm)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    COMPREPLY=( $( compgen -W 'MASTER \
+                        SLAVE NONE ACCEPT' -- "$cur" ) )
+                fi
+                ;;
+            ptype)
+                _count_args
+                if [ $args -eq 2 ]; then
+                    _bluetooth_packet_types
+                fi
+                ;;
+        esac
+    fi
+}
+complete -F _hciconfig hciconfig
+
+_hciattach()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-n -p -t -b -s -l' -- "$cur" ) )
+    else
+        _count_args
+        case $args in
+            1)
+                COMPREPLY=( $( printf '%s\n' /dev/tty* ) )
+                COMPREPLY=( $( compgen -W '${COMPREPLY[@]} \
+                    ${COMPREPLY[@]#/dev/}' -- "$cur" ) )
+                ;;
+            2)
+                COMPREPLY=( $( compgen -W 'any ericsson digi \
+                    xircom csr bboxes swave bcsp 0x0105 \
+                    0x080a 0x0160 0x0002' -- "$cur" ) )
+                ;;
+            3)
+                COMPREPLY=( $( compgen -W '9600 19200 38400 \
+                    57600 115200 230400 460800 921600' -- "$cur" ) )
+                ;;
+            4)
+                COMPREPLY=( $( compgen -W 'flow noflow' -- "$cur" ) )
+                ;;
+            5)
+                _bluetooth_adresses
+                ;;
+        esac
+    fi
+
+}
+complete -F _hciattach hciattach
+
+_hid2hci()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --quiet -0 --tohci -1 \
+            --tohid' -- "$cur" ) )
+    fi
+}
+complete -F _hid2hci hid2hci
+
+_avctrl()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --quiet' -- "$cur" ) )
+    else
+        _count_args
+        if [ $args -eq 1 ]; then
+            COMPREPLY=( $( compgen -W 'discover switch' -- "$cur" ) )
+        fi
+    fi
+}
+complete -F _avctrl avctrl
+}
+
+# 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
diff --git a/.bash/bash_completion.d/brctl b/.bash/bash_completion.d/brctl
new file mode 100644 (file)
index 0000000..1be86af
--- /dev/null
@@ -0,0 +1,48 @@
+# bash completion for brctl
+
+have brctl &&
+_brctl()
+{
+    local cur command
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+    command=${COMP_WORDS[1]}
+
+    case $COMP_CWORD in
+        1)
+            COMPREPLY=( $( compgen -W "addbr delbr addif delif \
+                setageing setbridgeprio setfd sethello \
+                setmaxage setpathcost setportprio show \
+                showmacs showstp stp" -- "$cur" ) )
+            ;;
+        2)
+            case $command in
+                show)
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W "$(brctl show | \
+                        awk 'NR>1 {print $1}' )" -- "$cur" ) )
+            esac
+            ;;
+        3)
+            case $command in
+                addif|delif)
+                    _configured_interfaces
+                    ;;
+                stp)
+                    COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+                    ;;
+            esac
+            ;;
+    esac
+} &&
+complete -F _brctl -o default brctl
+
+# 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
diff --git a/.bash/bash_completion.d/bzip2 b/.bash/bash_completion.d/bzip2
new file mode 100644 (file)
index 0000000..7e2f9fd
--- /dev/null
@@ -0,0 +1,51 @@
+# bash completion for bzip2
+
+have bzip2 || have pbzip2 &&
+_bzip2()
+{
+    local cur prev xspec helpopts
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    helpopts=`_parse_help ${COMP_WORDS[0]}`
+
+    case $prev in
+        -b|-h|--help|-p)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        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
+
+# 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
diff --git a/.bash/bash_completion.d/cardctl b/.bash/bash_completion.d/cardctl
new file mode 100644 (file)
index 0000000..1af7491
--- /dev/null
@@ -0,0 +1,24 @@
+# Linux cardctl(8) completion
+
+have cardctl || have pccardctl &&
+_cardctl()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -W 'status config ident suspend \
+            resume reset eject insert scheme' -- "$cur" ) )
+    fi
+} &&
+complete -F _cardctl cardctl pccardctl
+
+# 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
diff --git a/.bash/bash_completion.d/cfengine b/.bash/bash_completion.d/cfengine
new file mode 100644 (file)
index 0000000..50a1384
--- /dev/null
@@ -0,0 +1,88 @@
+# bash completion for cfengine
+
+have cfagent && {
+_cfagent_options()
+{
+    COMPREPLY=( $( compgen -W '--sysadm --force-net-copy --no-check-files \
+        --no-check-mounts --debug --define --no-edits --enforce-links --file \
+        --help --no-hard-classes --no-ifconfig --inform --no-copy --no-lock \
+        --traverse-links --delete-stale-links --no-mount --no-modules \
+        --dry-run --negate --parse-only --no-processes --no-splay \
+        --no-commands --silent --no-tidy --use-env --underscore-classes \
+        --verbose --version --no-preconf --no-links --quiet' -- "$cur" ) )
+}
+
+_cfagent()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f|--file)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        _cfagent_options
+    fi
+}
+complete -F _cfagent cfagent
+
+_cfrun()
+{
+    local i section cfinputs cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    section=1
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == -- ]]; then
+            section=$((section + 1))
+        fi
+    done
+
+    case $section in
+        1)
+            case $prev in
+                -f)
+                    _filedir
+                    return 0
+                    ;;
+            esac
+
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W '-f -h -d -S -T -v' -- $cur ) )
+            else
+                hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts
+                for (( i=1; i < COMP_CWORD; i++ )); do
+                    if [[ "${COMP_WORDS[i]}" == -f ]]; then
+                        hostfile=${COMP_WORDS[i+1]}
+                        break
+                    fi
+                done
+                [ ! -f $hostfile ] && return 0
+
+                COMPREPLY=( $(compgen -W  "$( command grep -v \
+                    -E '(=|^$|^#)' $hostfile )" -- "$cur" ) )
+            fi
+            ;;
+        2)
+            _cfagent_options
+            ;;
+    esac
+}
+complete -F _cfrun cfrun
+}
+
+# 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
diff --git a/.bash/bash_completion.d/chkconfig b/.bash/bash_completion.d/chkconfig
new file mode 100644 (file)
index 0000000..2d02e56
--- /dev/null
@@ -0,0 +1,44 @@
+# chkconfig(8) completion
+
+have chkconfig &&
+_chkconfig()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        --level=[1-6]|[1-6]|--list|--add|--del|--override)
+            _services
+            return 0
+            ;;
+        --level)
+            COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--list --add --del --override --level' -- "$cur" ) )
+    else
+        if [[ $COMP_CWORD -eq 2 || $COMP_CWORD -eq 4 ]]; then
+            COMPREPLY=( $( compgen -W 'on off reset resetpriorities' -- "$cur" ) )
+        else
+            _services
+        fi
+    fi
+} &&
+complete -F _chkconfig chkconfig
+
+# 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
diff --git a/.bash/bash_completion.d/chsh b/.bash/bash_completion.d/chsh
new file mode 100644 (file)
index 0000000..1af3630
--- /dev/null
@@ -0,0 +1,37 @@
+# chsh(1) completion
+
+_chsh()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --list-shells|--help|-v|--version)
+            return 0
+            ;;
+        -s|--shell)
+            _shells
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* && "$( uname -s )" == @(Linux|GNU|GNU/*) ]]; then
+        COMPREPLY=( $( compgen -W '--shell --list-shells --help --version' \
+            -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -u -- "$cur" ) )
+    fi
+
+    return 0
+}
+complete -F _chsh chsh
+
+# 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
diff --git a/.bash/bash_completion.d/cksfv b/.bash/bash_completion.d/cksfv
new file mode 100644 (file)
index 0000000..1f83824
--- /dev/null
@@ -0,0 +1,38 @@
+# cksfv completion by Chris <xris@forevermore.net>
+
+have cksfv &&
+_cksfv()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -W '-C -f -i -q -v' -- "$cur" ) )
+        return 0
+    fi
+
+    case "$prev" in
+        -C)
+            _filedir -d
+            return 0
+            ;;
+        -f)
+            _filedir 'sfv'
+            return 0
+            ;;
+    esac
+
+    _filedir
+    return 0
+} &&
+complete -F _cksfv cksfv
+
+# 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
diff --git a/.bash/bash_completion.d/clisp b/.bash/bash_completion.d/clisp
new file mode 100644 (file)
index 0000000..074f692
--- /dev/null
@@ -0,0 +1,31 @@
+# bash brogrammable completion for various Common Lisp implementations by
+# Nikodemus Siivola <nikodemus@random-state.net>
+
+have clisp &&
+_clisp()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    # completing an option (may or may not be separated by a space)
+    if [[ "$cur" == -* ]]; then
+    COMPREPLY=( $( compgen -W '-h --help --version --license -B -K \
+        -M -m -L -N -E -q --quiet --silent -w -I -ansi \
+         -traditional -p -C -norc -i -c -l -o -x ' -- "$cur" ) )
+    else
+        _filedir
+    fi
+
+    return 0
+} &&
+complete -F _clisp -o default clisp
+
+# 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
diff --git a/.bash/bash_completion.d/configure b/.bash/bash_completion.d/configure
new file mode 100644 (file)
index 0000000..1b20769
--- /dev/null
@@ -0,0 +1,44 @@
+# bash completion for configure
+
+_configure()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        --*prefix|--*dir)
+            _filedir -d
+            ;;
+    esac
+
+    $split && return 0
+
+    # if $COMP_CONFIGURE_HINTS is not null, then completions of the form
+    # --option=SETTING will include 'SETTING' as a contextual hint
+    [[ "$cur" != -* ]] && return 0
+
+    if [ -n "$COMP_CONFIGURE_HINTS" ]; then
+        COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
+            awk '/^  --[A-Za-z]/ { print $1; \
+            if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \
+            -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
+            awk '/^  --[A-Za-z]/ { print $1; \
+            if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' )" \
+            -- "$cur" ) )
+    fi
+}
+complete -F _configure configure
+
+# 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
diff --git a/.bash/bash_completion.d/coreutils b/.bash/bash_completion.d/coreutils
new file mode 100644 (file)
index 0000000..33d58cf
--- /dev/null
@@ -0,0 +1,149 @@
+# Completions for various core utilities
+
+# chown(1) completion
+#
+have chown &&
+_chown()
+{
+    local cur prev split=false
+
+    # Get cur and prev words; but don't treat user:group as separate words.
+    _get_comp_words_by_ref -n : cur prev
+
+    _split_longopt && split=true
+
+    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 "${COMP_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 == 1 ]]; then
+            _usergroup -u
+        else
+            _filedir
+        fi
+    fi
+} &&
+complete -F _chown chown
+
+
+# chgrp(1) completion
+#
+have chgrp &&
+_chgrp()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    cur=${cur//\\\\/}
+
+    _split_longopt && split=true
+
+    if [[ "$prev" == --reference ]]; then
+        _filedir
+        return 0
+    fi
+
+    $split && return 0
+
+    # options completion
+    if [[ "$cur" == -* ]]; then
+        local w opts
+        for w in "${COMP_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 [[ $COMP_CWORD -eq 1 && "$cur" != -* || "$prev" == -* ]]; then
+        _allowed_groups
+    else
+        _filedir || return 0
+    fi
+
+    return 0
+} &&
+complete -F _chgrp chgrp
+
+# id(1) completion
+#
+have id &&
+_id()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\
+            -r --real -u --user --help --version' -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -u "$cur" ) )
+    fi
+} &&
+complete -F _id id
+
+# mktemp(1) completion
+#
+have mktemp &&
+_mktemp()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|--version|--suffix)
+            return 0
+            ;;
+        --tmpdir|-p)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    [[ "$cur" == -* ]] && \
+        COMPREPLY=( $( compgen -W '-d -u -q -p -t' -- "$cur" ) )
+} &&
+complete -F _mktemp mktemp
+
+# 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
diff --git a/.bash/bash_completion.d/cowsay b/.bash/bash_completion.d/cowsay
new file mode 100644 (file)
index 0000000..c6d797a
--- /dev/null
@@ -0,0 +1,31 @@
+# bash completion for cowsay
+
+have cowsay &&
+_cowsay()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f)
+            COMPREPLY=( $( compgen -W '$( cowsay -l | tail -n +2)' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    # relevant options completion
+    COMPREPLY=( $( compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \
+        -- "$cur" ) )
+
+} &&
+complete -F _cowsay -o default cowsay cowthink
+
+# 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
diff --git a/.bash/bash_completion.d/cpan2dist b/.bash/bash_completion.d/cpan2dist
new file mode 100644 (file)
index 0000000..13f568a
--- /dev/null
@@ -0,0 +1,52 @@
+# bash completion for cpan2dist
+
+have cpan2dist &&
+_cpan2dist()
+{
+    local cur prev packagelist cpandirs
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --format)
+            # should remove ":" from COMP_WORDBREAKS, but doesn't work (?)
+            COMPREPLY=( $( compgen -W '$(perl -MCPANPLUS::Dist -e \
+                "print map { \"\$_\n\" } CPANPLUS::Dist->dist_types")' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        --banlist|--ignorelist|--modulelist|--logfile)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --skiptest --force --install \
+            --verbose --keepsource --makefile --buildprereq \
+            --archive --flushcache --defaults --edit-metafile \
+            --format --ban --banlist --ignore --ignorelist \
+            --modulelist --logfile --timeout --set-config \
+            --set-program --dist-opts --default-banlist \
+            --default-ignorelist' -- $cur ) )
+    else
+        cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" )
+        for dir in ${cpandirs[@]}; do
+            [[ -d "$dir" && -r "$dir/02packages.details.txt.gz" ]] && \
+                packagelist="$dir/02packages.details.txt.gz"
+        done
+        COMPREPLY=( $( zgrep "^${cur//-/::}" \
+            $packagelist 2>/dev/null \
+            | awk '{print $1}' | sed -e 's/::/-/g' ) )
+    fi
+} &&
+complete -F _cpan2dist -o default cpan2dist
+
+# 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
diff --git a/.bash/bash_completion.d/cpio b/.bash/bash_completion.d/cpio
new file mode 100644 (file)
index 0000000..5ead018
--- /dev/null
@@ -0,0 +1,103 @@
+# bash completion for cpio
+
+have cpio && {
+_cpio_format()
+{
+    COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur" ) )
+}
+
+_cpio()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+
+    _split_longopt && split=true
+
+    # --name value style option
+    case $prev in
+        -H|--format)
+            _cpio_format
+            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 [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through \
+                                   -? --help --license --usage --version' -- "$cur" ) )
+    else
+        case ${COMP_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 -t --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
+}
+
+# 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
diff --git a/.bash/bash_completion.d/crontab b/.bash/bash_completion.d/crontab
new file mode 100644 (file)
index 0000000..d2ee23a
--- /dev/null
@@ -0,0 +1,60 @@
+# crontab(1) completion
+
+have crontab &&
+_crontab()
+{
+    local cur prev
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -u)
+            _allowed_users
+            return 0
+            ;;
+    esac
+
+    local i opts=" -u -l -r -e" # leading space at start is significant...
+    [ "$(uname -s)" = Linux ] && opts="$opts -i"
+    [ -e /etc/selinux ] && opts="$opts -s"
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        case "${COMP_WORDS[i]}" in
+            -l)
+                opts=${opts// -l -r -e/}
+                opts=${opts// -i/}
+                opts=${opts// -s/}
+                ;;
+            -e)
+                opts=${opts// -l -r -e/}
+                opts=${opts// -i/}
+                ;;
+            -r)
+                opts=${opts// -l -r -e/}
+                ;;
+            -u)
+                opts=${opts// -u/}
+                opts=${opts// -i/}
+                ;;
+            -i|-s)
+                opts=${opts// ${COMP_WORDS[i]}/}
+                ;;
+        esac
+    done
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
+        return 0
+    fi
+
+    # do filenames only if we did not have -l, -r, or -e
+    [[ "${COMP_LINE}" == *\ -@(l|r|e)* ]] || _filedir
+} &&
+complete -F _crontab crontab
+
+# 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
diff --git a/.bash/bash_completion.d/cryptsetup b/.bash/bash_completion.d/cryptsetup
new file mode 100644 (file)
index 0000000..5e88de3
--- /dev/null
@@ -0,0 +1,113 @@
+# bash completion for cryptsetup
+
+_cryptsetup_name()
+{
+    COMPREPLY=( $( compgen -X control -W '$( command ls /dev/mapper )' \
+        -- "$cur" ) )
+}
+
+_cryptsetup_device()
+{
+    cur=${cur:=/dev/}
+    _filedir
+}
+
+have cryptsetup &&
+_cryptsetup()
+{
+    local cur prev arg
+    COMPREPLY=()
+    cur=`_get_cword`
+    prev=`_get_pword`
+
+    case $prev in
+        --key-file|--master-key-file|--header-backup-file|-d)
+            _filedir
+            return 0;
+            ;;
+    esac
+
+    _get_first_arg
+    if [ -z $arg ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--hash --cipher --verify-passphrase \
+                --key-file --master-key-file --key-slot --key-size --size \
+                --offset --skip --readonly --iter-time --batch-mode --timeout \
+                --tries --align-payload --version' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -W 'create remove status resize luksFormat \
+                luksOpen luksClose luksSuspend luksResume luksAddKey \
+                luksRemoveKey luksKillSlot luksDelKey luksUUID isLuks \
+                luksDump luksHeaderBackup luksHeaderRestore' -- "$cur" ) )
+        fi
+    else
+        _count_args
+        case $arg in
+            create)
+                case $args in
+                    2)
+                        _cryptsetup_name
+                        ;;
+                    3)
+                        _cryptsetup_device
+                        ;;
+                esac
+                ;;
+            remove|status|resize|luksClose|luksSuspend|luksResume)
+                case $args in
+                    2)
+                        _cryptsetup_name
+                        ;;
+                esac
+                ;;
+            luksFormat|luksAddKey|luksRemoveKey)
+                case $args in
+                    2)
+                        _cryptsetup_device
+                        ;;
+                    3)
+                        _filedir
+                        ;;
+                esac
+                ;;
+            luksOpen)
+                case $args in
+                    2)
+                        _cryptsetup_device
+                        ;;
+                    3)
+                        _cryptsetup_name
+                        ;;
+                esac
+                ;;
+            luksKillSlot|luksDelKey|luksUUID|isLuks|luksDump)
+                case $args in
+                    2)
+                        _cryptsetup_device
+                        ;;
+                esac
+                ;;
+            luksHeaderBackup|luksHeaderRestore)
+                case $args in
+                    2)
+                        _cryptsetup_device
+                        ;;
+                    3)
+                        COMPREPLY=( '--header-backup-file' )
+                        ;;
+                    esac
+                ;;
+        esac
+    fi
+
+    return 0
+} &&
+complete -F _cryptsetup cryptsetup
+
+# 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
diff --git a/.bash/bash_completion.d/cups b/.bash/bash_completion.d/cups
new file mode 100644 (file)
index 0000000..2848c95
--- /dev/null
@@ -0,0 +1,21 @@
+# bash completion for cups
+
+have cancel &&
+_cancel()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    COMPREPLY=( $( compgen -W "$( lpstat | cut -d' ' -f1 )" -- "$cur" ) )
+} &&
+complete -F _cancel cancel
+
+# 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
diff --git a/.bash/bash_completion.d/cvs b/.bash/bash_completion.d/cvs
new file mode 100644 (file)
index 0000000..be3b1be
--- /dev/null
@@ -0,0 +1,392 @@
+# cvs(1) completion
+
+have cvs && {
+set_prefix()
+{
+    [ -z ${prefix:-} ] || prefix=${cur%/*}/
+    [ -r ${prefix:-}CVS/Entries ] || prefix=""
+}
+
+get_entries()
+{
+    local IFS=$'\n'
+    [ -r ${prefix:-}CVS/Entries ] && \
+    entries=$(cut -d/ -f2 -s ${prefix:-}CVS/Entries)
+}
+
+get_modules()
+{
+    if [ -n "$prefix" ]; then
+        COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) )
+    else
+        COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) )
+    fi
+}
+
+_cvs_commands()
+{
+    cvs --help-commands 2>&1 | awk '/^(     *|\t)/ { print $1 }'
+}
+
+_cvs_options()
+{
+    cvs --help-options 2>&1 | awk '/^(     *|\t)-/ { print $1 }'
+}
+
+_cvs_command_options()
+{
+    cvs --help $1 2>&1 | sed -ne 's/^[[:space:]]*\(-[^[:space:]=[]*\).*/\1/p'
+}
+
+_cvs_kflags()
+{
+    COMPREPLY=( $( compgen -W 'kv kvl k o b v' -- "$cur" ) )
+}
+
+_cvs_roots()
+{
+    local -a cvsroots
+    cvsroots=( $CVSROOT )
+    [ -r ~/.cvspass ] && \
+        cvsroots=( "${cvsroots[@]}" $( awk '{ print $2 }' ~/.cvspass ) )
+    [ -r CVS/Root ] && cvsroots=( "${cvsroots[@]}" $(cat CVS/Root) )
+    COMPREPLY=( $( compgen -W '${cvsroots[@]}' -- "$cur" ) )
+    __ltrim_colon_completions "$cur"
+}
+
+_cvs()
+{
+    local cur prev count mode i cvsroot cvsroots pwd
+    local -a flags miss files entries changed newremoved
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+
+    count=0
+    for i in "${COMP_WORDS[@]}"; do
+        [ $count -eq $COMP_CWORD ] && break
+        # Last parameter was the CVSROOT, now go back to mode selection
+        if [[ "${COMP_WORDS[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then
+            mode=""
+        fi
+        if [ -z "$mode" ]; then
+            case $i in
+                -H|--help)
+                    COMPREPLY=( $( compgen -W "$( _cvs_commands )" -- "$cur" ) )
+                    return 0
+                    ;;
+                -d)
+                    mode=cvsroot
+                    cvsroot=${COMP_WORDS[((count+1))]}
+                    ;;
+                ad|add|new)
+                    mode=add
+                    ;;
+                adm|admin|rcs)
+                    mode=admin
+                    ;;
+                ann|annotate)
+                    mode=annotate
+                    ;;
+                checkout|co|get)
+                    mode=checkout
+                    ;;
+                com|commit|ci)
+                    mode=commit
+                    ;;
+                di|dif|diff)
+                    mode=diff
+                    ;;
+                ex|exp|export)
+                    mode=export
+                    ;;
+                edit|unedit)
+                    mode=$i
+                    ;;
+                hi|his|history)
+                    mode=history
+                    ;;
+                im|imp|import)
+                    mode=import
+                    ;;
+                re|rel|release)
+                    mode=release
+                    ;;
+                log|rlog)
+                    mode=log
+                    ;;
+                rdiff|patch)
+                    mode=rdiff
+                    ;;
+                remove|rm|delete)
+                    mode=remove
+                    ;;
+                rtag|rfreeze)
+                    mode=rtag
+                    ;;
+                st|stat|status)
+                    mode=status
+                    ;;
+                tag|freeze)
+                    mode=tag
+                    ;;
+                up|upd|update)
+                    mode=update
+                    ;;
+            esac
+        elif [[ "$i" = -* ]]; then
+            flags=( "${flags[@]}" $i )
+        fi
+        count=$((++count))
+    done
+
+    case $mode in
+        add)
+            case $prev in
+                -m)
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
+            if [[ "$cur" != -* ]]; then
+                set_prefix
+                if [[ $COMP_CWORD -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
+                    get_entries
+                    [ -z "$cur" ] && \
+                    files=$( command ls -Ad !(CVS) ) || \
+                    files=$( command ls -d ${cur}* 2>/dev/null )
+                    for i in "${entries[@]}"; do
+                        files=( ${files[@]/#$i//} )
+                    done
+                    COMPREPLY=( $( compgen -X '*~' -W '${files[@]}' -- $cur ) )
+                fi
+            else
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        admin)
+            case $prev in
+                -a|-A|-b|-c|-e|-l|-m|-n|-N|-o|-s|-t-|-u)
+                    return 0
+                    ;;
+                -t)
+                    _filedir
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
+            if [[ "$cur" = -* ]]; then
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        annotate)
+            [[ "$prev" == -@(r|D) ]] && return 0
+
+            if [[ "$cur" = -* ]]; then
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            else
+                get_entries
+                COMPREPLY=( $( compgen -W '${entries[@]}' -- "$cur" ) )
+            fi
+            ;;
+        checkout)
+            case $prev in
+                -r|-D|j)
+                    return 0
+                    ;;
+                -d)
+                    _filedir -d
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
+            if [[ "$cur" != -* ]]; then
+                [ -z "$cvsroot" ] && cvsroot=$CVSROOT
+                COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \
+                    awk '{print $1}' ) )
+                COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
+            else
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        commit)
+            case $prev in
+                -m|-r)
+                    return 0
+                    ;;
+                -F)
+                    _filedir
+                    return 0
+                    ;;
+            esac
+
+            set_prefix
+
+            if [[ "$cur" != -* && -r ${prefix:-}CVS/Entries ]]; then
+                # if $COMP_CVS_REMOTE is not null, 'cvs commit' will
+                # complete on remotely checked-out files (requires
+                # passwordless access to the remote repository
+                if [ -n "${COMP_CVS_REMOTE:-}" ]; then
+                    # this is the least computationally intensive
+                # way found so far, but other changes
+                # (something other than changed/removed/new)
+                # may be missing
+                changed=( $( cvs -q diff --brief 2>&1 | \
+                sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) )
+                newremoved=( $( cvs -q diff --brief 2>&1 | \
+                sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) )
+                COMPREPLY=( $( compgen -W '${changed[@]:-} \
+                           ${newremoved[@]:-}' -- "$cur" ) )
+                else
+                    COMPREPLY=( $(compgen -o default -- "$cur") )
+                fi
+            else
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        cvsroot)
+            # TODO: works poorly because of the colons and -o default,
+            #       could we drop -o default?  works ok without it in cvsps
+            _cvs_roots
+            ;;
+        export)
+            case $prev in
+                -r|-D)
+                    return 0
+                    ;;
+                -d)
+                    _filedir -d
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
+            if [[ "$cur" != -* ]]; then
+                [ -z "$cvsroot" ] && cvsroot=$CVSROOT
+                COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
+                COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
+            else
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        diff)
+            if [[ "$cur" == -* ]]; then
+                _longopt diff
+            else
+                get_entries
+                COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) )
+            fi
+            ;;
+        remove)
+            if [[ "$cur" != -* ]]; then
+                set_prefix
+                if [[ $COMP_CWORD -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
+                    get_entries
+                    # find out what files are missing
+                    for i in "${entries[@]}"; do
+                        [ ! -r "$i" ] && miss=( "${miss[@]}" $i )
+                    done
+                    COMPREPLY=( $(compgen -W '${miss[@]:-}' -- "$cur") )
+                fi
+            else
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        import)
+            case $prev in
+                -I|-b|-m|-W)
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
+            if [[ "$cur" != -* ]]; then
+                # starts with same algorithm as checkout
+                [ -z "$cvsroot" ] && cvsroot=$CVSROOT
+                prefix=${cur%/*}
+                if [ -r ${cvsroot}/${prefix} ]; then
+                    get_modules
+                    COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
+                    COMPREPLY=( ${COMPREPLY[@]#\/} )
+                fi
+                pwd=$( pwd )
+                pwd=${pwd##*/}
+                COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- $cur ) )
+            else
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        update)
+            case $prev in
+                -r|-D|-j|-I|-W)
+                    return 0
+                    ;;
+                -k)
+                    _cvs_kflags
+                    return 0
+                    ;;
+            esac
+
+            if [[ "$cur" = -* ]]; then
+                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
+                    -- "$cur" ) )
+            fi
+            ;;
+        "")
+            case $prev in
+                -T)
+                    _filedir -d
+                    return 0
+                    ;;
+                -e|-s)
+                    return 0
+                    ;;
+                -z)
+                    COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" ) )
+                    return 0
+                    ;;
+            esac
+
+            COMPREPLY=( $( compgen -W '$( _cvs_commands ) $( _cvs_options ) \
+                --help --help-commands --help-options --version' -- "$cur" ) )
+            ;;
+    esac
+
+    return 0
+}
+complete -F _cvs -o default cvs
+}
+
+# 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
diff --git a/.bash/bash_completion.d/cvsps b/.bash/bash_completion.d/cvsps
new file mode 100644 (file)
index 0000000..257437b
--- /dev/null
@@ -0,0 +1,69 @@
+# bash completion for cvsps
+
+have cvsps &&
+_cvsps()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref -n : cur prev
+
+    case $prev in
+        -h|-z|-f|-d|-l|--diff-opts|--debuglvl)
+            return 0
+            ;;
+        -s)
+            COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
+                awk '/^PatchSet:?[ \t]/ { print $2 }' )" -- "$cur" ) )
+            return 0
+            ;;
+        -a)
+            COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
+                awk '/^Author:[ \t]/ { print $2 }' )" -- "$cur" ) )
+            return 0
+            ;;
+        -b)
+            COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
+                awk '/^Branch:[ \t]/ { print $2 }' )" -- "$cur" ) )
+            return 0
+            ;;
+        -r)
+            COMPREPLY=( $( compgen -W "$( cvsps 2>/dev/null |
+                awk '/^Tag:[ \t]+[^(]/ { print $2 }' )" -- "$cur" ) )
+            return 0
+            ;;
+        -p)
+            _filedir -d
+            return 0
+            ;;
+        --test-log)
+            _filedir
+            return 0
+            ;;
+        -Z)
+            COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" ) )
+            return 0
+            ;;
+        --root)
+            type _cvs_roots &>/dev/null && _cvs_roots
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W '-h -x -u -z -g -s -a -f -d -b -l -r -p -v \
+            -t --norc --summary-first --test-log --diff-opts --bkcvs --no-rlog \
+            --cvs-direct --no-cvs-direct --debuglvl -Z --root -q -A' \
+            -- "$cur" ) )
+    else
+        type _cvs_roots &>/dev/null && _cvs_roots
+    fi
+} &&
+complete -F _cvsps cvsps
+
+# 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
diff --git a/.bash/bash_completion.d/dd b/.bash/bash_completion.d/dd
new file mode 100644 (file)
index 0000000..7b9b3ac
--- /dev/null
@@ -0,0 +1,39 @@
+# bash completion for dd
+
+have dd &&
+_dd()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n = cur
+
+    case $cur in
+        if=*|of=*)
+            cur=${cur#*=}
+            _filedir
+            return 0
+            ;;
+        conv=*)
+            cur=${cur#*=}
+            COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock lcase
+                notrunc ucase swab noerror sync' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    _expand || return 0
+
+    COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) \
+                $( compgen -W 'bs cbs conv count ibs if obs of seek skip' \
+                           -S '=' -- "$cur" ) )
+} &&
+complete -F _dd -o nospace dd
+
+# 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
diff --git a/.bash/bash_completion.d/dhclient b/.bash/bash_completion.d/dhclient
new file mode 100644 (file)
index 0000000..3d7e1e1
--- /dev/null
@@ -0,0 +1,36 @@
+# bash completion for dhclient
+
+have dhclient && _dhclient()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -cf|-lf|-pf|-sf)
+            _filedir
+            return 0
+            ;;
+        -s)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-p -d -q -1 -r -lf -pf \
+            -cf -sf -s -g -n -nw -w' -- "$cur" ) )
+    else
+        _available_interfaces
+    fi
+} &&
+complete -F _dhclient dhclient
+
+# 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
diff --git a/.bash/bash_completion.d/dict b/.bash/bash_completion.d/dict
new file mode 100644 (file)
index 0000000..4cfdf98
--- /dev/null
@@ -0,0 +1,77 @@
+# dict(1) completion
+
+{ have dict || have rdict; } && {
+_dictdata()
+{
+    dict $host $port $1 2>/dev/null | sed -ne \
+        's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
+}
+
+_dict()
+{
+    local cur prev host port db dictfile
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    dictfile=/usr/share/dict/words
+
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        case ${COMP_WORDS[i]} in
+            -h|--host)
+                host=${COMP_WORDS[i+1]}
+                [ -n "$host" ] && host="-h $host"
+                i=$((++i))
+                ;;
+            -p|--port)
+                port=${COMP_WORDS[i+1]}
+                [ -n "$port" ] && port="-p $port"
+                i=$((++i))
+                ;;
+            -d|--database)
+                db=${COMP_WORDS[i+1]}
+                [ -n "$db" ] && host="-d $db"
+                i=$((++i))
+                ;;
+            *)
+                ;;
+        esac
+    done
+
+    if [[ "$cur" = -* ]]; then
+        COMPREPLY=( $( compgen -W '--host --port --database \
+                   --match --strategy --config \
+                   --nocorrect --dbs --strats \
+                   --serverhelp --info --serverinfo \
+                   --noauth --user --key --version \
+                   --license --help --verbose --raw \
+                   --pager --debug --html --pipesize --client' \
+                   -- "$cur" ) )
+        return 0
+    fi
+
+    case $prev in
+        -d|--database|-i|-info)
+            COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
+            return 0
+            ;;
+        -s|--strategy)
+            COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
+            return 0
+            ;;
+        *)
+            ;;
+    esac
+
+    [ -r $dictfile ] && \
+        COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
+}
+complete -F _dict -o default dict rdict
+}
+
+# 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
diff --git a/.bash/bash_completion.d/dpkg b/.bash/bash_completion.d/dpkg
new file mode 100644 (file)
index 0000000..0556f3d
--- /dev/null
@@ -0,0 +1,244 @@
+# This function is required by _dpkg() and _dpkg-reconfigure()
+have dpkg && {
+have grep-status && {
+_comp_dpkg_installed_packages()
+{
+    grep-status -P -e "^$1" -a -FStatus 'install ok installed' -n -s Package
+}
+} || {
+_comp_dpkg_installed_packages()
+{
+    command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
+        command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
+            half-configured|config-files" \
+            -Ee "^Essential: yes" | \
+        command grep "Package: $1" | cut -d\  -f2
+}
+}
+
+# Debian dpkg(8) completion
+#
+_dpkg()
+{
+    local cur prev i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    i=$COMP_CWORD
+
+    _expand || return 0
+
+    _split_longopt
+
+    # find the last option flag
+    if [[ $cur != -* ]]; then
+        while [[ $prev != -* && $i != 1 ]]; do
+            i=$((i-1))
+            prev=${COMP_WORDS[i-1]}
+        done
+    fi
+
+    case $prev in
+        -c|-i|-A|-I|-f|-e|-x|-X|-W|--install|--unpack|--record-avail| \
+        --contents|--info|--fsys-tarfile|--field|--control|--extract| \
+        --show)
+            _filedir '?(u)deb'
+            return 0
+            ;;
+        -b|--build)
+            _filedir -d
+            return 0
+            ;;
+        -s|-p|-l|--status|--print-avail|--list)
+            COMPREPLY=( $( apt-cache pkgnames "$cur" 2>/dev/null ) )
+            return 0
+            ;;
+        -S|--search)
+            _filedir
+            return 0
+            ;;
+        -r|-L|-P|--remove|--purge|--listfiles)
+            COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
+            return 0
+            ;;
+        *)
+            COMPREPLY=( $( compgen -W '-i --install --unpack -A --record-avail \
+                --configure -r --remove -P --purge --get-selections \
+                --set-selections --update-avail --merge-avail \
+                --clear-avail  --command-fd --forget-old-unavail -s \
+                --status -p --print-avail -L --listfiles -l --list \
+                -S --search -C --audit --print-architecture \
+                --print-gnu-build-architecture \
+                --print-installation-architecture \
+                --compare-versions --help --version --force-help \
+                --force-all --force-auto-select --force-downgrade \
+                --force-configure-any --force-hold --force-bad-path \
+                --force-not-root --force-overwrite \
+                --force-overwrite-diverted --force-bad-verify \
+                --force-depends-version --force-depends \
+                --force-confnew --force-confold --force-confdef \
+                --force-confmiss --force-conflicts --force-architecture\
+                --force-overwrite-dir --force-remove-reinstreq \
+                --force-remove-essential -Dh \
+                --debug=help --licence --admindir --root --instdir \
+                -O --selected-only -E --skip-same-version \
+                -G --refuse-downgrade -B --auto-deconfigure \
+                --no-debsig --no-act -D --debug --status-fd \
+                -b --build -I --info -f --field -c --contents \
+                -x --extract -X --vextract --fsys-tarfile -e --control \
+                --ignore-depends --abort-after' -- "$cur" ) )
+            ;;
+    esac
+
+
+}
+complete -F _dpkg dpkg dpkg-deb
+}
+
+# Debian GNU dpkg-reconfigure(8) completion
+#
+have dpkg-reconfigure &&
+_dpkg_reconfigure()
+{
+    local cur prev opt
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f|--frontend)
+        opt=( $( printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/* ) )
+        opt=( ${opt[@]##*/} )
+        opt=( ${opt[@]%.pm} )
+        COMPREPLY=( $( compgen -W '${opt[@]}' -- "$cur" ) )
+        return 0
+        ;;
+        -p|--priority)
+        COMPREPLY=( $( compgen -W 'low medium high critical' -- "$cur" ) )
+        return 0
+        ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only \
+                      --help --showold --force --terse' -- "$cur" ) )
+    else
+        COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
+    fi
+} &&
+complete -F _dpkg_reconfigure -o default dpkg-reconfigure
+
+# Debian dpkg-source completion
+#
+have dpkg-source &&
+_dpkg_source()
+{
+    local cur prev options work i action packopts unpackopts fields
+
+    packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sr -ss -sA -sK -sP \
+              -sU -sR"
+    unpackopts="-sp -sn -su"
+    options="-x -b $packopts $unpackopts"
+    fields="Format Source Version Binary Maintainer Uploader Architecture \
+            Standards-Version Build-Depends Files"
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    action="options"
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        if [[ ${COMP_WORDS[$i]} == "-x" ]]; then
+            action=unpack
+        elif [[ ${COMP_WORDS[$i]} == "-b" ]]; then
+            action=pack
+        elif [[ ${COMP_WORDS[$i]} == "-h" ]]; then
+            action=help
+        fi
+    done
+
+    case $action in
+        unpack)
+            case $prev in
+                -x)
+                    _filedir -d
+                    _filedir 'dsc'
+                    return 0
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W "$unpackopts" -- "$cur" ) )
+                    _filedir -d
+                    _filedir
+                    return 0
+                    ;;
+            esac
+            return 0
+            ;;
+        pack)
+            case $prev in
+                -b)
+                    _filedir -d
+                    return 0
+                    ;;
+                -c|-l|-T|-i|-I)
+                    # -c: get controlfile
+                    # -l: get per-version info from this file
+                    # -T: read variables here, not debian/substvars
+                    # -i: <regexp> filter out files to ignore diffs of.
+                    # -I: filter out files when building tarballs.
+                    # return directory names and file names
+                    _filedir -d
+                    _filedir
+                    return 0
+                    ;;
+                -F)
+                    # -F: force change log format
+                    COMPREPLY=( $( command ls /usr/lib/dpkg/parsechangelog ) )
+                    return 0
+                    ;;
+                -V|-D)
+                    # -V: set a substitution variable
+                    # we don't know anything about possible variables or values
+                    # so we don't try to suggest any completion.
+                    COMPREPLY=()
+                    return 0
+                    ;;
+                -D)
+                    # -D: override or add a .dsc field and value
+                    # if $cur doesn't contain a = yet, suggest variable names
+                    if [[ "$cur" == *=* ]]; then
+                        # $cur contains a "="
+                        COMPREPLY=()
+                        return 0
+                    else
+                        COMPREPLY=( $( compgen -W "$fields" -- "$cur" ) )
+                        return 0
+                    fi
+                    ;;
+                -U)
+                    # -U: remove a field
+                    # Suggest possible fieldnames
+                    COMPREPLY=( $( compgen -W "$fields" -- "$cur" ) )
+                    return 0
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W "$packopts $unpackopts" -- "$cur" ) )
+                    return 0
+                    ;;
+            esac
+            return 0
+            ;;
+        *)
+            COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+            return 0
+            ;;
+    esac
+} &&
+complete -F _dpkg_source dpkg-source
+
+# 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
diff --git a/.bash/bash_completion.d/dselect b/.bash/bash_completion.d/dselect
new file mode 100644 (file)
index 0000000..3042a8d
--- /dev/null
@@ -0,0 +1,40 @@
+# Debian Linux dselect(8) completion.
+
+have dselect &&
+_dselect()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --admindir)
+            _filedir -d
+            return 0
+            ;;
+        -D|-debug)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--admindir --help --version --licence \
+            --license --expert --debug' -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -W 'access update select install config \
+            remove quit' -- "$cur" ) )
+    fi
+
+    return 0
+} &&
+complete -F _dselect dselect
+
+# 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
diff --git a/.bash/bash_completion.d/dsniff b/.bash/bash_completion.d/dsniff
new file mode 100644 (file)
index 0000000..1d3b303
--- /dev/null
@@ -0,0 +1,256 @@
+# dsniff util completion
+
+have arpspoof &&
+_arpspoof()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _available_interfaces
+            return 0
+            ;;
+        -t)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-i -t' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+
+} &&
+complete -F _arpspoof arpspoof
+
+have dnsspoof &&
+_dnsspoof()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _interfaces
+            return 0
+            ;;
+        -f)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-i -f' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _dnsspoof dnsspoof
+
+have dsniff &&
+_dsniff()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -r|-w|-f)
+            _filedir
+            return 0
+            ;;
+        -i)
+            _interfaces
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-c -d -m -n -i -s -f -t -r -w' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _dsniff dsniff
+
+have filesnarf || have mailsnarf || have msgsnarf &&
+_snarf()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _interfaces
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-i -v' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _snarf filesnarf mailsnarf msgsnarf
+
+have macof &&
+_macof()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _interfaces
+            return 0
+            ;;
+    esac
+
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-i -s -d -e -x -y -n' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _macof macof
+
+have sshmitm &&
+_sshmitm()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-d -I -p' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+
+} &&
+complete -F _sshmitm sshmitm
+
+have sshow &&
+_sshow()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _interfaces
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-d -i' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _sshow sshow
+
+have tcpkill &&
+_tcpkill()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _interfaces
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _tcpkill tcpkill
+
+have tcpnice &&
+_tcpnice()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _interfaces
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-A -I -M -i' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _tcpnice tcpnice
+
+have urlsnarf &&
+_urlsnarf()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _interfaces
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-n -i -v' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _urlsnarf urlsnarf
+
+have webmitm &&
+_webmitm()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-d' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+
+} &&
+complete -F _webmitm webmitm
+
+# 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
diff --git a/.bash/bash_completion.d/dvd+rw-tools b/.bash/bash_completion.d/dvd+rw-tools
new file mode 100644 (file)
index 0000000..f37781e
--- /dev/null
@@ -0,0 +1,47 @@
+# dvd+rw-tools completions
+
+have growisofs &&
+_growisofs()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -version|-speed)
+            return 0
+            ;;
+        -Z|-M)
+            compopt -o nospace &>/dev/null
+            _dvd_devices
+            return 0
+            ;;
+        /?(r)dev/*)
+            if [[ $cur == =* ]] ; then
+                # e.g. /dev/dvd=foo.iso, /dev/dvdrw=/dev/zero
+                cur="${cur#=}"
+                _filedir
+                return 0
+            fi
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        # TODO: mkisofs options
+        COMPREPLY=( $( compgen -W '-dvd-compat -overburn -speed= -Z -M' \
+            -- "$cur" ) )
+        [[ ${COMPREPLY[@]} == *= ]] && compopt -o nospace &>/dev/null
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _growisofs growisofs
+
+# 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
diff --git a/.bash/bash_completion.d/e2fsprogs b/.bash/bash_completion.d/e2fsprogs
new file mode 100644 (file)
index 0000000..50ce788
--- /dev/null
@@ -0,0 +1,180 @@
+# bash completion for e2fsprogs
+
+have badblocks &&
+_badblocks()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -b|-c|-e|-d|-p|-t)
+            return 0
+            ;;
+        -i|-o)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        # -w (dangerous) and -X (internal use) not here on purpose
+        COMPREPLY=( $( compgen -W '-b -c -e -d -f -i -n -o -p -s -t -v' \
+            -- "$cur" ) )
+        return 0
+    fi
+
+    cur=${cur:=/dev/}
+    _filedir
+} &&
+complete -F _badblocks badblocks
+
+
+have dumpe2fs &&
+_dumpe2fs()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -o|-V)
+            return 0
+            ;;
+        -i)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-b -o -f -h -i -x -V' -- "$cur" ) )
+        return 0
+    fi
+
+    cur=${cur:=/dev/}
+    _filedir
+} &&
+complete -F _dumpe2fs dumpe2fs
+
+
+have e2freefrag &&
+_e2freefrag()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -c|-h)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-c -h' -- "$cur" ) )
+        return 0
+    fi
+
+    cur=${cur:=/dev/}
+    _filedir
+} &&
+complete -F _e2freefrag e2freefrag
+
+
+have e2label &&
+_e2label()
+{
+    COMPREPLY=()
+    local cur cword
+    _get_comp_words_by_ref cur cword
+
+    if [ $cword -eq 1 ]; then
+        cur=${cur:=/dev/}
+        _filedir
+    fi
+} &&
+complete -F _e2label e2label
+
+
+have filefrag &&
+_filefrag()
+{
+    COMPREPLY=()
+    local cur
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-B -b -s -v -x' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _filefrag filefrag
+
+
+have tune2fs &&
+_tune2fs()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -c|-C|-E|-i|-J|-L|-m|-r|-T)
+            return 0
+            ;;
+        -e)
+            COMPREPLY=( $( compgen -W 'continue remount-ro panic' -- "$cur" ) )
+            return 0
+            ;;
+        -g)
+            _gids
+            COMPREPLY=( $( compgen -g -W '${COMPREPLY[@]}' -- "$cur" ) )
+            return 0
+            ;;
+        -M)
+            _filedir -d
+            ;;
+        -o)
+            local -a opts=(^debug ^bsdgroups ^user_xattr ^acl ^uid16
+                ^journal_data ^journal_data_ordered ^journal_data_writeback)
+            COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) )
+            return 0
+            ;;
+        -O)
+            local -a opts=(^dir_index ^dir_nlink ^extent ^extra_isize ^filetype
+                ^flex_bg ^has_journal ^huge_file ^large_file ^resize_inode
+                ^sparse_super ^uninit_bg)
+            COMPREPLY=( $( compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur" ) )
+            return 0
+            ;;
+        -u)
+            _uids
+            COMPREPLY=( $( compgen -u -W '${COMPREPLY[@]}' -- "$cur" ) )
+            return 0
+            ;;
+        -U)
+            COMPREPLY=( $( compgen -W 'clear random time' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-c -C -e -E -f -g -i -j -J -l -L -m -M -o
+            -O -r -T -u -U' -- "$cur" ) )
+    fi
+
+    cur=${cur:=/dev/}
+    _filedir
+} &&
+complete -F _tune2fs tune2fs
+
+# 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
diff --git a/.bash/bash_completion.d/findutils b/.bash/bash_completion.d/findutils
new file mode 100644 (file)
index 0000000..b8aaa57
--- /dev/null
@@ -0,0 +1,128 @@
+# bash completion for GNU find. This makes heavy use of ksh style extended
+# globs and contains Linux specific code for completing the parameter
+# to the -fstype option.
+
+have find &&
+_find()
+{
+    local cur prev i exprfound onlyonce
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -maxdepth|-mindepth)
+            COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" ) )
+            return 0
+            ;;
+        -newer|-anewer|-cnewer|-fls|-fprint|-fprint0|-fprintf|-name|-iname|\
+        -lname|-ilname|-wholename|-iwholename|-samefile)
+            _filedir
+            return 0
+            ;;
+        -fstype)
+            _fstypes
+            if [[ "$( uname -s )" == *BSD ]] ; then
+                COMPREPLY=( "${COMPREPLY[@]}" \
+                    $( compgen -W 'local rdonly' -- "$cur" ) )
+            fi
+            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)
+            COMP_WORDS=(COMP_WORDS[0] "$cur")
+            COMP_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
+    # set exprfound to 1 if there is already an expression present
+    for i in ${COMP_WORDS[@]}; do
+        [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
+    done
+
+    # handle case where first parameter is not a dash option
+    if [[ "$exprfound" != 1 && "$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" ) )
+
+    # 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).
+    onlyonce=' -daystart -depth -follow -help -ignore_readdir_race -maxdepth \
+       -mindepth -mount -noignore_readdir_race -noleaf -nowarn -regextype \
+       -version -warn -xdev '
+    COMPREPLY=( $( \
+           (while read -d ' ' i; do
+            [[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
+            continue
+            # flatten array with spaces on either side,
+            # otherwise we cannot grep on word boundaries of
+            # first and last word
+            COMPREPLY=" ${COMPREPLY[@]} "
+            # remove word from list of completions
+            COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
+            done
+            printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
+          ) )
+
+    _filedir
+
+    return 0
+} &&
+complete -F _find find
+
+# 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
diff --git a/.bash/bash_completion.d/freeciv b/.bash/bash_completion.d/freeciv
new file mode 100644 (file)
index 0000000..602ad76
--- /dev/null
@@ -0,0 +1,65 @@
+# freeciv completions
+
+have civserver &&
+_civserver()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f|-g|-l|-r|--file|--log|--gamelog|--read)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-d -f -g -h -i -l -m -M -p -q -r -v\
+            --debug --file --gamelog --help --info --log --meta \
+            --Metaserver --port --quitidle --read --version' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _civserver civserver
+
+have civclient &&
+_civclient()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -l|-S|-t|--log|--Sound|--tiles)
+            _filedir
+            return 0
+            ;;
+        -P|--Plugin)
+            COMPREPLY=( $( compgen -W 'none esd sdl' -- "$cur" ) )
+            return 0
+            ;;
+        -s|--server)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -d -h -l -m -n -p -P -s -S -t -v\
+            --autoconnect --debug --help --log --meta --name --port \
+            --Plugin --server --Sound --tiles --version' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _civclient civclient
+
+# 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
diff --git a/.bash/bash_completion.d/freerdp b/.bash/bash_completion.d/freerdp
new file mode 100644 (file)
index 0000000..82a4646
--- /dev/null
@@ -0,0 +1,47 @@
+# bash completion for xfreerdp
+
+have xfreerdp &&
+_xfreerdp()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -k)
+            COMPREPLY=( $( compgen -W "$(xfreerdp --kbd-list | \
+                   awk '/^0x/ {print $1}')" -- "$cur" ) )
+            return 0
+            ;;
+        -a)
+            COMPREPLY=( $( compgen -W '8 15 16 24 32' -- "$cur" ) )
+            return 0
+            ;;
+        -x)
+            COMPREPLY=( $( compgen -W 'b broadband m modem l lan' -- $cur ) )
+            return 0
+            ;;
+        --plugin)
+            COMPREPLY=( $( compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -t -g -a -z -f -x -O -o \
+            -k --kbd-list -h --plugin --data' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+
+} &&
+complete -F _xfreerdp xfreerdp
+
+# 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
diff --git a/.bash/bash_completion.d/fuse b/.bash/bash_completion.d/fuse
new file mode 100644 (file)
index 0000000..58d0c51
--- /dev/null
@@ -0,0 +1,36 @@
+# bash completion for fuse
+
+have fusermount &&
+_fusermount()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h|-V|-o)
+            return 0
+            ;;
+        -u)
+            COMPREPLY=( $( compgen -W "$( awk \
+                '{ if ($3 ~ /^fuse\./) print $2 }' /etc/mtab 2>/dev/null )" \
+                -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W '-h -V -o -u -q -z' -- "$cur" ) )
+    else
+        _filedir -d
+    fi
+} &&
+complete -F _fusermount fusermount
+
+# 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
diff --git a/.bash/bash_completion.d/gcc b/.bash/bash_completion.d/gcc
new file mode 100644 (file)
index 0000000..d78e3e2
--- /dev/null
@@ -0,0 +1,59 @@
+# gcc(1) completion
+#
+# The only unusual feature is that we don't parse "gcc --help -v" output
+# directly, because that would include the options of all the other backend
+# tools (linker, assembler, preprocessor, etc) without any indication that
+# you cannot feed such options to the gcc driver directly.  (For example, the
+# linker takes a -z option, but you must type -Wl,-z for gcc.)  Instead, we
+# ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
+# --help output of the compiler.
+
+have gcc &&
+_gcc()
+{
+    local cur cc backend
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _expand || return 0
+
+    case $1 in
+        gcj)
+            backend=jc1
+            ;;
+        gpc)
+            backend=gpc1
+            ;;
+        *77)
+            backend=f771
+            ;;
+        *)
+            backend=cc1 # (near-)universal backend
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        cc=$( $1 -print-prog-name=$backend )
+        # sink stderr:
+        # for C/C++/ObjectiveC it's useless
+        # for FORTRAN/Java it's an error
+        COMPREPLY=( $( compgen -W "$( $cc --help 2>/dev/null | \
+           tr '\t' ' ' | \
+           sed -e '/^  *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
+           sort -u )" -- "$cur" ) )
+    else
+        _filedir
+    fi
+} &&
+complete -F _gcc gcc g++ c++ g77 gcj gpc
+[ $USERLAND = GNU -o $UNAME = Cygwin ] && \
+[ -n "${have:-}" ] && complete -F _gcc cc
+
+# 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
diff --git a/.bash/bash_completion.d/gcl b/.bash/bash_completion.d/gcl
new file mode 100644 (file)
index 0000000..e093153
--- /dev/null
@@ -0,0 +1,30 @@
+# bash programmable completion for various Common Lisp implementations by
+# Nikodemus Siivola <nikodemus@random-state.net>
+
+have gcl &&
+_gcl()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    # completing an option (may or may not be separated by a space)
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-eval -load -f -batch -dir -libdir \
+            -compile -o-file -c-file -h-file -data-file -system-p '-- "$cur" ) )
+    else
+        _filedir
+    fi
+
+    return 0
+} &&
+complete -F _gcl -o default gcl
+
+# 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
diff --git a/.bash/bash_completion.d/gdb b/.bash/bash_completion.d/gdb
new file mode 100644 (file)
index 0000000..f0bc42d
--- /dev/null
@@ -0,0 +1,44 @@
+# bash completion for gdb
+
+have gdb &&
+_gdb()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        local IFS
+        _compopt_o_filenames
+        if [[ "$cur" == */* ]]; then
+            # compgen -c works as expected if $cur contains any slashes.
+            IFS=$'\n'
+            COMPREPLY=( $( PATH="$PATH:." compgen -d -c -- "$cur" ) )
+        else
+            # otherwise compgen -c contains Bash's built-in commands,
+            # functions and aliases. Thus we need to retrieve the program
+            # names manually.
+            IFS=":"
+            local path_array=( $( \
+                sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" ) )
+            IFS=$'\n'
+            COMPREPLY=( $( compgen -d -W '$(find "${path_array[@]}" . \
+                -mindepth 1 -maxdepth 1 -not -type d -executable \
+                -printf "%f\\n" 2>/dev/null)' -- "$cur" ) )
+        fi
+    elif [ $COMP_CWORD -eq 2 ]; then
+        prev=${prev##*/}
+        COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
+            awk '{if ($1 ~ /^'"$prev"'/) print $2}' )" -- "$cur" ) )
+    fi
+} &&
+complete -F _gdb -o default gdb
+
+# 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
diff --git a/.bash/bash_completion.d/gdbus b/.bash/bash_completion.d/gdbus
new file mode 100644 (file)
index 0000000..79f4cb4
--- /dev/null
@@ -0,0 +1,33 @@
+
+# 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
diff --git a/.bash/bash_completion.d/genisoimage b/.bash/bash_completion.d/genisoimage
new file mode 100644 (file)
index 0000000..61b1811
--- /dev/null
@@ -0,0 +1,77 @@
+# bash completion for mkisofs/genisoimage
+
+(have mkisofs || have genisoimage) &&
+_mkisofs()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -o|-abstract|-biblio|-check-session|-copyright|-log-file| \
+        -root-info|-prep-boot|-*-list)
+            _filedir
+            return 0
+            ;;
+        -*-charset)
+            COMPREPLY=( $( compgen -W '$( mkisofs -input-charset \
+                    help 2>&1 | tail -n +3 )' -- "$cur" ) )
+            return 0
+            ;;
+        -uid)
+            _uids
+            return 0
+            ;;
+        -gid)
+            _gids
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-abstract -appid -allow-lowercase \
+            -allow-multidot -biblio -cache-inodes -no-cache-inodes \
+            -eltorito-boot -eltorito-alt-boot -sparc-boot -generic-boot \
+            -hard-disk-boot -no-emul-boot -no-boot -boot-load-seg \
+            -boot-load-size -boot-info-table -cdrecord-params \
+            -eltorito-catalog -check-oldname -check-session -copyright \
+            -omit-period -disable-deep-relocation -dir-mode -dvd-video \
+            -follow-links -file-mode -gid -gui -graft-points -hide -hide-list \
+            -hidden -hidden-list -hide-joliet -hide-joliet-list \
+            -hide-joliet-trans-tbl -hide-rr-moved -input-charset \
+            -output-charset -iso-level -joliet -joliet-long -jcharset \
+            -full-iso9660-filenames -allow-leading-dots -log-file -exclude \
+            -exclude-list -max-iso9660-filenames -prev-session \
+            -omit-version-number -new-dir-mode -nobak -no-bak -force-rr -no-rr \
+            -no-split-symlink-components -no-split-symlink-fields -output -pad \
+            -no-pad -path-list -publisher -preparer -print-size -quiet -rock
+            -rational-rock -relaxed-filenames -sort -split-output \
+            -stream-media-size -stream-file-name -sysid -translation-table \
+            -table-name -ucs-level -udf -uid -use-fileversion \
+            -untranslated-filenames -no-iso-translate -volid -volset \
+            -volset-size -volset-seqno -verbose -old-exclude \
+            -transparent-compression -hfs -apple -map -magic -hfs-creator \
+            -hfs-type -probe -no-desktop -mac-name \
+            -boot-hfs-file -part -auto -cluster-size \
+            -hide-hfs -hide-hfs-list -hfs-volid \
+            -icon-position -root-info -prep-boot \
+            -input-hfs-charset -output-hfs-charset \
+            -hfs-unlock -hfs-bless -hfs-parms --cap \
+            --netatalk --double --ethershare --ushare \
+            --exchange --sgi --xinet --macbin --single \
+            --dave --sfm --osx-double --osx-hfs' -- "$cur" ))
+    else
+        _filedir
+    fi
+
+} &&
+complete -F _mkisofs mkisofs genisoimage
+
+# 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
diff --git a/.bash/bash_completion.d/getent b/.bash/bash_completion.d/getent
new file mode 100644 (file)
index 0000000..54e62ab
--- /dev/null
@@ -0,0 +1,55 @@
+# bash completion for getent
+
+have getent &&
+_getent()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        passwd)
+            COMPREPLY=( $( compgen -u "$cur"  ) )
+            return 0
+            ;;
+        group)
+            COMPREPLY=( $( compgen -g "$cur"  ) )
+            return 0
+            ;;
+        services)
+            COMPREPLY=( $( compgen -s "$cur"  ) )
+            return 0
+            ;;
+        hosts)
+            COMPREPLY=( $( compgen -A hostname "$cur"  ) )
+            return 0
+            ;;
+        protocols|networks|ahosts|ahostsv4|ahostsv6|rpc)
+            COMPREPLY=( $( compgen -W "$( getent "$prev" | \
+                awk '{ print $1 }' )" -- "$cur" ) )
+            return 0
+            ;;
+        aliases|shadow)
+            COMPREPLY=( $( compgen -W "$( getent "$prev" | cut -d: -f1 )" \
+                -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -W 'passwd group hosts services protocols \
+            networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc \
+            shadow' -- "$cur" ) )
+    fi
+} &&
+complete -F _getent getent
+
+# 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
diff --git a/.bash/bash_completion.d/git b/.bash/bash_completion.d/git
new file mode 100644 (file)
index 0000000..1496c6d
--- /dev/null
@@ -0,0 +1,2765 @@
+#!bash
+#
+# bash/zsh completion support for core Git.
+#
+# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
+# 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'
+#    *) tree paths within 'ref:path/to/file' expressions
+#    *) common --long-options
+#
+# To use these routines:
+#
+#    1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
+#    2) Add the following line to your .bashrc/.zshrc:
+#        source ~/.git-completion.sh
+#
+#    3) Consider changing your PS1 to also show the current branch:
+#         Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
+#         ZSH:  PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
+#
+#       The argument to __git_ps1 will be displayed only if you
+#       are currently in a git repository.  The %s token will be
+#       the name of the current branch.
+#
+#       In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
+#       value, unstaged (*) and staged (+) changes will be shown next
+#       to the branch name.  You can configure this per-repository
+#       with the bash.showDirtyState variable, which defaults to true
+#       once GIT_PS1_SHOWDIRTYSTATE is enabled.
+#
+#       You can also see if currently something is stashed, by setting
+#       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
+#       then a '$' will be shown next to the branch name.
+#
+#       If you would like to see if there're untracked files, then you can
+#       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
+#       untracked files, then a '%' will be shown next to the branch name.
+#
+#       If you would like to see the difference between HEAD and its
+#       upstream, set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates
+#       you are behind, ">" indicates you are ahead, and "<>"
+#       indicates you have diverged.  You can further control
+#       behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated
+#       list of values:
+#           verbose       show number of commits ahead/behind (+/-) upstream
+#           legacy        don't use the '--count' option available in recent
+#                         versions of git-rev-list
+#           git           always compare HEAD to @{upstream}
+#           svn           always compare HEAD to your SVN upstream
+#       By default, __git_ps1 will compare HEAD to your SVN upstream
+#       if it can find one, or @{upstream} otherwise.  Once you have
+#       set GIT_PS1_SHOWUPSTREAM, you can override it on a
+#       per-repository basis by setting the bash.showUpstream config
+#       variable.
+#
+#
+# To submit patches:
+#
+#    *) Read Documentation/SubmittingPatches
+#    *) Send all patches to the current maintainer:
+#
+#       "Shawn O. Pearce" <spearce@spearce.org>
+#
+#    *) Always CC the Git mailing list:
+#
+#       git@vger.kernel.org
+#
+
+if [[ -n ${ZSH_VERSION-} ]]; then
+       autoload -U +X bashcompinit && bashcompinit
+fi
+
+case "$COMP_WORDBREAKS" in
+*:*) : great ;;
+*)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
+esac
+
+# __gitdir accepts 0 or 1 arguments (i.e., location)
+# returns location of .git repo
+__gitdir ()
+{
+       if [ -z "${1-}" ]; then
+               if [ -n "${__git_dir-}" ]; then
+                       echo "$__git_dir"
+               elif [ -d .git ]; then
+                       echo .git
+               else
+                       git rev-parse --git-dir 2>/dev/null
+               fi
+       elif [ -d "$1/.git" ]; then
+               echo "$1/.git"
+       else
+               echo "$1"
+       fi
+}
+
+# stores the divergence from upstream in $p
+# used by GIT_PS1_SHOWUPSTREAM
+__git_ps1_show_upstream ()
+{
+       local key value
+       local svn_remote=() svn_url_pattern count n
+       local upstream=git legacy="" verbose=""
+
+       # get some config options from git-config
+       local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
+       while read -r key value; do
+               case "$key" in
+               bash.showupstream)
+                       GIT_PS1_SHOWUPSTREAM="$value"
+                       if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
+                               p=""
+                               return
+                       fi
+                       ;;
+               svn-remote.*.url)
+                       svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
+                       svn_url_pattern+="\\|$value"
+                       upstream=svn+git # default upstream is SVN if available, else git
+                       ;;
+               esac
+       done <<< "$output"
+
+       # parse configuration values
+       for option in ${GIT_PS1_SHOWUPSTREAM}; do
+               case "$option" in
+               git|svn) upstream="$option" ;;
+               verbose) verbose=1 ;;
+               legacy)  legacy=1  ;;
+               esac
+       done
+
+       # Find our upstream
+       case "$upstream" in
+       git)    upstream="@{upstream}" ;;
+       svn*)
+               # get the upstream from the "git-svn-id: ..." in a commit message
+               # (git-svn uses essentially the same procedure internally)
+               local svn_upstream=($(git log --first-parent -1 \
+                                       --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
+               if [[ 0 -ne ${#svn_upstream[@]} ]]; then
+                       svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
+                       svn_upstream=${svn_upstream%@*}
+                       local n_stop="${#svn_remote[@]}"
+                       for ((n=1; n <= n_stop; ++n)); do
+                               svn_upstream=${svn_upstream#${svn_remote[$n]}}
+                       done
+
+                       if [[ -z "$svn_upstream" ]]; then
+                               # default branch name for checkouts with no layout:
+                               upstream=${GIT_SVN_ID:-git-svn}
+                       else
+                               upstream=${svn_upstream#/}
+                       fi
+               elif [[ "svn+git" = "$upstream" ]]; then
+                       upstream="@{upstream}"
+               fi
+               ;;
+       esac
+
+       # Find how many commits we are ahead/behind our upstream
+       if [[ -z "$legacy" ]]; then
+               count="$(git rev-list --count --left-right \
+                               "$upstream"...HEAD 2>/dev/null)"
+       else
+               # produce equivalent output to --count for older versions of git
+               local commits
+               if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
+               then
+                       local commit behind=0 ahead=0
+                       for commit in $commits
+                       do
+                               case "$commit" in
+                               "<"*) let ++behind
+                                       ;;
+                               *)    let ++ahead
+                                       ;;
+                               esac
+                       done
+                       count="$behind  $ahead"
+               else
+                       count=""
+               fi
+       fi
+
+       # calculate the result
+       if [[ -z "$verbose" ]]; then
+               case "$count" in
+               "") # no upstream
+                       p="" ;;
+               "0      0") # equal to upstream
+                       p="=" ;;
+               "0      "*) # ahead of upstream
+                       p=">" ;;
+               *"      0") # behind upstream
+                       p="<" ;;
+               *)          # diverged from upstream
+                       p="<>" ;;
+               esac
+       else
+               case "$count" in
+               "") # no upstream
+                       p="" ;;
+               "0      0") # equal to upstream
+                       p=" u=" ;;
+               "0      "*) # ahead of upstream
+                       p=" u+${count#0 }" ;;
+               *"      0") # behind upstream
+                       p=" u-${count%  0}" ;;
+               *)          # diverged from upstream
+                       p=" u+${count#* }-${count%      *}" ;;
+               esac
+       fi
+
+}
+
+
+# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
+# returns text to add to bash PS1 prompt (includes branch name)
+__git_ps1 ()
+{
+       local g="$(__gitdir)"
+       if [ -n "$g" ]; then
+               local r=""
+               local b=""
+               if [ -f "$g/rebase-merge/interactive" ]; then
+                       r="|REBASE-i"
+                       b="$(cat "$g/rebase-merge/head-name")"
+               elif [ -d "$g/rebase-merge" ]; then
+                       r="|REBASE-m"
+                       b="$(cat "$g/rebase-merge/head-name")"
+               else
+                       if [ -d "$g/rebase-apply" ]; then
+                               if [ -f "$g/rebase-apply/rebasing" ]; then
+                                       r="|REBASE"
+                               elif [ -f "$g/rebase-apply/applying" ]; then
+                                       r="|AM"
+                               else
+                                       r="|AM/REBASE"
+                               fi
+                       elif [ -f "$g/MERGE_HEAD" ]; then
+                               r="|MERGING"
+                       elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
+                               r="|CHERRY-PICKING"
+                       elif [ -f "$g/BISECT_LOG" ]; then
+                               r="|BISECTING"
+                       fi
+
+                       b="$(git symbolic-ref HEAD 2>/dev/null)" || {
+
+                               b="$(
+                               case "${GIT_PS1_DESCRIBE_STYLE-}" in
+                               (contains)
+                                       git describe --contains HEAD ;;
+                               (branch)
+                                       git describe --contains --all HEAD ;;
+                               (describe)
+                                       git describe HEAD ;;
+                               (* | default)
+                                       git describe --tags --exact-match HEAD ;;
+                               esac 2>/dev/null)" ||
+
+                               b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
+                               b="unknown"
+                               b="($b)"
+                       }
+               fi
+
+               local w=""
+               local i=""
+               local s=""
+               local u=""
+               local c=""
+               local p=""
+
+               if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
+                       if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
+                               c="BARE:"
+                       else
+                               b="GIT_DIR!"
+                       fi
+               elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
+                       if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
+                               if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
+                                       git diff --no-ext-diff --quiet --exit-code || w="*"
+                                       if git rev-parse --quiet --verify HEAD >/dev/null; then
+                                               git diff-index --cached --quiet HEAD -- || i="+"
+                                       else
+                                               i="#"
+                                       fi
+                               fi
+                       fi
+                       if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
+                               git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
+                       fi
+
+                       if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
+                          if [ -n "$(git ls-files --others --exclude-standard)" ]; then
+                             u="%"
+                          fi
+                       fi
+
+                       if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
+                               __git_ps1_show_upstream
+                       fi
+               fi
+
+               local f="$w$i$s$u"
+               printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
+       fi
+}
+
+# __gitcomp_1 requires 2 arguments
+__gitcomp_1 ()
+{
+       local c IFS=' '$'\t'$'\n'
+       for c in $1; do
+               case "$c$2" in
+               --*=*) printf %s$'\n' "$c$2" ;;
+               *.)    printf %s$'\n' "$c$2" ;;
+               *)     printf %s$'\n' "$c$2 " ;;
+               esac
+       done
+}
+
+# The following function is based on code from:
+#
+#   bash_completion - programmable completion functions for bash 3.2+
+#
+#   Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
+#             © 2009-2010, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#   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=<type> and <rev>:<path> 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
+if [[ -z ${ZSH_VERSION:+set} ]]; 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
+}
+else
+_get_comp_words_by_ref ()
+{
+       while [ $# -gt 0 ]; do
+               case "$1" in
+               cur)
+                       cur=${COMP_WORDS[COMP_CWORD]}
+                       ;;
+               prev)
+                       prev=${COMP_WORDS[COMP_CWORD-1]}
+                       ;;
+               words)
+                       words=("${COMP_WORDS[@]}")
+                       ;;
+               cword)
+                       cword=$COMP_CWORD
+                       ;;
+               -n)
+                       # assume COMP_WORDBREAKS is already set sanely
+                       shift
+                       ;;
+               esac
+               shift
+       done
+}
+fi
+fi
+
+# Generates completion reply with compgen, 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_="$cur"
+
+       if [ $# -gt 2 ]; then
+               cur_="$3"
+       fi
+       case "$cur_" in
+       --*=)
+               COMPREPLY=()
+               ;;
+       *)
+               local IFS=$'\n'
+               COMPREPLY=($(compgen -P "${2-}" \
+                       -W "$(__gitcomp_1 "${1-}" "${4-}")" \
+                       -- "$cur_"))
+               ;;
+       esac
+}
+
+# Generates completion reply with compgen 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 ()
+{
+       local s=$'\n' IFS=' '$'\t'$'\n'
+       local cur_="$cur" suffix=" "
+
+       if [ $# -gt 2 ]; then
+               cur_="$3"
+               if [ $# -gt 3 ]; then
+                       suffix="$4"
+               fi
+       fi
+
+       IFS=$s
+       COMPREPLY=($(compgen -P "${2-}" -S "$suffix" -W "$1" -- "$cur_"))
+}
+
+__git_heads ()
+{
+       local dir="$(__gitdir)"
+       if [ -d "$dir" ]; then
+               git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
+                       refs/heads
+               return
+       fi
+}
+
+__git_tags ()
+{
+       local dir="$(__gitdir)"
+       if [ -d "$dir" ]; then
+               git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
+                       refs/tags
+               return
+       fi
+}
+
+# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
+# presence of 2nd argument means use the guess heuristic employed
+# by checkout for tracking branches
+__git_refs ()
+{
+       local i hash dir="$(__gitdir "${1-}")" track="${2-}"
+       local format refs
+       if [ -d "$dir" ]; then
+               case "$cur" in
+               refs|refs/*)
+                       format="refname"
+                       refs="${cur%/*}"
+                       track=""
+                       ;;
+               *)
+                       for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
+                               if [ -e "$dir/$i" ]; then echo $i; fi
+                       done
+                       format="refname:short"
+                       refs="refs/tags refs/heads refs/remotes"
+                       ;;
+               esac
+               git --git-dir="$dir" for-each-ref --format="%($format)" \
+                       $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
+                       local ref entry
+                       git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
+                               "refs/remotes/" | \
+                       while read -r entry; do
+                               eval "$entry"
+                               ref="${ref#*/}"
+                               if [[ "$ref" == "$cur"* ]]; then
+                                       echo "$ref"
+                               fi
+                       done | uniq -u
+               fi
+               return
+       fi
+       case "$cur" in
+       refs|refs/*)
+               git ls-remote "$dir" "$cur*" 2>/dev/null | \
+               while read -r hash i; do
+                       case "$i" in
+                       *^{}) ;;
+                       *) echo "$i" ;;
+                       esac
+               done
+               ;;
+       *)
+               git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
+               while read -r hash i; do
+                       case "$i" in
+                       *^{}) ;;
+                       refs/*) echo "${i#refs/*/}" ;;
+                       *) echo "$i" ;;
+                       esac
+               done
+               ;;
+       esac
+}
+
+# __git_refs2 requires 1 argument (to pass to __git_refs)
+__git_refs2 ()
+{
+       local i
+       for i in $(__git_refs "$1"); do
+               echo "$i:$i"
+       done
+}
+
+# __git_refs_remotes requires 1 argument (to pass to ls-remote)
+__git_refs_remotes ()
+{
+       local i hash
+       git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
+       while read -r hash i; do
+               echo "$i:refs/remotes/$1/${i#refs/heads/}"
+       done
+}
+
+__git_remotes ()
+{
+       local i ngoff IFS=$'\n' d="$(__gitdir)"
+       __git_shopt -q nullglob || ngoff=1
+       __git_shopt -s nullglob
+       for i in "$d/remotes"/*; do
+               echo ${i#$d/remotes/}
+       done
+       [ "$ngoff" ] && __git_shopt -u nullglob
+       for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
+               i="${i#remote.}"
+               echo "${i/.url*/}"
+       done
+}
+
+__git_list_merge_strategies ()
+{
+       git merge -s help 2>&1 |
+       sed -n -e '/[Aa]vailable strategies are: /,/^$/{
+               s/\.$//
+               s/.*://
+               s/^[    ]*//
+               s/[     ]*$//
+               p
+       }'
+}
+
+__git_merge_strategies=
+# 'git merge -s help' (and thus detection of the merge strategy
+# list) fails, unfortunately, if run outside of any git working
+# tree.  __git_merge_strategies is set to the empty string in
+# that case, and the detection will be repeated the next time it
+# is needed.
+__git_compute_merge_strategies ()
+{
+       : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
+}
+
+__git_complete_revlist_file ()
+{
+       local pfx ls ref cur_="$cur"
+       case "$cur_" in
+       *..?*:*)
+               return
+               ;;
+       ?*:*)
+               ref="${cur_%%:*}"
+               cur_="${cur_#*:}"
+               case "$cur_" in
+               ?*/*)
+                       pfx="${cur_%/*}"
+                       cur_="${cur_##*/}"
+                       ls="$ref:$pfx"
+                       pfx="$pfx/"
+                       ;;
+               *)
+                       ls="$ref"
+                       ;;
+               esac
+
+               case "$COMP_WORDBREAKS" in
+               *:*) : great ;;
+               *)   pfx="$ref:$pfx" ;;
+               esac
+
+               local IFS=$'\n'
+               COMPREPLY=($(compgen -P "$pfx" \
+                       -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
+                               | sed '/^100... blob /{
+                                          s,^.*        ,,
+                                          s,$, ,
+                                      }
+                                      /^120000 blob /{
+                                          s,^.*        ,,
+                                          s,$, ,
+                                      }
+                                      /^040000 tree /{
+                                          s,^.*        ,,
+                                          s,$,/,
+                                      }
+                                      s/^.*    //')" \
+                       -- "$cur_"))
+               ;;
+       *...*)
+               pfx="${cur_%...*}..."
+               cur_="${cur_#*...}"
+               __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+               ;;
+       *..*)
+               pfx="${cur_%..*}.."
+               cur_="${cur_#*..}"
+               __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+               ;;
+       *)
+               __gitcomp_nl "$(__git_refs)"
+               ;;
+       esac
+}
+
+
+__git_complete_file ()
+{
+       __git_complete_revlist_file
+}
+
+__git_complete_revlist ()
+{
+       __git_complete_revlist_file
+}
+
+__git_complete_remote_or_refspec ()
+{
+       local cur_="$cur" cmd="${words[1]}"
+       local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
+       while [ $c -lt $cword ]; do
+               i="${words[c]}"
+               case "$i" in
+               --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
+               --all)
+                       case "$cmd" in
+                       push) no_complete_refspec=1 ;;
+                       fetch)
+                               COMPREPLY=()
+                               return
+                               ;;
+                       *) ;;
+                       esac
+                       ;;
+               -*) ;;
+               *) remote="$i"; break ;;
+               esac
+               c=$((++c))
+       done
+       if [ -z "$remote" ]; then
+               __gitcomp_nl "$(__git_remotes)"
+               return
+       fi
+       if [ $no_complete_refspec = 1 ]; then
+               COMPREPLY=()
+               return
+       fi
+       [ "$remote" = "." ] && remote=
+       case "$cur_" in
+       *:*)
+               case "$COMP_WORDBREAKS" in
+               *:*) : great ;;
+               *)   pfx="${cur_%%:*}:" ;;
+               esac
+               cur_="${cur_#*:}"
+               lhs=0
+               ;;
+       +*)
+               pfx="+"
+               cur_="${cur_#+}"
+               ;;
+       esac
+       case "$cmd" in
+       fetch)
+               if [ $lhs = 1 ]; then
+                       __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
+               else
+                       __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+               fi
+               ;;
+       pull)
+               if [ $lhs = 1 ]; then
+                       __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
+               else
+                       __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+               fi
+               ;;
+       push)
+               if [ $lhs = 1 ]; then
+                       __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
+               else
+                       __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
+               fi
+               ;;
+       esac
+}
+
+__git_complete_strategy ()
+{
+       __git_compute_merge_strategies
+       case "$prev" in
+       -s|--strategy)
+               __gitcomp "$__git_merge_strategies"
+               return 0
+       esac
+       case "$cur" in
+       --strategy=*)
+               __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
+               return 0
+               ;;
+       esac
+       return 1
+}
+
+__git_list_all_commands ()
+{
+       local i IFS=" "$'\n'
+       for i in $(git help -a|egrep '^  [a-zA-Z0-9]')
+       do
+               case $i in
+               *--*)             : helper pattern;;
+               *) echo $i;;
+               esac
+       done
+}
+
+__git_all_commands=
+__git_compute_all_commands ()
+{
+       : ${__git_all_commands:=$(__git_list_all_commands)}
+}
+
+__git_list_porcelain_commands ()
+{
+       local i IFS=" "$'\n'
+       __git_compute_all_commands
+       for i in "help" $__git_all_commands
+       do
+               case $i in
+               *--*)             : helper pattern;;
+               applymbox)        : ask gittus;;
+               applypatch)       : ask gittus;;
+               archimport)       : import;;
+               cat-file)         : plumbing;;
+               check-attr)       : plumbing;;
+               check-ref-format) : plumbing;;
+               checkout-index)   : plumbing;;
+               commit-tree)      : plumbing;;
+               count-objects)    : infrequent;;
+               cvsexportcommit)  : export;;
+               cvsimport)        : import;;
+               cvsserver)        : daemon;;
+               daemon)           : daemon;;
+               diff-files)       : plumbing;;
+               diff-index)       : plumbing;;
+               diff-tree)        : plumbing;;
+               fast-import)      : import;;
+               fast-export)      : export;;
+               fsck-objects)     : plumbing;;
+               fetch-pack)       : plumbing;;
+               fmt-merge-msg)    : plumbing;;
+               for-each-ref)     : plumbing;;
+               hash-object)      : plumbing;;
+               http-*)           : transport;;
+               index-pack)       : plumbing;;
+               init-db)          : deprecated;;
+               local-fetch)      : plumbing;;
+               lost-found)       : infrequent;;
+               ls-files)         : plumbing;;
+               ls-remote)        : plumbing;;
+               ls-tree)          : plumbing;;
+               mailinfo)         : plumbing;;
+               mailsplit)        : plumbing;;
+               merge-*)          : plumbing;;
+               mktree)           : plumbing;;
+               mktag)            : plumbing;;
+               pack-objects)     : plumbing;;
+               pack-redundant)   : plumbing;;
+               pack-refs)        : plumbing;;
+               parse-remote)     : plumbing;;
+               patch-id)         : plumbing;;
+               peek-remote)      : plumbing;;
+               prune)            : plumbing;;
+               prune-packed)     : plumbing;;
+               quiltimport)      : import;;
+               read-tree)        : plumbing;;
+               receive-pack)     : plumbing;;
+               remote-*)         : transport;;
+               repo-config)      : deprecated;;
+               rerere)           : plumbing;;
+               rev-list)         : plumbing;;
+               rev-parse)        : plumbing;;
+               runstatus)        : plumbing;;
+               sh-setup)         : internal;;
+               shell)            : daemon;;
+               show-ref)         : plumbing;;
+               send-pack)        : plumbing;;
+               show-index)       : plumbing;;
+               ssh-*)            : transport;;
+               stripspace)       : plumbing;;
+               symbolic-ref)     : plumbing;;
+               tar-tree)         : deprecated;;
+               unpack-file)      : plumbing;;
+               unpack-objects)   : plumbing;;
+               update-index)     : plumbing;;
+               update-ref)       : plumbing;;
+               update-server-info) : daemon;;
+               upload-archive)   : plumbing;;
+               upload-pack)      : plumbing;;
+               write-tree)       : plumbing;;
+               var)              : infrequent;;
+               verify-pack)      : infrequent;;
+               verify-tag)       : plumbing;;
+               *) echo $i;;
+               esac
+       done
+}
+
+__git_porcelain_commands=
+__git_compute_porcelain_commands ()
+{
+       __git_compute_all_commands
+       : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
+}
+
+__git_pretty_aliases ()
+{
+       local i IFS=$'\n'
+       for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
+               case "$i" in
+               pretty.*)
+                       i="${i#pretty.}"
+                       echo "${i/ */}"
+                       ;;
+               esac
+       done
+}
+
+__git_aliases ()
+{
+       local i IFS=$'\n'
+       for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
+               case "$i" in
+               alias.*)
+                       i="${i#alias.}"
+                       echo "${i/ */}"
+                       ;;
+               esac
+       done
+}
+
+# __git_aliased_command requires 1 argument
+__git_aliased_command ()
+{
+       local word cmdline=$(git --git-dir="$(__gitdir)" \
+               config --get "alias.$1")
+       for word in $cmdline; do
+               case "$word" in
+               \!gitk|gitk)
+                       echo "gitk"
+                       return
+                       ;;
+               \!*)    : shell command alias ;;
+               -*)     : option ;;
+               *=*)    : setting env ;;
+               git)    : git itself ;;
+               *)
+                       echo "$word"
+                       return
+               esac
+       done
+}
+
+# __git_find_on_cmdline requires 1 argument
+__git_find_on_cmdline ()
+{
+       local word subcommand c=1
+       while [ $c -lt $cword ]; do
+               word="${words[c]}"
+               for subcommand in $1; do
+                       if [ "$subcommand" = "$word" ]; then
+                               echo "$subcommand"
+                               return
+                       fi
+               done
+               c=$((++c))
+       done
+}
+
+__git_has_doubledash ()
+{
+       local c=1
+       while [ $c -lt $cword ]; do
+               if [ "--" = "${words[c]}" ]; then
+                       return 0
+               fi
+               c=$((++c))
+       done
+       return 1
+}
+
+__git_whitespacelist="nowarn warn error error-all fix"
+
+_git_am ()
+{
+       local dir="$(__gitdir)"
+       if [ -d "$dir"/rebase-apply ]; then
+               __gitcomp "--skip --continue --resolved --abort"
+               return
+       fi
+       case "$cur" in
+       --whitespace=*)
+               __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --3way --committer-date-is-author-date --ignore-date
+                       --ignore-whitespace --ignore-space-change
+                       --interactive --keep --no-utf8 --signoff --utf8
+                       --whitespace= --scissors
+                       "
+               return
+       esac
+       COMPREPLY=()
+}
+
+_git_apply ()
+{
+       case "$cur" in
+       --whitespace=*)
+               __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --stat --numstat --summary --check --index
+                       --cached --index-info --reverse --reject --unidiff-zero
+                       --apply --no-add --exclude=
+                       --ignore-whitespace --ignore-space-change
+                       --whitespace= --inaccurate-eof --verbose
+                       "
+               return
+       esac
+       COMPREPLY=()
+}
+
+_git_add ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --interactive --refresh --patch --update --dry-run
+                       --ignore-errors --intent-to-add
+                       "
+               return
+       esac
+       COMPREPLY=()
+}
+
+_git_archive ()
+{
+       case "$cur" in
+       --format=*)
+               __gitcomp "$(git archive --list)" "" "${cur##--format=}"
+               return
+               ;;
+       --remote=*)
+               __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --format= --list --verbose
+                       --prefix= --remote= --exec=
+                       "
+               return
+               ;;
+       esac
+       __git_complete_file
+}
+
+_git_bisect ()
+{
+       __git_has_doubledash && return
+
+       local subcommands="start bad good skip reset visualize replay log run"
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       if [ -z "$subcommand" ]; then
+               if [ -f "$(__gitdir)"/BISECT_START ]; then
+                       __gitcomp "$subcommands"
+               else
+                       __gitcomp "replay start"
+               fi
+               return
+       fi
+
+       case "$subcommand" in
+       bad|good|reset|skip|start)
+               __gitcomp_nl "$(__git_refs)"
+               ;;
+       *)
+               COMPREPLY=()
+               ;;
+       esac
+}
+
+_git_branch ()
+{
+       local i c=1 only_local_ref="n" has_r="n"
+
+       while [ $c -lt $cword ]; do
+               i="${words[c]}"
+               case "$i" in
+               -d|-m)  only_local_ref="y" ;;
+               -r)     has_r="y" ;;
+               esac
+               c=$((++c))
+       done
+
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --color --no-color --verbose --abbrev= --no-abbrev
+                       --track --no-track --contains --merged --no-merged
+                       --set-upstream
+                       "
+               ;;
+       *)
+               if [ $only_local_ref = "y" -a $has_r = "n" ]; then
+                       __gitcomp_nl "$(__git_heads)"
+               else
+                       __gitcomp_nl "$(__git_refs)"
+               fi
+               ;;
+       esac
+}
+
+_git_bundle ()
+{
+       local cmd="${words[2]}"
+       case "$cword" in
+       2)
+               __gitcomp "create list-heads verify unbundle"
+               ;;
+       3)
+               # looking for a file
+               ;;
+       *)
+               case "$cmd" in
+                       create)
+                               __git_complete_revlist
+                       ;;
+               esac
+               ;;
+       esac
+}
+
+_git_checkout ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --conflict=*)
+               __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+               ;;
+       --*)
+               __gitcomp "
+                       --quiet --ours --theirs --track --no-track --merge
+                       --conflict= --orphan --patch
+                       "
+               ;;
+       *)
+               # check if --track, --no-track, or --no-guess was specified
+               # if so, disable DWIM mode
+               local flags="--track --no-track --no-guess" track=1
+               if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
+                       track=''
+               fi
+               __gitcomp_nl "$(__git_refs '' $track)"
+               ;;
+       esac
+}
+
+_git_cherry ()
+{
+       __gitcomp "$(__git_refs)"
+}
+
+_git_cherry_pick ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "--edit --no-commit"
+               ;;
+       *)
+               __gitcomp_nl "$(__git_refs)"
+               ;;
+       esac
+}
+
+_git_clean ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "--dry-run --quiet"
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_clone ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --local
+                       --no-hardlinks
+                       --shared
+                       --reference
+                       --quiet
+                       --no-checkout
+                       --bare
+                       --mirror
+                       --origin
+                       --upload-pack
+                       --template=
+                       --depth
+                       "
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_commit ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --cleanup=*)
+               __gitcomp "default strip verbatim whitespace
+                       " "" "${cur##--cleanup=}"
+               return
+               ;;
+       --reuse-message=*|--reedit-message=*|\
+       --fixup=*|--squash=*)
+               __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
+               return
+               ;;
+       --untracked-files=*)
+               __gitcomp "all no normal" "" "${cur##--untracked-files=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --all --author= --signoff --verify --no-verify
+                       --edit --amend --include --only --interactive
+                       --dry-run --reuse-message= --reedit-message=
+                       --reset-author --file= --message= --template=
+                       --cleanup= --untracked-files --untracked-files=
+                       --verbose --quiet --fixup= --squash=
+                       "
+               return
+       esac
+       COMPREPLY=()
+}
+
+_git_describe ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --all --tags --contains --abbrev= --candidates=
+                       --exact-match --debug --long --match --always
+                       "
+               return
+       esac
+       __gitcomp_nl "$(__git_refs)"
+}
+
+__git_diff_common_options="--stat --numstat --shortstat --summary
+                       --patch-with-stat --name-only --name-status --color
+                       --no-color --color-words --no-renames --check
+                       --full-index --binary --abbrev --diff-filter=
+                       --find-copies-harder
+                       --text --ignore-space-at-eol --ignore-space-change
+                       --ignore-all-space --exit-code --quiet --ext-diff
+                       --no-ext-diff
+                       --no-prefix --src-prefix= --dst-prefix=
+                       --inter-hunk-context=
+                       --patience
+                       --raw
+                       --dirstat --dirstat= --dirstat-by-file
+                       --dirstat-by-file= --cumulative
+"
+
+_git_diff ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
+                       --base --ours --theirs --no-index
+                       $__git_diff_common_options
+                       "
+               return
+               ;;
+       esac
+       __git_complete_revlist_file
+}
+
+__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
+                       tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
+"
+
+_git_difftool ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --tool=*)
+               __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
+               return
+               ;;
+       --*)
+               __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
+                       --base --ours --theirs
+                       --no-renames --diff-filter= --find-copies-harder
+                       --relative --ignore-submodules
+                       --tool="
+               return
+               ;;
+       esac
+       __git_complete_file
+}
+
+__git_fetch_options="
+       --quiet --verbose --append --upload-pack --force --keep --depth=
+       --tags --no-tags --all --prune --dry-run
+"
+
+_git_fetch ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "$__git_fetch_options"
+               return
+               ;;
+       esac
+       __git_complete_remote_or_refspec
+}
+
+_git_format_patch ()
+{
+       case "$cur" in
+       --thread=*)
+               __gitcomp "
+                       deep shallow
+                       " "" "${cur##--thread=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --stdout --attach --no-attach --thread --thread=
+                       --output-directory
+                       --numbered --start-number
+                       --numbered-files
+                       --keep-subject
+                       --signoff --signature --no-signature
+                       --in-reply-to= --cc=
+                       --full-index --binary
+                       --not --all
+                       --cover-letter
+                       --no-prefix --src-prefix= --dst-prefix=
+                       --inline --suffix= --ignore-if-in-upstream
+                       --subject-prefix=
+                       "
+               return
+               ;;
+       esac
+       __git_complete_revlist
+}
+
+_git_fsck ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --tags --root --unreachable --cache --no-reflogs --full
+                       --strict --verbose --lost-found
+                       "
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_gc ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "--prune --aggressive"
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_gitk ()
+{
+       _gitk
+}
+
+__git_match_ctag() {
+       awk "/^${1////\\/}/ { print \$1 }" "$2"
+}
+
+_git_grep ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --cached
+                       --text --ignore-case --word-regexp --invert-match
+                       --full-name --line-number
+                       --extended-regexp --basic-regexp --fixed-strings
+                       --perl-regexp
+                       --files-with-matches --name-only
+                       --files-without-match
+                       --max-depth
+                       --count
+                       --and --or --not --all-match
+                       "
+               return
+               ;;
+       esac
+
+       case "$cword,$prev" in
+       2,*|*,-*)
+               if test -r tags; then
+                       __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
+                       return
+               fi
+               ;;
+       esac
+
+       __gitcomp_nl "$(__git_refs)"
+}
+
+_git_help ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "--all --info --man --web"
+               return
+               ;;
+       esac
+       __git_compute_all_commands
+       __gitcomp "$__git_all_commands $(__git_aliases)
+               attributes cli core-tutorial cvs-migration
+               diffcore gitk glossary hooks ignore modules
+               namespaces repository-layout tutorial tutorial-2
+               workflows
+               "
+}
+
+_git_init ()
+{
+       case "$cur" in
+       --shared=*)
+               __gitcomp "
+                       false true umask group all world everybody
+                       " "" "${cur##--shared=}"
+               return
+               ;;
+       --*)
+               __gitcomp "--quiet --bare --template= --shared --shared="
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_ls_files ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "--cached --deleted --modified --others --ignored
+                       --stage --directory --no-empty-directory --unmerged
+                       --killed --exclude= --exclude-from=
+                       --exclude-per-directory= --exclude-standard
+                       --error-unmatch --with-tree= --full-name
+                       --abbrev --ignored --exclude-per-directory
+                       "
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_ls_remote ()
+{
+       __gitcomp_nl "$(__git_remotes)"
+}
+
+_git_ls_tree ()
+{
+       __git_complete_file
+}
+
+# Options that go well for log, shortlog and gitk
+__git_log_common_options="
+       --not --all
+       --branches --tags --remotes
+       --first-parent --merges --no-merges
+       --max-count=
+       --max-age= --since= --after=
+       --min-age= --until= --before=
+       --min-parents= --max-parents=
+       --no-min-parents --no-max-parents
+"
+# Options that go well for log and gitk (not shortlog)
+__git_log_gitk_options="
+       --dense --sparse --full-history
+       --simplify-merges --simplify-by-decoration
+       --left-right --notes --no-notes
+"
+# Options that go well for log and shortlog (not gitk)
+__git_log_shortlog_options="
+       --author= --committer= --grep=
+       --all-match
+"
+
+__git_log_pretty_formats="oneline short medium full fuller email raw format:"
+__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
+
+_git_log ()
+{
+       __git_has_doubledash && return
+
+       local g="$(git rev-parse --git-dir 2>/dev/null)"
+       local merge=""
+       if [ -f "$g/MERGE_HEAD" ]; then
+               merge="--merge"
+       fi
+       case "$cur" in
+       --pretty=*|--format=*)
+               __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
+                       " "" "${cur#*=}"
+               return
+               ;;
+       --date=*)
+               __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
+               return
+               ;;
+       --decorate=*)
+               __gitcomp "long short" "" "${cur##--decorate=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       $__git_log_common_options
+                       $__git_log_shortlog_options
+                       $__git_log_gitk_options
+                       --root --topo-order --date-order --reverse
+                       --follow --full-diff
+                       --abbrev-commit --abbrev=
+                       --relative-date --date=
+                       --pretty= --format= --oneline
+                       --cherry-pick
+                       --graph
+                       --decorate --decorate=
+                       --walk-reflogs
+                       --parents --children
+                       $merge
+                       $__git_diff_common_options
+                       --pickaxe-all --pickaxe-regex
+                       "
+               return
+               ;;
+       esac
+       __git_complete_revlist
+}
+
+__git_merge_options="
+       --no-commit --no-stat --log --no-log --squash --strategy
+       --commit --stat --no-squash --ff --no-ff --ff-only
+"
+
+_git_merge ()
+{
+       __git_complete_strategy && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "$__git_merge_options"
+               return
+       esac
+       __gitcomp_nl "$(__git_refs)"
+}
+
+_git_mergetool ()
+{
+       case "$cur" in
+       --tool=*)
+               __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
+               return
+               ;;
+       --*)
+               __gitcomp "--tool="
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_merge_base ()
+{
+       __gitcomp_nl "$(__git_refs)"
+}
+
+_git_mv ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "--dry-run"
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_name_rev ()
+{
+       __gitcomp "--tags --all --stdin"
+}
+
+_git_notes ()
+{
+       local subcommands='add append copy edit list prune remove show'
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+
+       case "$subcommand,$cur" in
+       ,--*)
+               __gitcomp '--ref'
+               ;;
+       ,*)
+               case "${words[cword-1]}" in
+               --ref)
+                       __gitcomp_nl "$(__git_refs)"
+                       ;;
+               *)
+                       __gitcomp "$subcommands --ref"
+                       ;;
+               esac
+               ;;
+       add,--reuse-message=*|append,--reuse-message=*|\
+       add,--reedit-message=*|append,--reedit-message=*)
+               __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
+               ;;
+       add,--*|append,--*)
+               __gitcomp '--file= --message= --reedit-message=
+                               --reuse-message='
+               ;;
+       copy,--*)
+               __gitcomp '--stdin'
+               ;;
+       prune,--*)
+               __gitcomp '--dry-run --verbose'
+               ;;
+       prune,*)
+               ;;
+       *)
+               case "${words[cword-1]}" in
+               -m|-F)
+                       ;;
+               *)
+                       __gitcomp_nl "$(__git_refs)"
+                       ;;
+               esac
+               ;;
+       esac
+}
+
+_git_pull ()
+{
+       __git_complete_strategy && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --rebase --no-rebase
+                       $__git_merge_options
+                       $__git_fetch_options
+               "
+               return
+               ;;
+       esac
+       __git_complete_remote_or_refspec
+}
+
+_git_push ()
+{
+       case "$prev" in
+       --repo)
+               __gitcomp_nl "$(__git_remotes)"
+               return
+       esac
+       case "$cur" in
+       --repo=*)
+               __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --all --mirror --tags --dry-run --force --verbose
+                       --receive-pack= --repo= --set-upstream
+               "
+               return
+               ;;
+       esac
+       __git_complete_remote_or_refspec
+}
+
+_git_rebase ()
+{
+       local dir="$(__gitdir)"
+       if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
+               __gitcomp "--continue --skip --abort"
+               return
+       fi
+       __git_complete_strategy && return
+       case "$cur" in
+       --whitespace=*)
+               __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
+               return
+               ;;
+       --*)
+               __gitcomp "
+                       --onto --merge --strategy --interactive
+                       --preserve-merges --stat --no-stat
+                       --committer-date-is-author-date --ignore-date
+                       --ignore-whitespace --whitespace=
+                       --autosquash
+                       "
+
+               return
+       esac
+       __gitcomp_nl "$(__git_refs)"
+}
+
+_git_reflog ()
+{
+       local subcommands="show delete expire"
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+
+       if [ -z "$subcommand" ]; then
+               __gitcomp "$subcommands"
+       else
+               __gitcomp_nl "$(__git_refs)"
+       fi
+}
+
+__git_send_email_confirm_options="always never auto cc compose"
+__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
+
+_git_send_email ()
+{
+       case "$cur" in
+       --confirm=*)
+               __gitcomp "
+                       $__git_send_email_confirm_options
+                       " "" "${cur##--confirm=}"
+               return
+               ;;
+       --suppress-cc=*)
+               __gitcomp "
+                       $__git_send_email_suppresscc_options
+                       " "" "${cur##--suppress-cc=}"
+
+               return
+               ;;
+       --smtp-encryption=*)
+               __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
+               return
+               ;;
+       --*)
+               __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
+                       --compose --confirm= --dry-run --envelope-sender
+                       --from --identity
+                       --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
+                       --no-suppress-from --no-thread --quiet
+                       --signed-off-by-cc --smtp-pass --smtp-server
+                       --smtp-server-port --smtp-encryption= --smtp-user
+                       --subject --suppress-cc= --suppress-from --thread --to
+                       --validate --no-validate"
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_stage ()
+{
+       _git_add
+}
+
+__git_config_get_set_variables ()
+{
+       local prevword word config_file= c=$cword
+       while [ $c -gt 1 ]; do
+               word="${words[c]}"
+               case "$word" in
+               --global|--system|--file=*)
+                       config_file="$word"
+                       break
+                       ;;
+               -f|--file)
+                       config_file="$word $prevword"
+                       break
+                       ;;
+               esac
+               prevword=$word
+               c=$((--c))
+       done
+
+       git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
+       while read -r line
+       do
+               case "$line" in
+               *.*=*)
+                       echo "${line/=*/}"
+                       ;;
+               esac
+       done
+}
+
+_git_config ()
+{
+       case "$prev" in
+       branch.*.remote)
+               __gitcomp_nl "$(__git_remotes)"
+               return
+               ;;
+       branch.*.merge)
+               __gitcomp_nl "$(__git_refs)"
+               return
+               ;;
+       remote.*.fetch)
+               local remote="${prev#remote.}"
+               remote="${remote%.fetch}"
+               if [ -z "$cur" ]; then
+                       COMPREPLY=("refs/heads/")
+                       return
+               fi
+               __gitcomp_nl "$(__git_refs_remotes "$remote")"
+               return
+               ;;
+       remote.*.push)
+               local remote="${prev#remote.}"
+               remote="${remote%.push}"
+               __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
+                       for-each-ref --format='%(refname):%(refname)' \
+                       refs/heads)"
+               return
+               ;;
+       pull.twohead|pull.octopus)
+               __git_compute_merge_strategies
+               __gitcomp "$__git_merge_strategies"
+               return
+               ;;
+       color.branch|color.diff|color.interactive|\
+       color.showbranch|color.status|color.ui)
+               __gitcomp "always never auto"
+               return
+               ;;
+       color.pager)
+               __gitcomp "false true"
+               return
+               ;;
+       color.*.*)
+               __gitcomp "
+                       normal black red green yellow blue magenta cyan white
+                       bold dim ul blink reverse
+                       "
+               return
+               ;;
+       help.format)
+               __gitcomp "man info web html"
+               return
+               ;;
+       log.date)
+               __gitcomp "$__git_log_date_formats"
+               return
+               ;;
+       sendemail.aliasesfiletype)
+               __gitcomp "mutt mailrc pine elm gnus"
+               return
+               ;;
+       sendemail.confirm)
+               __gitcomp "$__git_send_email_confirm_options"
+               return
+               ;;
+       sendemail.suppresscc)
+               __gitcomp "$__git_send_email_suppresscc_options"
+               return
+               ;;
+       --get|--get-all|--unset|--unset-all)
+               __gitcomp_nl "$(__git_config_get_set_variables)"
+               return
+               ;;
+       *.*)
+               COMPREPLY=()
+               return
+               ;;
+       esac
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --global --system --file=
+                       --list --replace-all
+                       --get --get-all --get-regexp
+                       --add --unset --unset-all
+                       --remove-section --rename-section
+                       "
+               return
+               ;;
+       branch.*.*)
+               local pfx="${cur%.*}." cur_="${cur##*.}"
+               __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
+               return
+               ;;
+       branch.*)
+               local pfx="${cur%.*}." cur_="${cur#*.}"
+               __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
+               return
+               ;;
+       guitool.*.*)
+               local pfx="${cur%.*}." cur_="${cur##*.}"
+               __gitcomp "
+                       argprompt cmd confirm needsfile noconsole norescan
+                       prompt revprompt revunmerged title
+                       " "$pfx" "$cur_"
+               return
+               ;;
+       difftool.*.*)
+               local pfx="${cur%.*}." cur_="${cur##*.}"
+               __gitcomp "cmd path" "$pfx" "$cur_"
+               return
+               ;;
+       man.*.*)
+               local pfx="${cur%.*}." cur_="${cur##*.}"
+               __gitcomp "cmd path" "$pfx" "$cur_"
+               return
+               ;;
+       mergetool.*.*)
+               local pfx="${cur%.*}." cur_="${cur##*.}"
+               __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
+               return
+               ;;
+       pager.*)
+               local pfx="${cur%.*}." cur_="${cur#*.}"
+               __git_compute_all_commands
+               __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
+               return
+               ;;
+       remote.*.*)
+               local pfx="${cur%.*}." cur_="${cur##*.}"
+               __gitcomp "
+                       url proxy fetch push mirror skipDefaultUpdate
+                       receivepack uploadpack tagopt pushurl
+                       " "$pfx" "$cur_"
+               return
+               ;;
+       remote.*)
+               local pfx="${cur%.*}." cur_="${cur#*.}"
+               __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
+               return
+               ;;
+       url.*.*)
+               local pfx="${cur%.*}." cur_="${cur##*.}"
+               __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
+               return
+               ;;
+       esac
+       __gitcomp "
+               add.ignoreErrors
+               advice.commitBeforeMerge
+               advice.detachedHead
+               advice.implicitIdentity
+               advice.pushNonFastForward
+               advice.resolveConflict
+               advice.statusHints
+               alias.
+               am.keepcr
+               apply.ignorewhitespace
+               apply.whitespace
+               branch.autosetupmerge
+               branch.autosetuprebase
+               browser.
+               clean.requireForce
+               color.branch
+               color.branch.current
+               color.branch.local
+               color.branch.plain
+               color.branch.remote
+               color.decorate.HEAD
+               color.decorate.branch
+               color.decorate.remoteBranch
+               color.decorate.stash
+               color.decorate.tag
+               color.diff
+               color.diff.commit
+               color.diff.frag
+               color.diff.func
+               color.diff.meta
+               color.diff.new
+               color.diff.old
+               color.diff.plain
+               color.diff.whitespace
+               color.grep
+               color.grep.context
+               color.grep.filename
+               color.grep.function
+               color.grep.linenumber
+               color.grep.match
+               color.grep.selected
+               color.grep.separator
+               color.interactive
+               color.interactive.error
+               color.interactive.header
+               color.interactive.help
+               color.interactive.prompt
+               color.pager
+               color.showbranch
+               color.status
+               color.status.added
+               color.status.changed
+               color.status.header
+               color.status.nobranch
+               color.status.untracked
+               color.status.updated
+               color.ui
+               commit.status
+               commit.template
+               core.abbrev
+               core.askpass
+               core.attributesfile
+               core.autocrlf
+               core.bare
+               core.bigFileThreshold
+               core.compression
+               core.createObject
+               core.deltaBaseCacheLimit
+               core.editor
+               core.eol
+               core.excludesfile
+               core.fileMode
+               core.fsyncobjectfiles
+               core.gitProxy
+               core.ignoreCygwinFSTricks
+               core.ignoreStat
+               core.ignorecase
+               core.logAllRefUpdates
+               core.loosecompression
+               core.notesRef
+               core.packedGitLimit
+               core.packedGitWindowSize
+               core.pager
+               core.preferSymlinkRefs
+               core.preloadindex
+               core.quotepath
+               core.repositoryFormatVersion
+               core.safecrlf
+               core.sharedRepository
+               core.sparseCheckout
+               core.symlinks
+               core.trustctime
+               core.warnAmbiguousRefs
+               core.whitespace
+               core.worktree
+               diff.autorefreshindex
+               diff.external
+               diff.ignoreSubmodules
+               diff.mnemonicprefix
+               diff.noprefix
+               diff.renameLimit
+               diff.renames
+               diff.suppressBlankEmpty
+               diff.tool
+               diff.wordRegex
+               difftool.
+               difftool.prompt
+               fetch.recurseSubmodules
+               fetch.unpackLimit
+               format.attach
+               format.cc
+               format.headers
+               format.numbered
+               format.pretty
+               format.signature
+               format.signoff
+               format.subjectprefix
+               format.suffix
+               format.thread
+               format.to
+               gc.
+               gc.aggressiveWindow
+               gc.auto
+               gc.autopacklimit
+               gc.packrefs
+               gc.pruneexpire
+               gc.reflogexpire
+               gc.reflogexpireunreachable
+               gc.rerereresolved
+               gc.rerereunresolved
+               gitcvs.allbinary
+               gitcvs.commitmsgannotation
+               gitcvs.dbTableNamePrefix
+               gitcvs.dbdriver
+               gitcvs.dbname
+               gitcvs.dbpass
+               gitcvs.dbuser
+               gitcvs.enabled
+               gitcvs.logfile
+               gitcvs.usecrlfattr
+               guitool.
+               gui.blamehistoryctx
+               gui.commitmsgwidth
+               gui.copyblamethreshold
+               gui.diffcontext
+               gui.encoding
+               gui.fastcopyblame
+               gui.matchtrackingbranch
+               gui.newbranchtemplate
+               gui.pruneduringfetch
+               gui.spellingdictionary
+               gui.trustmtime
+               help.autocorrect
+               help.browser
+               help.format
+               http.lowSpeedLimit
+               http.lowSpeedTime
+               http.maxRequests
+               http.minSessions
+               http.noEPSV
+               http.postBuffer
+               http.proxy
+               http.sslCAInfo
+               http.sslCAPath
+               http.sslCert
+               http.sslCertPasswordProtected
+               http.sslKey
+               http.sslVerify
+               http.useragent
+               i18n.commitEncoding
+               i18n.logOutputEncoding
+               imap.authMethod
+               imap.folder
+               imap.host
+               imap.pass
+               imap.port
+               imap.preformattedHTML
+               imap.sslverify
+               imap.tunnel
+               imap.user
+               init.templatedir
+               instaweb.browser
+               instaweb.httpd
+               instaweb.local
+               instaweb.modulepath
+               instaweb.port
+               interactive.singlekey
+               log.date
+               log.decorate
+               log.showroot
+               mailmap.file
+               man.
+               man.viewer
+               merge.
+               merge.conflictstyle
+               merge.log
+               merge.renameLimit
+               merge.renormalize
+               merge.stat
+               merge.tool
+               merge.verbosity
+               mergetool.
+               mergetool.keepBackup
+               mergetool.keepTemporaries
+               mergetool.prompt
+               notes.displayRef
+               notes.rewrite.
+               notes.rewrite.amend
+               notes.rewrite.rebase
+               notes.rewriteMode
+               notes.rewriteRef
+               pack.compression
+               pack.deltaCacheLimit
+               pack.deltaCacheSize
+               pack.depth
+               pack.indexVersion
+               pack.packSizeLimit
+               pack.threads
+               pack.window
+               pack.windowMemory
+               pager.
+               pretty.
+               pull.octopus
+               pull.twohead
+               push.default
+               rebase.autosquash
+               rebase.stat
+               receive.autogc
+               receive.denyCurrentBranch
+               receive.denyDeleteCurrent
+               receive.denyDeletes
+               receive.denyNonFastForwards
+               receive.fsckObjects
+               receive.unpackLimit
+               receive.updateserverinfo
+               remotes.
+               repack.usedeltabaseoffset
+               rerere.autoupdate
+               rerere.enabled
+               sendemail.
+               sendemail.aliasesfile
+               sendemail.aliasfiletype
+               sendemail.bcc
+               sendemail.cc
+               sendemail.cccmd
+               sendemail.chainreplyto
+               sendemail.confirm
+               sendemail.envelopesender
+               sendemail.from
+               sendemail.identity
+               sendemail.multiedit
+               sendemail.signedoffbycc
+               sendemail.smtpdomain
+               sendemail.smtpencryption
+               sendemail.smtppass
+               sendemail.smtpserver
+               sendemail.smtpserveroption
+               sendemail.smtpserverport
+               sendemail.smtpuser
+               sendemail.suppresscc
+               sendemail.suppressfrom
+               sendemail.thread
+               sendemail.to
+               sendemail.validate
+               showbranch.default
+               status.relativePaths
+               status.showUntrackedFiles
+               status.submodulesummary
+               submodule.
+               tar.umask
+               transfer.unpackLimit
+               url.
+               user.email
+               user.name
+               user.signingkey
+               web.browser
+               branch. remote.
+       "
+}
+
+_git_remote ()
+{
+       local subcommands="add rename rm show prune update set-head"
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       if [ -z "$subcommand" ]; then
+               __gitcomp "$subcommands"
+               return
+       fi
+
+       case "$subcommand" in
+       rename|rm|show|prune)
+               __gitcomp_nl "$(__git_remotes)"
+               ;;
+       update)
+               local i c='' IFS=$'\n'
+               for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
+                       i="${i#remotes.}"
+                       c="$c ${i/ */}"
+               done
+               __gitcomp "$c"
+               ;;
+       *)
+               COMPREPLY=()
+               ;;
+       esac
+}
+
+_git_replace ()
+{
+       __gitcomp_nl "$(__git_refs)"
+}
+
+_git_reset ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "--merge --mixed --hard --soft --patch"
+               return
+               ;;
+       esac
+       __gitcomp_nl "$(__git_refs)"
+}
+
+_git_revert ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
+               return
+               ;;
+       esac
+       __gitcomp_nl "$(__git_refs)"
+}
+
+_git_rm ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
+               return
+               ;;
+       esac
+       COMPREPLY=()
+}
+
+_git_shortlog ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       $__git_log_common_options
+                       $__git_log_shortlog_options
+                       --numbered --summary
+                       "
+               return
+               ;;
+       esac
+       __git_complete_revlist
+}
+
+_git_show ()
+{
+       __git_has_doubledash && return
+
+       case "$cur" in
+       --pretty=*|--format=*)
+               __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
+                       " "" "${cur#*=}"
+               return
+               ;;
+       --*)
+               __gitcomp "--pretty= --format= --abbrev-commit --oneline
+                       $__git_diff_common_options
+                       "
+               return
+               ;;
+       esac
+       __git_complete_file
+}
+
+_git_show_branch ()
+{
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       --all --remotes --topo-order --current --more=
+                       --list --independent --merge-base --no-name
+                       --color --no-color
+                       --sha1-name --sparse --topics --reflog
+                       "
+               return
+               ;;
+       esac
+       __git_complete_revlist
+}
+
+_git_stash ()
+{
+       local save_opts='--keep-index --no-keep-index --quiet --patch'
+       local subcommands='save list show apply clear drop pop create branch'
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       if [ -z "$subcommand" ]; then
+               case "$cur" in
+               --*)
+                       __gitcomp "$save_opts"
+                       ;;
+               *)
+                       if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
+                               __gitcomp "$subcommands"
+                       else
+                               COMPREPLY=()
+                       fi
+                       ;;
+               esac
+       else
+               case "$subcommand,$cur" in
+               save,--*)
+                       __gitcomp "$save_opts"
+                       ;;
+               apply,--*|pop,--*)
+                       __gitcomp "--index --quiet"
+                       ;;
+               show,--*|drop,--*|branch,--*)
+                       COMPREPLY=()
+                       ;;
+               show,*|apply,*|drop,*|pop,*|branch,*)
+                       __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+                                       | sed -n -e 's/:.*//p')"
+                       ;;
+               *)
+                       COMPREPLY=()
+                       ;;
+               esac
+       fi
+}
+
+_git_submodule ()
+{
+       __git_has_doubledash && return
+
+       local subcommands="add status init update summary foreach sync"
+       if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
+               case "$cur" in
+               --*)
+                       __gitcomp "--quiet --cached"
+                       ;;
+               *)
+                       __gitcomp "$subcommands"
+                       ;;
+               esac
+               return
+       fi
+}
+
+_git_svn ()
+{
+       local subcommands="
+               init fetch clone rebase dcommit log find-rev
+               set-tree commit-diff info create-ignore propget
+               proplist show-ignore show-externals branch tag blame
+               migrate mkdirs reset gc
+               "
+       local subcommand="$(__git_find_on_cmdline "$subcommands")"
+       if [ -z "$subcommand" ]; then
+               __gitcomp "$subcommands"
+       else
+               local remote_opts="--username= --config-dir= --no-auth-cache"
+               local fc_opts="
+                       --follow-parent --authors-file= --repack=
+                       --no-metadata --use-svm-props --use-svnsync-props
+                       --log-window-size= --no-checkout --quiet
+                       --repack-flags --use-log-author --localtime
+                       --ignore-paths= $remote_opts
+                       "
+               local init_opts="
+                       --template= --shared= --trunk= --tags=
+                       --branches= --stdlayout --minimize-url
+                       --no-metadata --use-svm-props --use-svnsync-props
+                       --rewrite-root= --prefix= --use-log-author
+                       --add-author-from $remote_opts
+                       "
+               local cmt_opts="
+                       --edit --rmdir --find-copies-harder --copy-similarity=
+                       "
+
+               case "$subcommand,$cur" in
+               fetch,--*)
+                       __gitcomp "--revision= --fetch-all $fc_opts"
+                       ;;
+               clone,--*)
+                       __gitcomp "--revision= $fc_opts $init_opts"
+                       ;;
+               init,--*)
+                       __gitcomp "$init_opts"
+                       ;;
+               dcommit,--*)
+                       __gitcomp "
+                               --merge --strategy= --verbose --dry-run
+                               --fetch-all --no-rebase --commit-url
+                               --revision $cmt_opts $fc_opts
+                               "
+                       ;;
+               set-tree,--*)
+                       __gitcomp "--stdin $cmt_opts $fc_opts"
+                       ;;
+               create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
+               show-externals,--*|mkdirs,--*)
+                       __gitcomp "--revision="
+                       ;;
+               log,--*)
+                       __gitcomp "
+                               --limit= --revision= --verbose --incremental
+                               --oneline --show-commit --non-recursive
+                               --authors-file= --color
+                               "
+                       ;;
+               rebase,--*)
+                       __gitcomp "
+                               --merge --verbose --strategy= --local
+                               --fetch-all --dry-run $fc_opts
+                               "
+                       ;;
+               commit-diff,--*)
+                       __gitcomp "--message= --file= --revision= $cmt_opts"
+                       ;;
+               info,--*)
+                       __gitcomp "--url"
+                       ;;
+               branch,--*)
+                       __gitcomp "--dry-run --message --tag"
+                       ;;
+               tag,--*)
+                       __gitcomp "--dry-run --message"
+                       ;;
+               blame,--*)
+                       __gitcomp "--git-format"
+                       ;;
+               migrate,--*)
+                       __gitcomp "
+                               --config-dir= --ignore-paths= --minimize
+                               --no-auth-cache --username=
+                               "
+                       ;;
+               reset,--*)
+                       __gitcomp "--revision= --parent"
+                       ;;
+               *)
+                       COMPREPLY=()
+                       ;;
+               esac
+       fi
+}
+
+_git_tag ()
+{
+       local i c=1 f=0
+       while [ $c -lt $cword ]; do
+               i="${words[c]}"
+               case "$i" in
+               -d|-v)
+                       __gitcomp_nl "$(__git_tags)"
+                       return
+                       ;;
+               -f)
+                       f=1
+                       ;;
+               esac
+               c=$((++c))
+       done
+
+       case "$prev" in
+       -m|-F)
+               COMPREPLY=()
+               ;;
+       -*|tag)
+               if [ $f = 1 ]; then
+                       __gitcomp_nl "$(__git_tags)"
+               else
+                       COMPREPLY=()
+               fi
+               ;;
+       *)
+               __gitcomp_nl "$(__git_refs)"
+               ;;
+       esac
+}
+
+_git_whatchanged ()
+{
+       _git_log
+}
+
+_git ()
+{
+       local i c=1 command __git_dir
+
+       if [[ -n ${ZSH_VERSION-} ]]; then
+               emulate -L bash
+               setopt KSH_TYPESET
+
+               # workaround zsh's bug that leaves 'words' as a special
+               # variable in versions < 4.3.12
+               typeset -h words
+
+               # workaround zsh's bug that quotes spaces in the COMPREPLY
+               # array if IFS doesn't contain spaces.
+               typeset -h IFS
+       fi
+
+       local cur words cword prev
+       _get_comp_words_by_ref -n =: cur words cword prev
+       while [ $c -lt $cword ]; do
+               i="${words[c]}"
+               case "$i" in
+               --git-dir=*) __git_dir="${i#--git-dir=}" ;;
+               --bare)      __git_dir="." ;;
+               --version|-p|--paginate) ;;
+               --help) command="help"; break ;;
+               *) command="$i"; break ;;
+               esac
+               c=$((++c))
+       done
+
+       if [ -z "$command" ]; then
+               case "$cur" in
+               --*)   __gitcomp "
+                       --paginate
+                       --no-pager
+                       --git-dir=
+                       --bare
+                       --version
+                       --exec-path
+                       --html-path
+                       --work-tree=
+                       --namespace=
+                       --help
+                       "
+                       ;;
+               *)     __git_compute_porcelain_commands
+                      __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
+               esac
+               return
+       fi
+
+       local completion_func="_git_${command//-/_}"
+       declare -f $completion_func >/dev/null && $completion_func && return
+
+       local expansion=$(__git_aliased_command "$command")
+       if [ -n "$expansion" ]; then
+               completion_func="_git_${expansion//-/_}"
+               declare -f $completion_func >/dev/null && $completion_func
+       fi
+}
+
+_gitk ()
+{
+       if [[ -n ${ZSH_VERSION-} ]]; then
+               emulate -L bash
+               setopt KSH_TYPESET
+
+               # workaround zsh's bug that leaves 'words' as a special
+               # variable in versions < 4.3.12
+               typeset -h words
+
+               # workaround zsh's bug that quotes spaces in the COMPREPLY
+               # array if IFS doesn't contain spaces.
+               typeset -h IFS
+       fi
+
+       local cur words cword prev
+       _get_comp_words_by_ref -n =: cur words cword prev
+
+       __git_has_doubledash && return
+
+       local g="$(__gitdir)"
+       local merge=""
+       if [ -f "$g/MERGE_HEAD" ]; then
+               merge="--merge"
+       fi
+       case "$cur" in
+       --*)
+               __gitcomp "
+                       $__git_log_common_options
+                       $__git_log_gitk_options
+                       $merge
+                       "
+               return
+               ;;
+       esac
+       __git_complete_revlist
+}
+
+complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
+       || complete -o default -o nospace -F _git git
+complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
+       || complete -o default -o nospace -F _gitk gitk
+
+# The following are necessary only for Cygwin, and only are needed
+# when the user has tab-completed the executable name and consequently
+# included the '.exe' suffix.
+#
+if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
+complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
+       || complete -o default -o nospace -F _git git.exe
+fi
+
+if [[ -n ${ZSH_VERSION-} ]]; then
+       __git_shopt () {
+               local option
+               if [ $# -ne 2 ]; then
+                       echo "USAGE: $0 (-q|-s|-u) <option>" >&2
+                       return 1
+               fi
+               case "$2" in
+               nullglob)
+                       option="$2"
+                       ;;
+               *)
+                       echo "$0: invalid option: $2" >&2
+                       return 1
+               esac
+               case "$1" in
+               -q)     setopt | grep -q "$option" ;;
+               -u)     unsetopt "$option" ;;
+               -s)     setopt "$option" ;;
+               *)
+                       echo "$0: invalid flag: $1" >&2
+                       return 1
+               esac
+       }
+else
+       __git_shopt () {
+               shopt "$@"
+       }
+fi
diff --git a/.bash/bash_completion.d/gkrellm b/.bash/bash_completion.d/gkrellm
new file mode 100644 (file)
index 0000000..13e25ad
--- /dev/null
@@ -0,0 +1,54 @@
+# gkrellm(1) completion
+
+have gkrellm || have gkrellm2 &&
+_gkrellm()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -t|--theme)
+            _filedir -d
+            return 0
+            ;;
+        -p|--plugin)
+            _filedir so
+            return 0
+            ;;
+        -s|--server)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -l|--logfile)
+            _filedir
+            return 0
+            ;;
+        -g|--geometry|-c|--config|-P|--port|-d|--debug-level)
+            # Argument required but no completions available
+            return 0
+            ;;
+        -h|--help|-v|--version)
+            # All other options are noop with these
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--theme --geometry --wm --m2 --nt \
+            --withdrawn --config --force-host-config --server --port --nc \
+            --config-clean --nolock --plugin --demo --logfile --version \
+            --debug-level --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _gkrellm gkrellm gkrellm2
+
+# 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
diff --git a/.bash/bash_completion.d/gnatmake b/.bash/bash_completion.d/gnatmake
new file mode 100644 (file)
index 0000000..cdd193c
--- /dev/null
@@ -0,0 +1,37 @@
+# Gnatmake completion by Ralf_Schroth@t-online.de (Ralf Schroth)
+
+have gnatmake &&
+_gnatmake()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        # relevant (and less relevant ;-) )options completion
+        COMPREPLY=( $( compgen -W '-a -c -f -i -j -k -m -M -n -o \
+            -q -s -v -z -aL -A -aO -aI -I -I- -L -nostdinc \
+           -nostdlib -cargs -bargs -largs -fstack-check \
+           -fno-inline -g -O1 -O0 -O2 -O3 -gnata -gnatA \
+           -gnatb -gnatc -gnatd -gnatD -gnate -gnatE \
+           -gnatf -gnatF -gnatg -gnatG -gnath -gnati \
+           -gnatk -gnatl -gnatL -gnatm -gnatn -gnato \
+           -gnatO -gnatp -gnatP -gnatq -gnatR -gnats \
+           -gnatt -gnatT -gnatu -gnatU -gnatv -gnatws \
+           -gnatwe -gnatwl -gnatwu -gnatW -gnatx -gnatX \
+           -gnaty -gnatz -gnatZ -gnat83' -- "$cur" ) )
+    else
+        # source file completion
+        _filedir '@(adb|ads)'
+    fi
+} &&
+complete -F _gnatmake gnatmake
+
+# 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
diff --git a/.bash/bash_completion.d/gpg b/.bash/bash_completion.d/gpg
new file mode 100644 (file)
index 0000000..878a800
--- /dev/null
@@ -0,0 +1,48 @@
+# bash completion for gpg
+
+have gpg &&
+_gpg()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -s|--sign|--clearsign|--decrypt-files|--load-extension)
+            _filedir
+            return 0
+            ;;
+        --export|--sign-key|--lsignkey|--nrsignkey|--nrlsignkey|--editkey)
+            # return list of public keys
+            COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
+                sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \
+                    -ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) )
+            return 0
+            ;;
+        -r|--recipient)
+            COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
+                sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
+            if [ -e ~/.gnupg/gpg.conf ]; then
+                COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne \
+                    's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
+                    ~/.gnupg/gpg.conf  )" -- "$cur") )
+            fi
+            return 0
+        ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$(gpg --dump-options)' -- "$cur" ) )
+     fi
+
+} &&
+complete -F _gpg -o default gpg
+
+# 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
diff --git a/.bash/bash_completion.d/gpg2 b/.bash/bash_completion.d/gpg2
new file mode 100644 (file)
index 0000000..b99783f
--- /dev/null
@@ -0,0 +1,52 @@
+# gpg2(1) completion
+
+have gpg2 && {
+_gpg2 ()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --homedir)
+            _filedir -d
+            return 0
+            ;;
+        -s|--sign|--clearsign|--options|--decrypt)
+            _filedir
+            return 0
+            ;;
+        --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key)
+            # return list of public keys
+            COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \
+                sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p' \
+                    -ne 's@^.*\(<\([^>]*\)>\).*$@\2@p' )" -- "$cur" ) )
+            return 0
+            ;;
+        -r|--recipient)
+            COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \
+                sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
+            if [ -e ~/.gnupg/gpg.conf ]; then
+                COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne \
+                    's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
+                    ~/.gnupg/gpg.conf)" -- "$cur"))
+            fi
+        return 0
+        ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$(gpg2 --dump-options)' -- "$cur" ) )
+    fi
+} &&
+complete -F _gpg2 -o default gpg2
+}
+
+# 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
diff --git a/.bash/bash_completion.d/gresource b/.bash/bash_completion.d/gresource
new file mode 100644 (file)
index 0000000..ef1145d
--- /dev/null
@@ -0,0 +1,58 @@
+
+# Check for bash
+[ -z "$BASH_VERSION" ] && return
+
+####################################################################################################
+
+__gresource() {
+  local choices coffset section
+
+  if [ ${COMP_CWORD} -gt 2 ]; then
+      if [ ${COMP_WORDS[1]} = --section ]; then
+          section=${COMP_WORDS[2]}
+          coffset=2
+      else
+          coffset=0
+      fi
+  else
+      coffset=0
+  fi
+
+  case "$((${COMP_CWORD}-$coffset))" in
+    1)
+      choices=$'--section \nhelp \nsections \nlist \ndetails \nextract '
+      ;;
+
+    2)
+      case "${COMP_WORDS[$(($coffset+1))]}" in
+        --section)
+          return 0
+          ;;
+
+        help)
+          choices=$'sections\nlist\ndetails\nextract'
+          ;;
+
+        sections|list|details|extract)
+          COMPREPLY=($(compgen -f -- ${COMP_WORDS[${COMP_CWORD}]}))
+          return 0
+          ;;
+      esac
+      ;;
+
+    3)
+      case "${COMP_WORDS[$(($coffset+1))]}" in
+        list|details|extract)
+          choices="$(gresource list ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null | sed -e 's.$. .')"
+          ;;
+      esac
+      ;;
+  esac
+
+  local IFS=$'\n'
+  COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
+}
+
+####################################################################################################
+
+complete -o nospace -F __gresource gresource
diff --git a/.bash/bash_completion.d/gsettings b/.bash/bash_completion.d/gsettings
new file mode 100644 (file)
index 0000000..21f5c6d
--- /dev/null
@@ -0,0 +1,84 @@
+
+# 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'
+      ;;
+
+    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)"$'\n'"$(gsettings $schemadir list-relocatable-schemas | sed -e 's.$.:/.')"
+          ;;
+
+        get|range|set|reset|writable|monitor)
+          choices="$(gsettings $schemadir list-schemas | sed -e 's.$. .')"$'\n'"$(gsettings $schemadir list-relocatable-schemas | 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)
+          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
diff --git a/.bash/bash_completion.d/gvim-completion b/.bash/bash_completion.d/gvim-completion
new file mode 100644 (file)
index 0000000..f19ce6f
--- /dev/null
@@ -0,0 +1,40 @@
+# Author: Ciaran McCreesh <ciaranm@gentoo.org>
+#
+# completion for gvim
+
+_gvim()
+{
+    local cur prev cmd args
+
+    COMPREPLY=()
+    cur=${COMP_WORDS[COMP_CWORD]}
+    prev=${COMP_WORDS[COMP_CWORD-1]}
+    cmd=${COMP_WORDS[0]}
+
+    if [[ "${prev}" == "--servername" ]] ; then
+        local servers
+        servers=$(gvim --serverlist )
+        COMPREPLY=( $( compgen -W "${servers}" -- $cur ) )
+
+    elif [[ "${prev}" == -[uUi] ]] ; then
+        COMPREPLY=( $( compgen -W "NONE" ) \
+                $( compgen -f -X "!*vim*" -- "$cur" ) )
+
+    elif [[ "${cur}" == -* ]] ; then
+        args='-t -q -c -S --cmd -A -b -C -d -D -e -E -f --nofork \
+            -F -g -h -H -i -L -l -m -M -N -n -nb -o -R -r -s \
+            -T -u -U -V -v -w -W -x -X -y -Y -Z --echo-wid \
+            --help --literal --noplugin --version'
+        args="${args} --echo-wid  --remote --remote-expr \
+            --remote-send --remote-silent --remote-wait \
+            --remote-wait-silent --serverlist \
+            --servername --socketid"
+        COMPREPLY=( $( compgen -W "${args}" -- $cur ) )
+    else
+        _filedir
+    fi
+}
+
+complete -o filenames -F _gvim gvim gview rgview rgview
+
+# vim: set ft=sh sw=4 et sts=4 :
diff --git a/.bash/bash_completion.d/gzip b/.bash/bash_completion.d/gzip
new file mode 100644 (file)
index 0000000..f7aec17
--- /dev/null
@@ -0,0 +1,55 @@
+# bash completion for gzip
+
+have gzip || have pigz &&
+_gzip()
+{
+    local cur prev xspec helpopts
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    helpopts=`_parse_help ${COMP_WORDS[0]}`
+
+    case $prev in
+        -b|--blocksize|-p|--processes|-S|--suffix|-h|--help|-V|--version)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W "$helpopts -1 -2 -3 -4 -5 -6 -7 -8 -9" \
+            -- "$cur" ) )
+        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=
+    elif [[ "$prev" == '>' || "$prev" == '>>' ]]; then
+        xspec=
+    elif [ "$prev" = '<' ]; then
+        xspec=
+    fi
+
+    _expand || return 0
+
+    _compopt_o_filenames
+    COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
+        $( compgen -d -- "$cur" ) )
+} &&
+complete -F _gzip gzip pigz
+
+# 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
diff --git a/.bash/bash_completion.d/heimdal b/.bash/bash_completion.d/heimdal
new file mode 100644 (file)
index 0000000..c1efb11
--- /dev/null
@@ -0,0 +1,133 @@
+# bash completion for heimdal
+
+have ktutil && {
+_heimdal_principals()
+{
+
+    COMPREPLY=( $( compgen -W "$( kadmin -l dump 2>/dev/null | \
+        awk '{print $1}' )" -- "$cur" ) )
+}
+
+_heimdal_realms()
+{
+
+    COMPREPLY=( $( compgen -W "( kadmin -l dump 2>/dev/null | \
+        awk '{print $1}' | awk -F@ '{print $2}' )" -- "$cur" ) )
+}
+
+_heimdal_encodings()
+{
+
+    COMPREPLY=( $( compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 \
+        des3-cbc-sha1 arcfour-hmac-md5 aes128-cts-hmac-sha1-96 \
+        aes256-cts-hmac-sha1-96' -- "$cur" ) )
+}
+
+_ktutil()
+{
+    local cur prev command options split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -p|--principal)
+            _heimdal_principals
+            return 0
+            ;;
+        -e|--enctype)
+            _heimdal_encodings
+            return 0
+            ;;
+        -a|--admin-server)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -r|--realm)
+            _heimdal_realms
+            return 0
+            ;;
+        -s|-k|--srvtab|--keytab)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    commands='add change copy get list remove rename purge srvconvert \
+        srv2keytab srvcreate key2srvtab'
+
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        case ${COMP_WORDS[i]} in
+            -k|--keytab)
+                i=$(($i+1))
+                ;;
+            -*)
+                ;;
+            *)
+                command=${COMP_WORDS[i]}
+                break
+                ;;
+        esac
+    done
+
+    if [[ "$cur" == -* ]]; then
+        case $command in
+            add)
+                options='-p --principal -V -e --enctype -w --password -r \
+                    --random -s --no-salt -h --hex'
+            ;;
+            change)
+                options='-r --realm -a --admin-server -s --server-port'
+            ;;
+            get)
+                options='-p --principal -e --enctype -r --realm -a \
+                    --admin-server -s server --server-port'
+                ;;
+            list)
+                options='--keys --timestamp'
+                ;;
+            remove)
+                options='-p --principal -V --kvno -e --enctype'
+                ;;
+            purge)
+                options='--age'
+                ;;
+            srv2keytab|key2srvtab)
+                options='-s --srvtab'
+                ;;
+            *)
+                options='-k --keytab -v --verbose --version -v --help'
+                ;;
+        esac
+        COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+    else
+        case $command in
+            copy)
+                _filedir
+                ;;
+            get)
+                _heimdal_principals
+                ;;
+            rename)
+                _heimdal_principals
+                ;;
+            *)
+                COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
+                ;;
+        esac
+    fi
+}
+complete -F _ktutil ktutil
+}
+
+# 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
diff --git a/.bash/bash_completion.d/helpers/perl b/.bash/bash_completion.d/helpers/perl
new file mode 100644 (file)
index 0000000..b3522ac
--- /dev/null
@@ -0,0 +1,88 @@
+#!/usr/bin/env perl
+use strict;
+use Config;
+use File::Spec::Functions;
+
+my %seen;
+
+sub print_modules_real {
+    my ($base, $dir, $word) = @_;
+
+    # return immediatly if potential completion doesn't match current word
+    # a double comparaison 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' againt '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);
+}
diff --git a/.bash/bash_completion.d/hping2 b/.bash/bash_completion.d/hping2
new file mode 100644 (file)
index 0000000..e2e6bf1
--- /dev/null
@@ -0,0 +1,55 @@
+# bash completion for hping2
+
+have hping || have hping2 || have hping3 &&
+_hping2()
+{
+    local cur prev
+
+    COMPREPLY=()
+    cur=`_get_cword`
+    prev=`_get_pword`
+
+    case $prev in
+        -I|--interface)
+            _available_interfaces
+            return 0
+            ;;
+        -a|--spoof)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -o|--tos)
+            COMPREPLY=( $( compgen -W '02 04 08 10' ) )
+            return 0
+            ;;
+        -E|--file)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --version --count --interval --fast \
+            --faster --numeric --quiet --interface --verbose --debug --bind \
+            --unbind --rawip --icmp --upd --scan --listen --spoof \
+            --rand-source --rand-dest --ttl --id --ipproto --winid -rel --frag \
+            --morefrag --dontfrag --fragoff --mtu --tos --rroute --icmptype \
+            --icmpcode --icmp-ipver --icmp-iphlen --icmp-iplen --icmp-ipid \
+            --icmp-ipproto --icmp-cksum --icmp-ts --icmp-addr --baseport \
+            --destport --keep --win --tcpoff --tcpseq --tcpack --seqnum \
+            --badcksum --tcp-timestamp --fin --syn --rst --push --ack --urg \
+            --xmas --ymas --data --file --sign --dump --print --safe --end \
+            --traceroute --tr-keep-ttl --tr-stop --tr-no-rtt' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+} &&
+complete -F _hping2 hping hping2 hping3
+
+# 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
diff --git a/.bash/bash_completion.d/iconv b/.bash/bash_completion.d/iconv
new file mode 100644 (file)
index 0000000..9e33200
--- /dev/null
@@ -0,0 +1,46 @@
+# iconv(1) completion
+
+have iconv &&
+_iconv()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -'?'|--help|--usage|-V|--version|--unicode-subst|--byte-subst|\
+        --widechar-subst)
+            return 0
+            ;;
+        -f|--from-code|-t|--to-code)
+            COMPREPLY=( $( compgen -W '$( iconv -l | \
+                sed -e "s@/*\$@@" -e "s/[,()]//g" )' -- "$cur" ) )
+            return 0
+            ;;
+        -o|--output)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" = -* ]]; then
+        COMPREPLY=( $( compgen -W '--from-code --to-code --list -c
+            --unicode-subst --byte-subst --widechar-subst --output --silent
+            --verbose --help --usage --version' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _iconv -o default iconv
+
+# 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
diff --git a/.bash/bash_completion.d/iftop b/.bash/bash_completion.d/iftop
new file mode 100644 (file)
index 0000000..9ec2a0d
--- /dev/null
@@ -0,0 +1,35 @@
+# iftop(8) completion
+
+have iftop &&
+_iftop()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h|-f|-F|-m)
+            return 0
+            ;;
+        -i)
+            _available_interfaces -a
+            return 0
+            ;;
+        -c)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    COMPREPLY=( $( compgen -W '-h -n -N -p -P -b -B -i -f -F -c -m' \
+        -- "$cur" ) )
+} &&
+complete -F _iftop iftop
+
+# 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
diff --git a/.bash/bash_completion.d/ifupdown b/.bash/bash_completion.d/ifupdown
new file mode 100644 (file)
index 0000000..f81e08d
--- /dev/null
@@ -0,0 +1,27 @@
+# Red Hat & Debian GNU/Linux if{up,down} completion
+#
+[ $USERLAND = GNU ] && { have ifup || have ifdown; } &&
+_ifupdown()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        _configured_interfaces
+        COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
+    fi
+
+    return 0
+} &&
+complete -F _ifupdown ifup ifdown
+[ $USERLAND = GNU ] && have ifstatus && complete -F _ifupdown ifstatus
+
+# 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
diff --git a/.bash/bash_completion.d/imagemagick b/.bash/bash_completion.d/imagemagick
new file mode 100644 (file)
index 0000000..c7ba74c
--- /dev/null
@@ -0,0 +1,532 @@
+# bash completion for ImageMagick
+
+have convert && {
+_ImageMagick()
+{
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -channel)
+            COMPREPLY=( $( compgen -W 'Red Green Blue Opacity \
+                Matte Cyan Magenta Yellow Black' -- "$cur" ) )
+            return 0
+            ;;
+        -colormap)
+            COMPREPLY=( $( compgen -W 'shared private' -- "$cur" ) )
+            return 0
+            ;;
+        -colorspace)
+            COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent \
+                XYZ YCbCr YIQ YPbPr YUV CMYK' -- "$cur" ) )
+            return 0
+            ;;
+        -compose)
+            COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus \
+                Minus Add Subtract Difference Multiply Bumpmap\
+                Copy CopyRed CopyGreen CopyBlue CopyOpacity' -- "$cur" ) )
+            return 0
+            ;;
+        -compress)
+            COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG \
+                Lossless LZW RLE Zip' -- "$cur" ) )
+            return 0
+            ;;
+        -dispose)
+            COMPREPLY=( $( compgen -W 'Undefined None Background Previous' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -encoding)
+            COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert \
+                AdobeStandard AppleRoman BIG5 GB2312 Latin2 \
+                None SJIScode Symbol Unicode Wansung' -- "$cur"))
+            return 0
+            ;;
+        -endian)
+            COMPREPLY=( $( compgen -W 'MSB LSB' -- "$cur" ) )
+            return 0
+            ;;
+        -filter)
+            COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite \
+                Hanning Hamming Blackman Gaussian Quadratic \
+                Cubic Catrom Mitchell Lanczos Bessel Sinc' -- "$cur" ) )
+            return 0
+            ;;
+        -format)
+            COMPREPLY=( $( compgen -W "$( convert -list format | \
+                awk '/ [r-][w-][+-] / {print $1}' | \
+                tr -d '*' | tr [:upper:] [:lower:] )" -- "$cur" ) )
+            return 0
+            ;;
+        -gravity)
+            COMPREPLY=( $( compgen -W 'Northwest North NorthEast \
+                West Center East SouthWest South SouthEast' -- "$cur" ) )
+            return 0
+            ;;
+        -intent)
+            COMPREPLY=( $( compgen -W 'Absolute Perceptual \
+                Relative Saturation' -- "$cur" ) )
+            return 0
+            ;;
+        -interlace)
+            COMPREPLY=( $( compgen -W 'None Line Plane Partition' -- "$cur" ) )
+            return 0
+            ;;
+        -limit)
+            COMPREPLY=( $( compgen -W 'Disk File Map Memory' -- "$cur" ) )
+            return 0
+            ;;
+        -list)
+            COMPREPLY=( $( compgen -W 'Delegate Format Magic Module Resource \
+                Type' -- "$cur" ) )
+            return 0
+            ;;
+        -map)
+            COMPREPLY=( $( compgen -W 'best default gray red green blue' \
+                -- "$cur" ) )
+            _filedir
+            return 0
+            ;;
+        -noise)
+            COMPREPLY=( $( compgen -W 'Uniform Gaussian Multiplicative \
+                Impulse Laplacian Poisson' -- "$cur" ) )
+            return 0
+            ;;
+        -preview)
+            COMPREPLY=( $( compgen -W 'Rotate Shear Roll Hue \
+                Saturation Brightness Gamma Spiff \
+                Dull Grayscale Quantize Despeckle \
+                ReduceNoise AddNoise Sharpen Blur \
+                Treshold EdgeDetect Spread Shade \
+                Raise Segment Solarize Swirl Implode \
+                Wave OilPaint CharcoalDrawing JPEG' -- "$cur" ) )
+            return 0
+            ;;
+        -mask|-profile|-texture|-tile|-write)
+            _filedir
+            return 0
+            ;;
+        -type)
+            COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette PaletteMatte \
+                TrueColor TrueColorMatte ColorSeparation ColorSeparationlMatte \
+                Optimize' -- "$cur" ) )
+            return 0
+            ;;
+        -units)
+            COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch \
+                PixelsPerCentimeter' -- "$cur" ) )
+            return 0
+            ;;
+        -virtual-pixel)
+            COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' -- "$cur" ) )
+            return 0
+            ;;
+        -visual)
+            COMPREPLY=( $( compgen -W 'StaticGray GrayScale StaticColor \
+                PseudoColor TrueColor DirectColor defaut visualid' -- "$cur" ))
+            return 0
+            ;;
+    esac
+}
+
+_convert()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-adaptive-blur -adaptive-resize \
+            -adaptive-sharpen -adjoin -affine -alpha -annotate \
+            -antialias -append -attenuate -authenticate \
+            -auto-orient -average -background -bench -bias \
+            -black-point-compensation -black-threshold \
+            -blue-primary -blur -border -bordercolor -caption \
+            -channel -charcoal -chop -clip -clip-mask -clip-path \
+            -clone -clut -coalesce -colorize -colors -colorspace \
+            -combine -comment -compose -composite -compress \
+            -contrast -contrast-stretch -convolve -crop -cycle \
+            -debug -decipher -deconstruct -define -delay -delete \
+            -density -depth -despeckle -display -dispose -distort \
+            -dither -draw -edge -emboss -encipher -encoding \
+            -endian -enhance -equalize -evaluate -extent -extract \
+            -family -fill -filter -flatten -flip -floodfill -flop \
+            -font -format -frame -fuzz -fx -gamma -gaussian-blur \
+            -geometry -gravity -green-primary -help -identify \
+            -implode -insert -intent -interlace -interpolate \
+            -label -lat -layers -level -limit -linear-stretch \
+            -liquid-rescale -list -log -loop -map -mask \
+            -mattecolor -median -modulate -monitor -monochrome \
+            -morph -mosaic -motion-blur -negate -noise -normalize \
+            -opaque -ordered-dither -orient -page -paint -ping \
+            -pointsize -polaroid -posterize -preview -print \
+            -process -profile -quality -quantize -quiet \
+            -radial-blur -raise -random-threshold -recolor \
+            -red-primary -regard-warnings -region -render -repage \
+            -resample -resize -respect-parenthesis -reverse -roll \
+            -rotate -sample -sampling-factor -scale -scene -seed \
+            -segment -separate -sepia-tone -set -shade -shadow \
+            -sharpen -shave -shear -sigmoidal-contrast -size \
+            -sketch -solarize -splice -spread -stretch -strip \
+            -stroke -strokewidth -style -swap -swirl -taint \
+            -texture -threshold -thumbnail -tile -tile-offset \
+            -tint -transform -transparent -transparent-color \
+            -transpose -transverse -treedepth -trim -type \
+            -undercolor -unique-colors -units -unsharp -verbose \
+            -version -view -vignette -virtual-pixel -wave \
+            -weight -white-point -white-threshold \
+            -write' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+adjoin +append +compress \
+            +contrast +debug +dither +endian +gamma +label +map \
+            +mask +matte +negate +noise +page +raise +render \
+            +write' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _convert convert
+
+_mogrify()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-adaptive-blur -adaptive-resize \
+            -adaptive-sharpen -adjoin -affine -alpha -annotate \
+            -antialias -attenuate -authenticate -auto-orient \
+            -background -bias -black-point-compensation \
+            -black-threshold -blue-primary -blur -border \
+            -bordercolor -caption -channel -charcoal -chop -clip \
+            -clip-mask -clip-path -clut -colorize -colors \
+            -colorspace -comment -compose -compress -contrast \
+            -contrast-stretch -convolve -cycle -debug -decipher \
+            -define -delay -density -depth -despeckle -display \
+            -dispose -distort -dither -draw -edge -emboss \
+            -encipher -encoding -endian -enhance -equalize \
+            -evaluate -extent -extract -family -fill -filter \
+            -flip -floodfill -flop -font -format -frame -fuzz \
+            -gamma -gaussian-blur -geometry -gravity \
+            -green-primary -help -identify -implode -intent \
+            -interlace -interpolate -label -lat -layers -level \
+            -limit -linear-stretch -liquid-rescale -list -log \
+            -loop -mask -mattecolor -median -modulate -monitor \
+            -monochrome -motion-blur -negate -noise -normalize \
+            -opaque -ordered-dither -orient -page -paint -path \
+            -ping -pointsize -polaroid -posterize -preview -print \
+            -profile -quality -quantize -quiet -radial-blur \
+            -raise -random-threshold -recolor -red-primary \
+            -regard-warnings -region -render -repage -resample \
+            -resize -roll -rotate -sample -sampling-factor -scale \
+            -scene -seed -segment -sepia-tone -set -shade -shadow \
+            -sharpen -shave -shear -sigmoidal-contrast -size \
+            -sketch -solarize -splice -spread -stretch -strip \
+            -stroke -strokewidth -style -swirl -taint -texture \
+            -threshold -thumbnail -tile -tile-offset -tint \
+            -transform -transparent -transparent-color -transpose \
+            -transverse -treedepth -trim -type -undercolor \
+            -unique-colors -units -unsharp -verbose -version \
+            -view -vignette -virtual-pixel -wave -weight \
+            -white-point -white-threshold' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
+            +endian +gamma +label +map +mask +matte +negate +page \
+            +raise' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _mogrify mogrify
+
+_display()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-alpha -antialias -authenticate \
+            -auto-orient -backdrop -background -border \
+            -bordercolor -borderwidth -channel -clip \
+            -clip-path -coalesce -colormap -colors -colorspace \
+            -comment -compress -contrast -crop -debug -decipher \
+            -define -delay -density -depth -despeckle -display \
+            -dispose -dither -edge -endian -enhance -extract \
+            -filter -flatten -flip -flop -font -foreground \
+            -format -frame -gamma -geometry -help -iconGeometry \
+            -iconic -identify -immutable -interlace -interpolate \
+            -label -limit -list -log -loop -map -mattecolor \
+            -monitor -monochrome -name -negate -page -profile \
+            -quality -quantize -quiet -raise -regard-warnings \
+            -remote -repage -resample -resize \
+            -respect-parenthesis -roll -rotate -sample \
+            -sampling-factor -scenes -seed -segment -set \
+            -shared-memory -sharpen -size -strip -texture -title \
+            -transparent-color -treedepth -trim -update \
+            -usePixmap -verbose -version -virtual-pixel -visual \
+            -window -window-group -write' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
+            +endian +gamma +label +map +matte +negate +page \
+            +raise +write' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _display display
+
+_animate()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-alpha -authenticate -backdrop \
+            -background -bordercolor -borderwidth -channel \
+            -coalesce -colormap -colors -colorspace -crop -debug \
+            -decipher -define -delay -density -depth -display \
+            -dispose -dither -extract -filter -flatten -font \
+            -foreground -format -gamma -geometry -help \
+            -iconGeometry -iconic -identify -immutable -interlace \
+            -interpolate -limit -list -log -loop -map -mattecolor \
+            -mattecolor -monitor -monochrome -name -page -pause \
+            -quantize -quiet -regard-warnings -remote -repage \
+            -resample -resize -respect-parenthesis -rotate \
+            -sampling-factor -scenes -seed -set -shared-memory \
+            -size -strip -title -transparent-color -treedepth \
+            -trim -verbose -version -virtual-pixel -visual \
+            -window' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' \
+            -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _animate animate
+
+_identify()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-alpha -antialias -authenticate \
+            -channel -colorspace -crop -debug -define -density \
+            -depth -extract -format -fuzz -gamma -help -interlace \
+            -interpolate -limit -list -log -monitor -ping -quiet \
+            -regard-warnings -respect-parenthesis \
+            -sampling-factor -seed -set -size -strip -units \
+            -verbose -version -virtual-pixel' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _identify identify
+
+_montage()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-adjoin -affine -alpha \
+            -authenticate -background -blue-primary -blur -border \
+            -bordercolor -borderwidth -caption -channel -clone \
+            -coalesce -colors -colorspace -comment -compose \
+            -compress -crop -debug -define -density -depth \
+            -display -dispose -dither -draw -encoding -endian \
+            -extract -fill -filter -flatten -flip -flop -font \
+            -format -frame -gamma -geometry -gravity \
+            -green-primary -help -identify -interlace \
+            -interpolate -label -limit -list -log -mattecolor \
+            -mode -monitor -monochrome -origin -page -pointsize \
+            -polaroid -profile -quality -quantize -quiet \
+            -red-primary -regard-warnings -repage -resize \
+            -respect-parenthesis -rotate -sampling-factor -scenes \
+            -seed -set -shadow -size -strip -stroke -texture \
+            -thumbnail -tile -title -transform -transparent \
+            -transparent-color -treedepth -trim -type -units \
+            -verbose -version -virtual-pixel \
+            -white-point' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither \
+            +endian +gamma +label +matte +page' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _montage montage
+
+_composite()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-affine -alpha -authenticate \
+            -blend -blue-primary -border -bordercolor -channel \
+            -colors -colorspace -comment -compose -compress \
+            -debug -decipher -define -density -depth -displace \
+            -display -dispose -dissolve -dither -encipher \
+            -encoding -endian -extract -filter -font -format \
+            -geometry -gravity -green-primary -help -identify \
+            -interlace -interpolate -label -limit -list -log \
+            -monitor -monochrome -negate -page -profile -quality \
+            -quantize -quiet -red-primary -regard-warnings \
+            -repage -resize -respect-parenthesis -rotate \
+            -sampling-factor -scene -seed -sharpen -shave -size \
+            -stegano -stereo -strip -swap -thumbnail -tile \
+            -transform -transparent-color -treedepth -type -units \
+            -unsharp -verbose -version -virtual-pixel -watermark \
+            -white-point -write' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label \
+            +matte +negate +page +write' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _composite composite
+
+_compare()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-alpha -authenticate -channel \
+            -colorspace -compress -debug -decipher -define \
+            -density -depth -encipher -extract -format -fuzz \
+            -help -highlight-color -identify -interlace -limit \
+            -list -log -metric -monitor -passphrase -profile \
+            -quality -quantize -quiet -regard-warnings \
+            -respect-parenthesis -sampling-factor -seed -set \
+            -size -transparent-color -type -verbose -version \
+            -virtual-pixel' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _compare compare
+
+_conjure()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-debug -help -list -log -monitor -quiet \
+            -regard-warnings -seed -verbose -version' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _conjure conjure
+
+_import()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-adjoin -annotate -border -channel \
+            -colors -colorspace -comment -compress -crop -debug \
+            -define -delay -density -depth -descend -display \
+            -dispose -dither -encipher -encoding -endian -filter \
+            -format -frame -geometry -gravity -help -identify \
+            -interlace -interpolate -label -limit -list -log \
+            -monitor -monochrome -negate -page -pause -pointsize \
+            -quality -quantize -quiet -regard-warnings -repage \
+            -resize -respect-parenthesis -rotate -sampling-factor \
+            -scene -screen -seed -set -silent -snaps -strip \
+            -thumbnail -transparent -transparent-color -treedepth \
+            -trim -type -verbose -version -virtual-pixel \
+            -window' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _import import
+
+_stream()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _ImageMagick
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-authenticate -channel -colorspace \
+            -compress -debug -define -density -depth -extract \
+            -help -identify -interlace -interpolate -limit -list \
+            -log -map -monitor -quantize -quiet -regard-warnings \
+            -respect-parenthesis -sampling-factor -seed -set \
+            -size -storage-type -transparent-color -verbose \
+            -version -virtual-pixel' -- "$cur" ) )
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _stream stream
+}
+
+# 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
diff --git a/.bash/bash_completion.d/info b/.bash/bash_completion.d/info
new file mode 100644 (file)
index 0000000..367cade
--- /dev/null
@@ -0,0 +1,58 @@
+# bash completion for info
+
+have info &&
+_info()
+{
+    local cur i infopath
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _expand || return 0
+
+    # default completion if parameter contains /
+    if [[ "$cur" == */* ]]; then
+        _filedir
+        return 0
+    fi
+
+    infopath='/usr/share/info'
+
+    if [ "${INFOPATH: -1:1}" == ':' ]; then
+        infopath=${INFOPATH}${infopath}
+    elif [ ${INFOPATH:+set} ]; then
+        infopath=$INFOPATH
+    fi
+
+    infopath=$infopath:
+    if [ -n "$cur" ]; then
+        infopath="${infopath//://$cur* }"
+    else
+        infopath="${infopath//:// }"
+    fi
+
+    # redirect stderr for when path doesn't exist
+    COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) )
+    # weed out directory path names and paths to info pages
+    COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
+    # weed out info dir file
+    for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
+        if [ "${COMPREPLY[$i]}" == 'dir' ]; then
+            unset COMPREPLY[$i];
+        fi;
+    done
+    # strip suffix from info pages
+    COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} )
+    COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
+
+    return 0
+} &&
+complete -F _info info
+
+# 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
diff --git a/.bash/bash_completion.d/ipmitool b/.bash/bash_completion.d/ipmitool
new file mode 100644 (file)
index 0000000..3a90eeb
--- /dev/null
@@ -0,0 +1,214 @@
+# bash completion for ipmitool
+
+have ipmitool && {
+
+_ipmitool_singleline_help()
+{
+    COMPREPLY=( $( compgen -W "$( $1 $2 2>&1 | \
+        sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p' )" -- "$cur" ) )
+}
+
+_ipmitool()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h|-V|-p|-U|-e|-k|-y|-P|-m|-b|-t|-B|-T|-l)
+            return 0
+            ;;
+        -d)
+            COMPREPLY=( $( compgen -W "$( \
+                command ls -d /dev/ipmi* /dev/ipmi/* /dev/ipmidev/* \
+                2>/dev/null | sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p' )" \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -I)
+            COMPREPLY=( $( compgen -W "$( $1 -h 2>&1 | \
+                sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \
+                -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p' )" \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -H)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -f|-S|-O)
+            _filedir
+            return 0
+            ;;
+        -C)
+            COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -L)
+            COMPREPLY=( $( compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -A)
+            COMPREPLY=( $( compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur" ) )
+            return 0
+            ;;
+        -o)
+            COMPREPLY=( $( compgen -W "$( $1 -o list 2>&1 | \
+                awk '/^[ \t]+/ { print $1 }' ) list" -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-h -V -v -c -d -I -H -p -U -f -S -a \
+            -e -C -k -y -L -A -P -E -K -m -b -t -B -T -l -o -O' -- "$cur" ) )
+        return 0
+    fi
+
+    # Find out command and subcommand
+
+    local cmds=( raw i2c spd lan chassis power event mc sdr sensor fru gendev
+        sel pef sol tsol isol user channel session sunoem kontronoem picmg fwum
+        firewall shell exec set hpm ekanalyzer)
+    local i c cmd subcmd
+    for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        [[ -n $cmd ]] && subcmd=${COMP_WORDS[i]} && break
+        for c in ${cmds[@]}; do
+            [ ${COMP_WORDS[i]} = $c ] && cmd=$c && break
+        done
+    done
+
+    if [ -z "$cmd" ]; then
+        COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) )
+        return 0
+    fi
+
+    # Command/subcommand completions
+
+    case $cmd in
+
+        shell)
+            ;;
+
+        exec)
+            _filedir
+            ;;
+
+        chassis|power|kontronoem|fwum)
+            _ipmitool_singleline_help $1 $cmd
+            ;;
+
+        lan)
+            case $subcmd in
+                print|set)
+                    ;;
+                alert)
+                    [ "$prev" = alert ] && \
+                        COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) )
+                    ;;
+                stats)
+                    [ "$prev" = stats ] && \
+                        COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) )
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W 'print set alert stats' \
+                        -- "$cur" ) )
+                    ;;
+            esac
+            ;;
+
+        sdr)
+            case $subcmd in
+                get|info|type|list|entity)
+                    ;;
+                elist)
+                    COMPREPLY=( $( compgen -W 'all full compact event mclog fru
+                        generic' -- "$cur" ) )
+                    ;;
+                dump)
+                    _filedir
+                    ;;
+                fill)
+                    case $prev in
+                        fill)
+                            COMPREPLY=( $( compgen -W 'sensors file' \
+                                -- "$cur" ) )
+                            ;;
+                        file)
+                            _filedir
+                            ;;
+                    esac
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W 'get info type list elist entity
+                        dump fill' -- "$cur" ) )
+                    ;;
+            esac
+            ;;
+
+        sensor)
+            case $subcmd in
+                list|get|thresh)
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W 'list get thresh' -- "$cur" ) )
+                    ;;
+            esac
+            ;;
+
+        sel)
+            case $subcmd in
+                info|clear|list|elist|delete)
+                    ;;
+                add|save|writeraw|readraw)
+                    _filedir
+                    ;;
+                time)
+                    [ "$prev" = time ] && \
+                        COMPREPLY=( $( compgen -W 'get set' -- "$cur" ) )
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W 'info clear list elist delete add
+                        get save writeraw readraw time' -- "$cur" ) )
+                    ;;
+            esac
+            ;;
+
+        user)
+            case $subcmd in
+                summary|list|disable|enable|priv|test)
+                    ;;
+                set)
+                    [ "$prev" = set ] && \
+                        COMPREPLY=( $( compgen -W 'name password' -- "$cur" ) )
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W 'summary list set disable enable
+                        priv test' -- "$cur" ) )
+                    ;;
+            esac
+            ;;
+
+        set)
+            [ "$prev" = set ] && \
+                COMPREPLY=( $( compgen -W 'hostname username password privlvl
+                    authtype localaddr targetaddr port csv verbose' \
+                        -- "$cur" ) )
+            ;;
+
+    esac
+}
+
+} &&
+complete -F _ipmitool ipmitool
+
+# 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
diff --git a/.bash/bash_completion.d/iproute2 b/.bash/bash_completion.d/iproute2
new file mode 100644 (file)
index 0000000..f5d7bbd
--- /dev/null
@@ -0,0 +1,285 @@
+# iproute2 tools completion
+
+have ip &&
+_ip()
+{
+    COMPREPLY=()
+    local cur prev words cword
+    _get_comp_words_by_ref cur prev words cword
+
+    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="$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="$c up down"
+                                COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
+                                ;;
+                        esac
+                    fi
+                    ;;
+                show)
+                    [[ $cword -eq $subcword+1 ]] && _available_interfaces
+                    ;;
+                *)
+                    [[ $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)
+                    # TODO
+                    ;;
+                *)
+                    [[ $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
+                list|add|del|flush)
+                    # TODO
+                    ;;
+                *)
+                    [[ $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
+                add|change|del|show|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
+
+# 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
diff --git a/.bash/bash_completion.d/ipsec b/.bash/bash_completion.d/ipsec
new file mode 100644 (file)
index 0000000..acb8c99
--- /dev/null
@@ -0,0 +1,51 @@
+# Linux ipsec(8) completion (for FreeS/WAN)
+#
+[ $UNAME = Linux ] && have ipsec &&
+_ipsec()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual \
+            pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp \
+            tncfg whack' -- "$cur" ) )
+        return 0
+    fi
+
+    case ${COMP_WORDS[1]} in
+        auto)
+            COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \
+                --replace --down --route --unroute \
+                --ready --status --rereadsecrets' \
+                -- "$cur" ) )
+            ;;
+        manual)
+            COMPREPLY=( $( compgen -W '--up --down --route --unroute \
+                --union' -- "$cur" ) )
+            ;;
+        ranbits)
+            COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \
+                -- "$cur" ) )
+            ;;
+        setup)
+            COMPREPLY=( $( compgen -W '--start --stop --restart' -- "$cur" ) )
+            ;;
+        *)
+            ;;
+    esac
+
+    return 0
+} &&
+complete -F _ipsec ipsec
+
+# 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
diff --git a/.bash/bash_completion.d/iptables b/.bash/bash_completion.d/iptables
new file mode 100644 (file)
index 0000000..bd0e462
--- /dev/null
@@ -0,0 +1,70 @@
+# bash completion for iptables
+
+have iptables &&
+_iptables()
+{
+    local cur prev table chain
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
+
+    if [[ $COMP_LINE == *-t\ *filter* ]]; then
+        table="-t filter"
+    elif [[ $COMP_LINE == *-t\ *nat* ]]; then
+        table="-t nat"
+    elif [[ $COMP_LINE == *-t\ *mangle* ]]; then
+        table="-t mangle"
+    fi
+
+    _split_longopt
+
+    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
+
+# 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
diff --git a/.bash/bash_completion.d/ipv6calc b/.bash/bash_completion.d/ipv6calc
new file mode 100644 (file)
index 0000000..20e810d
--- /dev/null
@@ -0,0 +1,57 @@
+have ipv6calc &&
+_ipv6calc()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n = cur prev
+    #cur=`_get_cword =`
+    #prev=`_get_pword`
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        -d|--debug)
+            return 0
+            ;;
+        -I|--in|-O|--out|-A|--action)
+            # With ipv6calc < 0.73.0, -m does nothing here, so use sed instead.
+            COMPREPLY=( $( compgen -W "$( ipv6calc "$prev" -h 2>&1 | \
+                sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p' )" \
+                -- "$cur" ) )
+            return 0
+            ;;
+        --db-geoip|--db-ip2location-ipv4|--db-ip2location-ipv6)
+            _filedir
+            return 0
+            ;;
+        --printstart|--printend)
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --debug --quiet --in \
+            --out --action --examples --showinfo --show_types \
+            --machine_readable --db-geoip --db-geoip-default \
+            --db-ip2location-ipv4 --db-ip2location-ipv6 \
+            --lowercase --uppercase --printprefix --printsuffix \
+            --maskprefix --masksuffix --printstart --printend \
+            --printcompressed --printuncompressed \
+            --printfulluncompressed --printmirrored' -- "$cur" ) )
+        return 0
+    fi
+
+    return 0
+} &&
+complete -F _ipv6calc ipv6calc
+
+# 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
diff --git a/.bash/bash_completion.d/isql b/.bash/bash_completion.d/isql
new file mode 100644 (file)
index 0000000..f0ddbd7
--- /dev/null
@@ -0,0 +1,20 @@
+# isql completion by Victor Bogado da Silva Lins <victor@bogado.net>
+
+have isql &&
+_isql()
+{
+    local cur
+    _get_comp_words_by_ref cur
+
+    [ -f "$ODBCINI" ] \
+        && COMPREPLY=( $( command grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) )
+} &&
+complete -F _isql isql
+
+# 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
diff --git a/.bash/bash_completion.d/jar b/.bash/bash_completion.d/jar
new file mode 100644 (file)
index 0000000..d703019
--- /dev/null
@@ -0,0 +1,36 @@
+# jar(1) completion
+
+have jar &&
+_jar()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [ $COMP_CWORD = 1 ]; then
+        COMPREPLY=( $( compgen -W 'c t x u' -- "$cur" ) )
+        return 0
+    fi
+
+    case ${COMP_WORDS[1]} in
+        *c*f)
+            _filedir
+            ;;
+        *f)
+            _filedir '@([ejw]ar|zip|apk)'
+            ;;
+        *)
+            _filedir
+            ;;
+    esac
+} &&
+complete -F _jar jar
+
+# 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
diff --git a/.bash/bash_completion.d/java b/.bash/bash_completion.d/java
new file mode 100644 (file)
index 0000000..460ae28
--- /dev/null
@@ -0,0 +1,533 @@
+# bash completion for java, javac and javadoc
+
+# available path elements completion
+have java || have javac || have javadoc &&
+_java_path()
+{
+    cur=${cur##*:}
+    _filedir '@(jar|zip)'
+}
+
+have java || have javadoc && {
+# exact classpath determination
+_java_find_classpath()
+{
+    local i
+
+    # search first in current options
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == -@(cp|classpath) ]]; then
+            classpath=${COMP_WORDS[i+1]}
+            break
+        fi
+    done
+
+    # default to environment
+    [ -z "$classpath" ] && classpath=$CLASSPATH
+
+    # default to current directory
+    [ -z "$classpath" ] && classpath=.
+}
+
+# exact sourcepath determination
+_java_find_sourcepath()
+{
+    local i
+
+    # search first in current options
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then
+            sourcepath=${COMP_WORDS[i+1]}
+            break
+        fi
+    done
+
+    # default to classpath
+    if [ -z "$sourcepath" ]; then
+        _java_find_classpath
+        sourcepath=$classpath
+    fi
+}
+
+# available classes completion
+_java_classes()
+{
+    local classpath i
+
+    # find which classpath to use
+    _java_find_classpath
+
+    # convert package syntax to path syntax
+    cur=${cur//.//}
+    # parse each classpath element for classes
+    for i in ${classpath//:/ }; do
+        if [[ "$i" == *.@(jar|zip) && -r $i ]]; then
+            if type zipinfo &>/dev/null; then
+                COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
+                    "$i" "$cur*" 2>/dev/null | \
+                    command grep '^[^$]*\.class$' ) )
+            else
+                COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \
+                    "$cur" | command grep '^[^$]*\.class$' ) )
+            fi
+
+        elif [ -d $i ]; then
+            # Intentionally looking for *.class only in $i (not subdirs),
+            # see Debian bug #496828.
+            COMPREPLY=( "${COMPREPLY[@]}"
+                $( command ls $i/$cur*.class 2>/dev/null | \
+                    sed -ne '/\$/d' -e "s|^$i//*||p" ) )
+
+            # FIXME: if we have foo.class and foo/, the completion
+            # returns "foo/"... how to give precedence to files
+            # over directories?
+        fi
+    done
+
+    # remove class extension
+    COMPREPLY=( ${COMPREPLY[@]%.class} )
+    # convert path syntax to package syntax
+    COMPREPLY=( ${COMPREPLY[@]//\//.} )
+}
+
+# available packages completion
+_java_packages()
+{
+    local sourcepath i
+
+    # find which sourcepath to use
+    _java_find_sourcepath
+
+    # convert package syntax to path syntax
+    cur=${cur//.//}
+    # parse each sourcepath element for packages
+    for i in ${sourcepath//:/ }; do
+        if [ -d $i ]; then
+            COMPREPLY=( "${COMPREPLY[@]}" $( command ls -F -d \
+                $i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ) )
+        fi
+    done
+    # keep only packages
+    COMPREPLY=( $( tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$" ) )
+    # remove packages extension
+    COMPREPLY=( ${COMPREPLY[@]%/} )
+    # convert path syntax to package syntax
+    cur=${COMPREPLY[@]//\//.}
+}
+}
+
+# java completion
+#
+have java &&
+_java()
+{
+    local cur prev words cword i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev words cword
+
+    for ((i=1; i < $cword; i++)); do
+        case ${words[$i]} in
+            -cp|-classpath)
+                ((i++)) # skip the classpath string.
+                ;;
+            -*)
+                # this is an option, not a class/jarfile name.
+                ;;
+            *)
+                # once we've seen a class, just do filename completion
+                _filedir
+                return 0
+                ;;
+        esac
+    done
+
+    case $cur in
+        # standard option completions
+        -verbose:*)
+            COMPREPLY=( $( compgen -W 'class gc jni' -- "${cur#*:}" ) )
+            return 0
+            ;;
+        -javaagent:*)
+            cur=${cur#*:}
+            _filedir '@(jar|zip)'
+            return 0
+            ;;
+        -agentpath:*)
+            cur=${cur#*:}
+            _filedir so
+            return 0
+            ;;
+        # various non-standard option completions
+        -splash:*)
+            cur=${cur#*:}
+            _filedir '@(gif|jp?(e)g|png)'
+            return 0
+            ;;
+        -Xbootclasspath*:*)
+            _java_path
+            return 0
+            ;;
+        -Xcheck:*)
+            COMPREPLY=( $( compgen -W 'jni' -- "${cur#*:}" ) )
+            return 0
+            ;;
+        -Xgc:*)
+            COMPREPLY=( $( compgen -W 'singlecon gencon singlepar genpar' \
+                -- "${cur#*:}" ) )
+            return 0
+            ;;
+        -Xgcprio:*)
+            COMPREPLY=( $( compgen -W 'throughput pausetime deterministic' \
+                -- "${cur#*:}" ) )
+            return 0
+            ;;
+        -Xloggc:*|-Xverboselog:*)
+            cur=${cur#*:}
+            _filedir
+            return 0
+            ;;
+        -Xshare:*)
+            COMPREPLY=( $( compgen -W 'auto off on' -- "${cur#*:}" ) )
+            return 0
+            ;;
+        -Xverbose:*)
+            COMPREPLY=( $( compgen -W 'memory load jni cpuinfo codegen opt
+                gcpause gcreport' -- "${cur#*:}" ) )
+            return 0
+            ;;
+        -Xverify:*)
+            COMPREPLY=( $( compgen -W 'all none remote' -- "${cur#*:}" ) )
+            return 0
+            ;;
+        # the rest that we have no completions for
+        -D*|-*:*)
+            return 0
+            ;;
+    esac
+
+    case $prev in
+        -cp|-classpath)
+            _java_path
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        # standard options
+        COMPREPLY=( $( compgen -W '-client -server -agentlib: -agentpath:
+            -classpath -D -d32 -d64 -enableassertions -disableassertions
+            -enablesystemassertions -disablesystemassertions -jar -javaagent:
+            -verbose -verbose -version -showversion -help -X' -- "$cur" ) )
+    else
+        if [[ "$prev" == -jar ]]; then
+            # jar file completion
+            _filedir jar
+        else
+            # classes completion
+            _java_classes
+        fi
+    fi
+
+    [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == -*[:=] ]] && \
+        type compopt &>/dev/null && compopt -o nospace
+
+    __ltrim_colon_completions "$cur"
+} &&
+complete -F _java java
+
+have javadoc &&
+_javadoc()
+{
+    COMPREPLY=()
+    local cur prev classpath
+
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -overview|-helpfile)
+            _filedir '?(x)htm?(l)'
+            return 0
+            ;;
+        -stylesheetfile)
+            _filedir css
+            return 0
+            ;;
+        -d|-link|-linkoffline)
+            # TODO: -linkoffline takes two arguments
+            _filedir -d
+            return 0
+            ;;
+        -classpath|-bootclasspath|-docletpath|-sourcepath|-extdirs)
+            _java_path
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        # relevant options completion
+        COMPREPLY=( $( compgen -W '-overview -public -protected \
+            -package -private -help -doclet -docletpath \
+            -sourcepath -classpath -exclude -subpackages \
+            -breakiterator -bootclasspath -source -extdirs \
+            -verbose -locale -encoding -J -d -use -version \
+            -author -docfilessubdirs -splitindex \
+            -windowtitle -doctitle -header -footer -bottom \
+            -link -linkoffline -excludedocfilessubdir \
+            -group -nocomment -nodeprecated -noqualifier \
+            -nosince -nodeprecatedlist -notree -noindex \
+            -nohelp -nonavbar -quiet -serialwarn -tag \
+            -taglet -tagletpath -charset -helpfile \
+            -linksource -stylesheetfile -docencoding' -- "$cur" ) )
+    else
+        # source files completion
+        _filedir java
+        # packages completion
+        _java_packages
+    fi
+} &&
+complete -F _javadoc javadoc
+
+have javac &&
+_javac()
+{
+    COMPREPLY=()
+    local cur prev
+
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -d)
+            _filedir -d
+            return 0
+            ;;
+        -classpath|-bootclasspath|-sourcepath|-extdirs)
+            _java_path
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        # relevant options completion
+        COMPREPLY=( $( compgen -W '-g -g:none -g:lines -g:vars \
+            -g:source -O -nowarn -verbose -deprecation -classpath \
+            -sourcepath -bootclasspath -extdirs -d -encoding -source \
+            -target -help' -- "$cur" ) )
+    else
+        # source files completion
+        _filedir java
+    fi
+} &&
+complete -F _javac javac
+
+have pack200 &&
+_pack200()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -S|--segment-limit|-P|--pass-file|-C|--class-attribute|\
+        -F|--field-attribute|-M|--method-attribute|-D|--code-attribute|\
+        '-?'|-h|--help|-V|--version|-J)
+            return 0
+            ;;
+        -E|--effort)
+            COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" ) )
+            return 0
+            ;;
+        -H|--deflate-hint)
+            COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) )
+            return 0
+            ;;
+        -m|--modification-time)
+            COMPREPLY=( $( compgen -W 'latest keep' -- "$cur" ) )
+            return 0
+            ;;
+        -U|--unknown-attribute)
+            COMPREPLY=( $( compgen -W 'error strip pass' -- "$cur" ) )
+            return 0
+            ;;
+        -f|--config-file)
+            _filedir properties
+            return 0
+            ;;
+        -l|--log-file)
+            COMPREPLY=( $( compgen -W '-' -- "$cur" ) )
+            _filedir log
+            return 0
+            ;;
+        -r|--repack)
+            _filedir jar
+            return 0
+            ;;
+    esac
+
+    # Check if a pack or a jar was already given.
+    local i pack=false jar=false
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )) ; do
+        case ${COMP_WORDS[i]} in
+            *.pack|*.pack.gz) pack=true ;;
+            *.jar) jar=true ;;
+        esac
+    done
+
+    if ! $pack ; then
+        if [[ "$cur" == -* ]] ; then
+            COMPREPLY=( $( compgen -W '--no-gzip --gzip --strip-debug \
+                --no-keep-file-order --segment-limit= --effort= \
+                --deflate-hint= --modification-time= --pass-file= \
+                --unknown-attribute= --class-attribute= --field-attribute= \
+                --method-attribute= --code-attribute= --config-file= \
+                --verbose --quiet --log-file= --help --version -J \
+                --repack' -- "$cur" ) )
+            [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && \
+                type compopt &>/dev/null && compopt -o nospace
+        else
+            _filedir 'pack?(.gz)'
+        fi
+    elif ! $jar ; then
+        _filedir jar
+    fi
+} &&
+complete -F _pack200 pack200
+
+have unpack200 &&
+_unpack200()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        '-?'|-h|--help|-V|--version|-J)
+            return 0
+            ;;
+        -H|--deflate-hint)
+            COMPREPLY=( $( compgen -W 'true false keep' -- "$cur" ) )
+            return 0
+            ;;
+        -l|--log-file)
+            COMPREPLY=( $( compgen -W '-' -- "$cur" ) )
+            _filedir log
+            return 0
+            ;;
+    esac
+
+    # Check if a pack or a jar was already given.
+    local i pack=false jar=false
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )) ; do
+        case ${COMP_WORDS[i]} in
+            *.pack|*.pack.gz) pack=true ;;
+            *.jar) jar=true ;;
+        esac
+    done
+
+    if ! $pack ; then
+        if [[ "$cur" == -* ]] ; then
+            COMPREPLY=( $( compgen -W '--deflate-hint= --remove-pack-file \
+                --verbose --quiet --log-file= --help --version' -- "$cur" ) )
+            [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]] && \
+                type compopt &>/dev/null && compopt -o nospace
+        else
+            _filedir 'pack?(.gz)'
+        fi
+    elif ! $jar ; then
+        _filedir jar
+    fi
+} &&
+complete -F _unpack200 unpack200
+
+have jarsigner &&
+_jarsigner()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -keystore)
+            COMPREPLY=( $( compgen -W 'NONE' -- "$cur" ) )
+            _filedir '@(jks|ks|p12|pfx)'
+            return 0
+            ;;
+        -storepass|-keypass|-sigfile|-digestalg|-sigalg|-tsacert|-altsigner|\
+        -altsignerpath|-providerName|-providerClass|-providerArg)
+            return 0
+            ;;
+        -storetype)
+            COMPREPLY=( $( compgen -W 'JKS PKCS11 PKCS12' -- "$cur" ) )
+            return 0
+            ;;
+        -signedjar)
+            _filedir jar
+            return 0
+            ;;
+        -tsa)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    # Check if a jar was already given.
+    local i jar=false
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )) ; do
+        if [[ "${COMP_WORDS[i]}" == *.jar && \
+            "${COMP_WORDS[i-1]}" != -signedjar ]] ; then
+            jar=true
+            break
+        fi
+    done
+
+    if ! $jar ; then
+        if [[ "$cur" == -* ]] ; then
+            # Documented as "should not be used": -internalsf, -sectionsonly
+            COMPREPLY=( $( compgen -W '-keystore -storepass -storetype \
+                -keypass -sigfile -signedjar -digestalg -sigalg -verify \
+                -verbose -certs -tsa -tsacert -altsigner -altsignerpath \
+                -protected -providerName -providerClass -providerArg' \
+                -- "$cur" ) )
+        fi
+        _filedir jar
+    fi
+} &&
+complete -F _jarsigner jarsigner
+
+have javaws &&
+_javaws()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -help|-license|-about|-viewer|-arg|-param|-property|-update|-umask)
+            return 0
+            ;;
+        -basedir|-codebase)
+            _filedir -d
+            return 0
+            ;;
+        -uninstall|-import)
+            _filedir jnlp
+            return 0
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W "$( _parse_help "$1" -help ) " -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir jnlp
+} &&
+complete -F _javaws javaws
+
+# 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
diff --git a/.bash/bash_completion.d/k3b b/.bash/bash_completion.d/k3b
new file mode 100644 (file)
index 0000000..1965717
--- /dev/null
@@ -0,0 +1,55 @@
+# bash completion for k3b
+
+have k3b &&
+_k3b()
+{
+    local cur prev
+    _get_comp_words_by_ref cur prev
+    COMPREPLY=()
+
+    case $prev in
+        --help*|--author|-v|--version|--license|--lang)
+            return 0
+            ;;
+        --datacd|--audiocd|--videocd|--mixedcd|--emovixcd|--videodvd)
+            _filedir
+            return 0
+            ;;
+        --copydvd|--formatdvd|--videodvdrip)
+            _dvd_devices
+            return 0
+            ;;
+        --copycd|--erasecd|--cddarip|--videocdrip)
+            _cd_devices
+            _dvd_devices
+            return 0
+            ;;
+        --cdimage|--image)
+            _filedir @(cue|iso|toc)
+            return 0
+            ;;
+        --dvdimage)
+            _filedir iso
+            return 0
+            ;;
+        --ao)
+            COMPREPLY=( $( compgen -W 'alsa arts' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) )
+    else
+        _filedir
+    fi
+} &&
+complete -F _k3b k3b
+
+# 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
diff --git a/.bash/bash_completion.d/kldload b/.bash/bash_completion.d/kldload
new file mode 100644 (file)
index 0000000..e5bce0a
--- /dev/null
@@ -0,0 +1,40 @@
+# bash completion for FreeBSD kernel module commands
+
+[ $UNAME = FreeBSD ] &&
+{
+
+_kldload()
+{
+    local cur moddir
+
+    moddir=/modules/
+    [ -d $moddir ] || moddir=/boot/kernel/
+    _get_comp_words_by_ref cur
+
+    _compopt_o_filenames
+    COMPREPLY=( $( compgen -f "$moddir$cur" ) )
+    COMPREPLY=( ${COMPREPLY[@]#$moddir} )
+    COMPREPLY=( ${COMPREPLY[@]%.ko} )
+
+    return 0
+}
+complete -F _kldload kldload
+
+_kldunload()
+{
+    local cur
+    _get_comp_words_by_ref cur
+    COMPREPLY=( $( kldstat | \
+        sed -ne "s/^.*[ \t]\{1,\}\($cur[a-z_]\{1,\}\).ko$/\1/p" ) )
+}
+complete -F _kldunload kldunload
+
+}
+
+# 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
diff --git a/.bash/bash_completion.d/larch b/.bash/bash_completion.d/larch
new file mode 100644 (file)
index 0000000..e58374f
--- /dev/null
@@ -0,0 +1,48 @@
+# larch(1) completion by Alex Shinn <foof@synthcode.com>
+
+have larch &&
+_larch()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
+        COMPREPLY=( $( compgen -W ' \
+            my-id my-default-archive register-archive whereis-archive archives \
+            init-tree tree-root tree-version set-tree-version inventory \
+            tagging-method tree-lint missing-tags add delete \
+            move explicit-default set-manifest manifest check-manifest mkpatch \
+            dopatch patch-report empty-patch make-archive make-category \
+            make-branch make-version categories branches versions revisions \
+            cat-archive-log archive-cache-revision archive-cached-revisions \
+            archive-uncache-revision category-readme branch-readme \
+            version-readme make-log logs add-log log-ls cat-log \
+            log-header-field changelog log-for-merge merge-points \
+            new-on-branch import commit get get-patch lock-branch \
+            lock-revision push-mirror build-config update-config replay-config \
+            record-config show-config config-history update replay delta-patch \
+            star-merge tag prepare-branch finish-branch join-branch \
+            whats-missing what-changed file-diffs pristines lock-pristine \
+            my-revision-library library-find library-add library-remove \
+            library-archives library-categories library-branches \
+            library-versions library-revisions library-log library-file \
+            touched-files-prereqs patch-set-web update-distributions \
+            distribution-name notify my-notifier mail-new-categories \
+            mail-new-branches mail-new-versions mail-new-revisions \
+            notify-library notify-browser push-new-revisions sendmail-mailx' \
+            "$cur" ))
+    fi
+
+    return 0
+} &&
+complete -F _larch -o default larch
+
+# 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
diff --git a/.bash/bash_completion.d/ldapvi b/.bash/bash_completion.d/ldapvi
new file mode 100644 (file)
index 0000000..31e26d1
--- /dev/null
@@ -0,0 +1,72 @@
+# bash completion for ldapvi
+
+have ldapvi &&
+_ldapvi()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h|--host)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -Y|--sasl-mech)
+            COMPREPLY=( $( compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 \
+                CRAM-MD5 PLAIN ANONYMOUS' -- "$cur" ) )
+            return 0
+            ;;
+        --bind)
+            COMPREPLY=( $( compgen -W 'simple sasl' -- "$cur" ) )
+            return 0
+            ;;
+        --bind-dialog)
+            COMPREPLY=( $( compgen -W 'never auto always' -- $cur ) )
+            return 0
+            ;;
+        --scope)
+            COMPREPLY=( $( compgen -W 'base one sub' -- "$cur" ) )
+            return 0
+            ;;
+        --deref)
+            COMPREPLY=( $( compgen -W 'never searching finding always' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        --encoding)
+            COMPREPLY=( $( compgen -W 'ASCII UTF-8 binary' -- "$cur" ) )
+            return 0
+            ;;
+        --tls)
+            COMPREPLY=( $( compgen -W 'never allow try strict' \
+                -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--discover --out --in --delete \
+            --rename -h --host -D --user -w --password --bind \
+            --bind-dialog -I --sasl-interactive --bind-dialog -O \
+            --sasl-secprops -Q --sasl-quiet -R --sasl-realm -U \
+            --sasl-authcid -X --sasl-authzid -Y --sasl-mech -b \
+            --base -s --scope -S --sort --add -o --class --config \
+            -c --continue --deleteoldrdn -a --deref -d --discover \
+            -A --empty --ncoding -H --help --ldap-conf -m --may -M \
+            --managedsait --noquestions -! --noninteractive -q \
+            --quiet -R --read -Z --starttls --tls -v --verbose \
+            --ldapsearch --ldapmodify --ldapdelete --ldapmoddn' \
+            -- "$cur" ) )
+    fi
+} &&
+complete -F _ldapvi ldapvi
+
+# 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
diff --git a/.bash/bash_completion.d/lftp b/.bash/bash_completion.d/lftp
new file mode 100644 (file)
index 0000000..1de87ae
--- /dev/null
@@ -0,0 +1,52 @@
+# bash completion for lftp
+
+have lftp &&
+_lftp()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f)
+            _filedir
+            return 0
+            ;;
+        -c|-h|--help|-v|--version|-e|-u|-p)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W '-f -c --help --version -e -u -p' \
+            -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -W \
+        '$( cut -f 1 -s ~/.lftp/bookmarks 2>/dev/null )' -- "$cur" ) )
+    _known_hosts_real "$cur"
+} &&
+complete -F _lftp lftp
+
+have lftpget &&
+_lftpget()
+{
+    COMPREPLY=()
+    local cur
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W '-c -d -v' -- "$cur" ) )
+    fi
+} &&
+complete -F _lftpget lftpget
+
+# 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
diff --git a/.bash/bash_completion.d/lilo b/.bash/bash_completion.d/lilo
new file mode 100644 (file)
index 0000000..ab0d9dc
--- /dev/null
@@ -0,0 +1,60 @@
+# bash completion for lilo(8)
+
+have lilo && {
+_lilo_labels()
+{
+    COMPREPLY=( $( compgen -W "$( awk -F'=' '/label/ {print $2}' \
+        /etc/lilo.conf | sed -e 's/\"//g' )" -- "$cur" ) )
+}
+
+_lilo()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -C|-i|-m|-s|-S)
+            _filedir
+            return 0
+            ;;
+        -r)
+            _filedir -d
+            return 0
+            ;;
+        -I|-D|-R)
+            # label completion
+            _lilo_labels
+            return 0
+            ;;
+        -A|-b|-M|-u|-U)
+            # device completion
+            cur=${cur:=/dev/}
+            _filedir
+            return 0
+            ;;
+        -T)
+            # topic completion
+            COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \
+                table= video' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        # relevant options completion
+        COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \
+            -M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- "$cur" ) )
+    fi
+}
+complete -F _lilo lilo
+}
+
+# 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
diff --git a/.bash/bash_completion.d/links b/.bash/bash_completion.d/links
new file mode 100644 (file)
index 0000000..9b7b50f
--- /dev/null
@@ -0,0 +1,43 @@
+# bash completion for links
+
+have links &&
+_links()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    case $cur in
+        --*)
+            COMPREPLY=( $( compgen -W '--help' -- "$cur" ) )
+            ;;
+        -*)
+            COMPREPLY=( $( compgen -W '-async-dns -max-connections \
+                -max-connections-to-host -retries -receive-timeout \
+                -unrestartable-receive-timeout -format-cache-size \
+                -memory-cache-size -http-proxy -ftp-proxy -download-dir \
+                -assume-codepage -anonymous -dump -no-connect \
+                -source -version -help' -- "$cur" ) )
+                ;;
+        *)
+            if [ -r ~/.links/links.his ]; then
+                COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \
+                    -- "$cur" ) )
+            fi
+            _filedir '@(htm|html)'
+            return 0
+            ;;
+    esac
+
+    return 0
+} &&
+complete -F _links links
+
+# 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
diff --git a/.bash/bash_completion.d/lintian b/.bash/bash_completion.d/lintian
new file mode 100644 (file)
index 0000000..e223789
--- /dev/null
@@ -0,0 +1,186 @@
+# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
+# ex: ts=8 sw=8 noet filetype=sh
+#
+# bash completion for lintian(1) and lintian-info(1)
+
+have lintian && {
+_lintian_tags() {
+    local match search tags
+
+    tags=$( grep -e ^Tag /usr/share/lintian/checks/*.desc | cut -d\  -f2 )
+    if [[ "$cur" == *, ]]; then
+        search=${cur//,/ }
+        for item in $search; do
+            match=$(grep -nE "^Tag: $item$" /usr/share/lintian/checks/*.desc \
+                    | cut -d: -f1 )
+            tags=$( echo $tags | sed -e "s/\<$item\>//g" )
+        done
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$tags") )
+    elif [[ "$cur" == *,* ]]; then
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -P "${cur%,*}," -W "$tags" -- \
+                                      "${cur##*,}") )
+    else
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$tags" -- "$cur") )
+    fi
+    return 0
+}
+
+_lintian_checks() {
+    local match search todisable checks
+
+    checks=$(grep -e ^Check-Script -e ^Abbrev \
+             /usr/share/lintian/checks/*.desc | cut -d\  -f2 )
+    if [[ "$cur" == *, ]]; then
+        search=${cur//,/ }
+        for item in $search; do
+            match=$(grep -nE "^(Check-Script|Abbrev): $item$" \
+                    /usr/share/lintian/checks/*.desc | cut -d: -f1 )
+            todisable=$(grep -e ^Check-Script -e ^Abbrev $match | \
+                        cut -d\  -f2 )
+            for name in $todisable; do
+                checks=$( echo $checks | sed -e "s/\<$name\>//g" )
+            done
+        done
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$checks") )
+    elif [[ "$cur" == *,* ]]; then
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -P "${cur%,*}," -W "$checks" \
+                                      -- "${cur##*,}") )
+    else
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$checks" -- "$cur") )
+    fi
+    return 0
+}
+
+_lintian_infos() {
+    local match search infos
+
+    infos=$(grep -e ^Collector /usr/share/lintian/collection/*.desc \
+            | cut -d\  -f2 )
+    if [[ "$cur" == *, ]]; then
+        search=${cur//,/ }
+        for item in $search; do
+            match=$( grep -nE "^Collector: $item$" \
+                    /usr/share/lintian/collection/*.desc | cut -d: -f1 )
+            infos=$( echo $infos | sed -e "s/\<$item\>//g" )
+        done
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$infos") )
+    elif [[ "$cur" == *,* ]]; then
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -P "${cur%,*}," -W "$infos" \
+                                      -- "${cur##*,}") )
+    else
+        COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$infos" -- "$cur") )
+    fi
+    return 0
+}
+
+_lintian_arches() {
+    return 0
+}
+
+_lintian() {
+    local cur prev action lint_actions general_opts behaviour_opts \
+          configuration_opts selection_opts
+
+    _get_comp_words_by_ref cur prev
+
+    lint_actions="--setup-lab --remove-lab --check --check-part --tags \
+                  --tags-from-file --ftp-master-rejects --dont-check-part \
+                  --unpack --remove"
+    general_opts="--help --version --print-version --verbose --debug --quiet"
+    behaviour_opts="--info --display-info --display-experimental --pedantic \
+                    --display-level --suppress-tags --unpack-level \
+                    --suppress-tags-from-file --no-override --show-overrides \
+                    --color --unpack-info --md5sums --checksums --allow-root \
+                    --fail-on-warnings --keep-lab"
+    configuration_opts="--cfg --lab --archivedir --dist --area --section \
+                        --arch --root"
+    selection_opts="--all --binary --source --udeb --packages-file"
+
+    if [[ "$prev" = -* ]]; then
+        case $prev in
+            -C|--check-part|-X|--dont-check-part)
+                _lintian_checks
+                ;;
+            -T|--tags|--suppress-tags)
+                _lintian_tags
+                ;;
+            --tags-from-file|--suppress-tags-from-file|--cfg|-p|\
+            --packages-file)
+                _filedir
+                ;;
+            --lab|--archivedir|--dist|--root)
+                _filedir -d
+                ;;
+            -l|--unpack-level)
+                COMPREPLY=($(compgen -W "0 none 1 basic 2 contents" -- \
+                             "$cur"))
+                ;;
+            --color)
+                COMPREPLY=($(compgen -W "never always auto html" -- "$cur"))
+                ;;
+            -U|--unpack-info)
+                _lintian_infos
+                ;;
+            --area|--section)
+                COMPREPLY=($(compgen -W "main contrib non-free" -- "$cur"))
+                ;;
+            --arch)
+                ;;
+        esac
+    fi
+
+    case "$cur" in
+        --*)
+            COMPREPLY=($(compgen -W "$lint_actions $general_opts \
+                         $behaviour_opts $configuration_opts" -- "$cur"))
+            ;;
+        *,)
+            # If we're here, the user is trying to complete on
+            # --action tag,tag,<TAB>
+            # Only few actions permit that, re-complete them now.
+            echo $prev
+            case "$prev" in
+                -C|--check-part|-X|--dont-check-part)
+                    _lintian_checks
+                    ;;
+                -T|--tags|--suppress-tags)
+                    _lintian_tags
+                    ;;
+                -U|--unpack-info)
+                    _lintian_infos
+                    ;;
+            esac
+            ;;
+        *)
+            _filedir '@(?(u)deb|changes|dsc)'
+            ;;
+    esac
+    return 0
+}
+
+_lintian_info() {
+    local cur prev
+
+    _get_comp_words_by_ref cur prev
+
+    case "$prev" in
+        -t|--tags)
+            _lintian_tags
+            return 0
+            ;;
+    esac
+
+    case "$cur" in
+        --*)
+            COMPREPLY=($(compgen -W "--annotate --help --tags" -- "$cur"))
+            ;;
+        *)
+            _filedir
+            ;;
+    esac
+    return 0
+}
+
+complete -F _lintian lintian
+complete -F _lintian_info lintian-info
+}
diff --git a/.bash/bash_completion.d/lisp b/.bash/bash_completion.d/lisp
new file mode 100644 (file)
index 0000000..ee43a01
--- /dev/null
@@ -0,0 +1,31 @@
+# bash programmable completion for various Common Lisp implementations by
+# Nikodemus Siivola <nikodemus@random-state.net>
+
+have lisp &&
+_lisp()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    # completing an option (may or may not be separated by a space)
+    if [[ "$cur" == -* ]]; then
+    COMPREPLY=( $( compgen -W '-core -lib -batch -quit -edit -eval -init \
+        -dynamic-space-size -hinit -noinit -nositeinit -load -slave ' \
+        -- "$cur" ) )
+    else
+        _filedir
+    fi
+
+    return 0
+} &&
+complete -F _lisp -o default lisp
+
+# 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
diff --git a/.bash/bash_completion.d/lrzip b/.bash/bash_completion.d/lrzip
new file mode 100644 (file)
index 0000000..5cde88a
--- /dev/null
@@ -0,0 +1,64 @@
+# lrzip(1) completion
+
+have lrzip &&
+_lrzip()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    if [[ "$cur" == -* && $prev != -N ]]; then
+        COMPREPLY=( $( compgen -W '-w -d -o -O -S -f -D -q -L -n -l -b -g -M \
+            -T -N -v -vv -V -h' -- "$cur" ) )
+        return 0
+    fi
+
+    local xspec="*.lrz"
+
+    case $prev in
+        -w|-S|-V|-h)
+            return 0
+            ;;
+        -d)
+            xspec="!"$xspec
+            ;;
+        -o)
+            _filedir
+            return 0
+            ;;
+        -O)
+            _filedir -d
+            return 0
+            ;;
+        -L)
+            COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" ) )
+            return 0
+            ;;
+        -T)
+            COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9 10' -- "$cur" ) )
+            return 0
+            ;;
+        -N)
+            COMPREPLY=( $( compgen -W '-20 -19 -18 -17 -16 -15 -14 -13 -12 \
+                -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 \
+                12 13 14 15 16 17 18 19' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    _expand || return 0
+
+    local IFS=$'\n'
+    _compopt_o_filenames
+    COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
+        $( compgen -d -- "$cur" ) )
+} &&
+complete -F _lrzip lrzip
+
+# 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
diff --git a/.bash/bash_completion.d/lsof b/.bash/bash_completion.d/lsof
new file mode 100644 (file)
index 0000000..ac010da
--- /dev/null
@@ -0,0 +1,64 @@
+# lsof(8) completion
+
+have lsof &&
+_lsof()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -'?'|-h|+c|-c|-d|-F|-i|+r|-r|-s|-S|-T)
+            return 0
+            ;;
+        -A|-k|-m|+m|-o)
+            _filedir
+            return 0
+            ;;
+        +d|+D)
+            _filedir -d
+            return 0
+            ;;
+        -D)
+            COMPREPLY=( $( compgen -W '? b i r u' -- "$cur" ) )
+            return 0
+            ;;
+        -f)
+            COMPREPLY=( $( compgen -W 'c f g G n' -- "$cur" ) )
+            return 0
+            ;;
+        -g)
+            # TODO: handle ^foo exclusions, comma separated lists
+            _pgids
+            return 0
+            ;;
+        -p)
+            # TODO: handle ^foo exclusions, comma separated lists
+            _pids
+            return 0
+            ;;
+        -u)
+            # TODO: handle ^foo exclusions, comma separated lists
+            COMPREPLY=( $( compgen -u -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == [-+]* ]]; then
+        COMPREPLY=( $( compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g
+            -i -k -l +L -L +m -m +M -M -n -N -o -O -p -P +r -r -R -s -S -T -t
+            -u -U -v -V +w -w -x -X -z -Z' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _lsof lsof
+
+# 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
diff --git a/.bash/bash_completion.d/lvm b/.bash/bash_completion.d/lvm
new file mode 100644 (file)
index 0000000..f4d3b77
--- /dev/null
@@ -0,0 +1,1094 @@
+# bash completion for lvm
+
+have lvm && {
+_volumegroups()
+{
+    COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \
+        sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) )
+}
+
+_physicalvolumes()
+{
+    COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
+        sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) )
+}
+
+_logicalvolumes()
+{
+    COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \
+        sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) )
+}
+
+_units()
+{
+    COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- "$cur" ) )
+}
+
+_sizes()
+{
+    COMPREPLY=( $( compgen -W 'k K m M g G t T' -- "$cur" ) )
+}
+
+_args()
+{
+    args=0
+    if [[ "${COMP_WORDS[0]}" == lvm ]]; then
+        offset=2
+    else
+        offset=1
+    fi
+    for (( i=$offset; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" != -* ]]; then
+            args=$(($args + 1))
+        fi
+    done
+}
+
+_lvmdiskscan()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --help \
+            --lvmpartition --verbose --version' -- "$cur" ) )
+    fi
+}
+complete -F _lvmdiskscan lvmdiskscan
+
+_pvscan()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    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
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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)
+            _units
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--aligned --all --debug \
+            --help --ignorelockingfailure --noheadings \
+            --nosuffix --options --sort --separator --unbuffered --units \
+            --verbose --version' -- "$cur" ) )
+    else
+        _physicalvolumes
+    fi
+}
+complete -F _pvs pvs
+
+_pvdisplay()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --units)
+            _units
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--colon --columns --units \
+            --verbose --debug --help --version' -- "$cur" ) )
+    else
+        _physicalvolumes
+    fi
+}
+complete -F _pvdisplay pvdisplay
+
+_pvchange()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|-x|--autobackup|--allocatable)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--all --autobackup \
+            --debug --help --test --uuid \
+            --allocatable --verbose --addtag --deltag \
+            --version' -- "$cur" ) )
+    else
+        _physicalvolumes
+    fi
+}
+complete -F _pvchange pvchange
+
+_pvcreate()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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)
+            _sizes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--restorefile --debug \
+            --force --help --labelsector --metadatatype \
+            --metadatacopies --metadatasize \
+            --setphysicalvolumesize --test --uuid \
+            --verbose --yes --version' -- "$cur" ) )
+    else
+        _physicalvolumes
+    fi
+}
+complete -F _pvcreate pvcreate
+
+_pvmove()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+        -n|--name)
+            _logicalvolumes
+            return 0
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--abort --autobackup \
+            --background --debug --force --help --interval --test --verbose \
+            --version --name' -- "$cur" ) )
+    else
+        _physicalvolumes
+    fi
+}
+complete -F _pvmove pvmove
+
+_pvremove()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --force \
+            --help --yes --test --verbose --version' -- "$cur" ) )
+    else
+        _physicalvolumes
+    fi
+}
+complete -F _pvremove pvremove
+
+_vgscan()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --help \
+            --ignorelockingfailure --mknodes \
+            --partial --verbose --version' -- "$cur" ) )
+    fi
+}
+complete -F _vgscan vgscan
+
+_vgs()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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)
+            _units
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--aligned --debug \
+            --help --ignorelockingfailure --noheadings \
+            --nosuffix --options --sort --partial \
+            --separator --unbuffered --units \
+            --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgs vgs
+
+_vgdisplay()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --units)
+            _units
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--colon --columns --units \
+            --partial --activevolumegroups --verbose \
+            --debug --help --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgdisplay vgdisplay
+
+_vgchange()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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
+        _volumegroups
+    fi
+}
+complete -F _vgchange vgchange
+
+_vgcreate()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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)
+            _sizes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --addtag --alloc \
+            --debug --help --maxlogicalvolumes --metadatatype \
+            --maxphysicalvolumes --physicalextentsize --test \
+            --verbose --version' -- "$cur" ) )
+    else
+        _args
+        if [ $args -eq 0 ]; then
+            _volumegroups
+        else
+            _physicalvolumes
+        fi
+    fi
+}
+complete -F _vgcreate vgcreate
+
+_vgremove()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --help --test \
+            --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgremove vgremove
+
+_vgrename()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --debug \
+            --help --test --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgrename vgrename
+
+_vgreduce()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--all --autobackup \
+            --debug --help --removemissing --test \
+            --verbose --version' -- "$cur" ) )
+
+    else
+        _args
+        if [ $args -eq 0 ]; then
+            _volumegroups
+        else
+            _physicalvolumes
+        fi
+    fi
+}
+complete -F _vgreduce vgreduce
+
+_vgextend()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+        -L|--size)
+            _sizes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --debug \
+            --help --test --verbose --version' -- "$cur" ) )
+    else
+        _args
+        if [ $args -eq 0 ]; then
+            _volumegroups
+        else
+            _physicalvolumes
+        fi
+    fi
+}
+complete -F _vgextend vgextend
+
+_vgport()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--all --debug \
+            --help --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgport vgimport vgexport
+
+_vgck()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug \
+            --help --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgck vgck
+
+_vgconvert()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -M|--metadatatype)
+            COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
+            return 0
+            ;;
+        --metadatacopies)
+            COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) )
+            return 0
+            ;;
+        --metadatasize)
+            _sizes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --help --labelsector \
+            --metadatatype --metadatacopies --metadatasize \
+            --test --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgconvert vgconvert
+
+_vgcfgbackup()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f|--file)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --file --help \
+            --ignorelockingfailure --partial --verbose \
+            --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgcfgbackup vgcfgbackup
+
+_vgcfgrestore()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f|--file)
+            _filedir
+            return 0
+            ;;
+        -M|--metadatatype)
+            COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
+            return 0
+            ;;
+        -n|--name)
+            _volumegroups
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --file --list \
+            --help --metadatatype --name --test \
+            --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgcfgrestore vgcfgrestore
+
+_vgmerge()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --debug --help \
+            --list --test --verbose --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgmerge vgmerge
+
+_vgsplit()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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
+        _args
+        if [[ $args -eq 0 || $args -eq 1 ]]; then
+            _volumegroups
+        else
+            _physicalvolumes
+        fi
+    fi
+}
+complete -F _vgsplit vgsplit
+
+_vgmknodes()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--debug --help --verbose \
+            --version' -- "$cur" ) )
+    else
+        _volumegroups
+    fi
+}
+complete -F _vgmknodes vgmknodes
+
+_lvscan()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--blockdevice --debug \
+            --help --ignorelockingfailure \
+            --partial --verbose --version' -- "$cur" ) )
+    fi
+}
+complete -F _lvscan lvscan
+
+_lvs()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    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)
+            _units
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--aligned --debug --help \
+            --ignorelockingfailure --noheadings --nosuffix --options \
+            --sort --partial --segments --separator --unbuffered --units \
+            --verbose --version' -- "$cur" ) )
+    else
+        _logicalvolumes
+    fi
+}
+complete -F _lvs lvs
+
+_lvdisplay()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --units)
+            _units
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--colon --columns --units \
+            --partial --maps --verbose --debug --help --version' -- "$cur" ) )
+    else
+        _logicalvolumes
+    fi
+}
+complete -F _lvdisplay lvdisplay
+
+_lvchange()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -a|-A|-C|-M|--available|--autobackup|--continguous|--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 '--autobackup --available \
+            --addtag --alloc --contiguous --debug --deltag \
+            --force --help --ignorelockingfailure \
+            --persistent --major --minor --partial \
+            --permission --readahead --refresh --test \
+            --verbose --version' -- "$cur" ) )
+    else
+        _logicalvolumes
+    fi
+}
+complete -F _lvchange lvchange
+
+_lvcreate()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|-C|-M|-Z|--autobackup|--continguous|--persistent|--zero)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+        -L|--size)
+            _sizes
+            return 0
+            ;;
+        -p|--permission)
+            COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) )
+            return 0
+            ;;
+        -n|--name)
+            _logicalvolumes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --addtag --alloc \
+            --contiguous --debug --help --stripes \
+            --stripesize --extents --size --persistent \
+            --major --minor --name --permission \
+            --readahead --test --type --verbose --zero \
+            --version' -- "$cur" ) )
+    else
+        _args
+        if [ $args -eq 0 ]; then
+            _volumegroups
+        else
+            _physicalvolumes
+        fi
+    fi
+}
+complete -F _lvcreate lvcreate
+
+_lvremove()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --debug \
+            --force --help --test --verbose --version' -- "$cur" ) )
+    else
+        _logicalvolumes
+    fi
+}
+complete -F _lvremove lvremove
+
+_lvrename()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --debug \
+            --help --test --verbose --version' -- "$cur" ) )
+    else
+        _logicalvolumes
+    fi
+}
+complete -F _lvrename lvrename
+
+_lvreduce()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+        -L|--size)
+            _sizes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup \
+            --debug --force --help --extents \
+            --size --nofsck --resizefs --test --verbose --version' -- "$cur" ) )
+    else
+        _logicalvolumes
+    fi
+}
+complete -F _lvreduce lvreduce
+
+_lvresize()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+        -L|--size)
+            _sizes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --alloc \
+            --debug --help --stripes --stripesize \
+            --extents --size --nofsck --resizefs \
+            --test --type --verbose --version' -- "$cur" ) )
+    else
+        _args
+        if [ $args -eq 0 ]; then
+            _logicalvolumes
+        else
+            _physicalvolumes
+        fi
+    fi
+}
+complete -F _lvresize lvresize
+
+_lvextend()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -A|--autobackup)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
+            return 0
+            ;;
+        -L|--size)
+            _sizes
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--autobackup --alloc \
+            --debug --help --stripes --stripesize \
+            --extents --size --nofsck --resizefs \
+            --test --type --verbose --version' -- "$cur" ) )
+    else
+        _args
+        if [ $args -eq 0 ]; then
+            _logicalvolumes
+        else
+            _physicalvolumes
+        fi
+    fi
+}
+complete -F _lvextend lvextend
+
+_lvm()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [ $COMP_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 ${COMP_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
+}
+
+# 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
diff --git a/.bash/bash_completion.d/lzma b/.bash/bash_completion.d/lzma
new file mode 100644 (file)
index 0000000..295ef37
--- /dev/null
@@ -0,0 +1,46 @@
+# lzma(1) completion by Per Øyvind Karlsen <peroyvind@mandriva.org>
+
+have lzma &&
+_lzma()
+{
+    local cur prev xspec
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 \
+            --help --decompress --compress --keep --force --suffix \
+            --test --stdout --quiet --verbose --license --list \
+            --version --small --fast --best --text' -- "$cur" ) )
+        return 0
+    fi
+
+    local IFS=$'\n'
+
+    xspec="*.@(lzma|tlz)"
+    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 _lzma lzma
+
+# 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
diff --git a/.bash/bash_completion.d/lzop b/.bash/bash_completion.d/lzop
new file mode 100644 (file)
index 0000000..6d38412
--- /dev/null
@@ -0,0 +1,69 @@
+# lzop(1) completion
+
+have lzop &&
+_lzop()
+{
+    local cur prev xspec
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P \
+            --fast --best --decompress --extract --test --list --ls --info \
+            --sysinfo --license --help --version --stdout --output --path \
+            --force --no-checksum --no-name --name --no-mode --no-time \
+            --suffix --keep --delete --crc32 --no-warn --ignore-warn --quiet \
+            --verbose --no-stdin --filter --checksum --no-color --mono \
+            --color' -- "$cur" ) )
+        return 0
+    fi
+
+    case $prev in
+        -o|--output)
+            _filedir
+            return 0
+            ;;
+        --path)
+            _filedir -d
+            return 0
+            ;;
+        -S|--suffix)
+            return 0
+            ;;
+    esac
+
+    xspec="*.?(t)lzo"
+    case $prev in
+        --decompress|--uncompress|--extract|--list|--ls|--info|--test)
+            xspec="!"$xspec
+            ;;
+        --force)
+            xspec=
+            ;;
+        --*)
+            ;;
+        -*f*|'<'|'>')
+            xspec=
+            ;;
+        -*[dltx]*)
+            xspec="!"$xspec
+            ;;
+    esac
+
+    _expand || return 0
+
+    local IFS=$'\n'
+    _compopt_o_filenames
+    COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
+            $( compgen -d -- "$cur" ) )
+} &&
+complete -F _lzop lzop
+
+# 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
diff --git a/.bash/bash_completion.d/mailman b/.bash/bash_completion.d/mailman
new file mode 100644 (file)
index 0000000..b239cbb
--- /dev/null
@@ -0,0 +1,587 @@
+# mailman completion
+
+have list_lists && {
+_mailman_lists()
+{
+    COMPREPLY=( $( compgen -W '$( list_lists -b )' -- "$cur" ) )
+}
+
+_list_lists()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--advertised --virtual-host-overview \
+            --bare --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _list_lists list_lists
+}
+
+have add_members &&
+_add_members()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -r|-d|--regular-members-file|--digest-members-file)
+            _filedir
+            return 0
+            ;;
+        -w|-a|--welcome-msg|--admin-notify)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur") )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--regular-members-file \
+            --digest-members-file --welcome-msg \
+            --admin-notify --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _add_members add_members
+
+have remove_members &&
+_remove_members()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -f|--file)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--file --all --fromall --nouserack \
+            --noadminack --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _remove_members remove_members
+
+have find_member &&
+_find_member()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -l|-x|--listname|--exclude)
+            _mailman_lists
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--listname --exclude --owners \
+            --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _find_member find_member
+
+have clone_member &&
+_clone_member()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -l|--listname)
+            _mailman_lists
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--listname --remove --admin \
+            --quiet --nomodify --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _clone_member clone_member
+
+have sync_members &&
+_sync_members()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -w|-g|-d|--welcome-msg|--goodbye-msg|--digest)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur") )
+            return 0
+            ;;
+        -d|--file)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--no-change --welcome-msg \
+            --goodbye-msg --digest --notifyadmin --file --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _sync_members sync_members
+
+have unshunt &&
+_unshunt()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help' -- "$cur" ) )
+    else
+        _filedir -d
+    fi
+
+} &&
+complete -F _unshunt unshunt
+
+have list_admins &&
+_list_admins()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--all-vhost --all --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _list_admins list_admins
+
+have list_owners &&
+_list_owners()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--with-listnames --moderators \
+            --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _list_owners list_owners
+
+have list_members &&
+_list_members()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -o|--output)
+            _filedir
+            return 0
+            ;;
+        -d|--digest)
+            COMPREPLY=( $( compgen -W 'mime plain' -- "$cur") )
+            return 0
+            ;;
+        -n|--nomail)
+            COMPREPLY=( $( compgen -W 'byadmin byuser bybounce unknown' \
+                -- "$cur") )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--output --regular --digest \
+            --nomail --fullnames --preserve --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _list_members list_members
+
+have change_pw &&
+_change_pw()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -l|--listname)
+            _mailman_lists
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--all --domain --listname \
+            --password --quiet --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _change_pw change_pw
+
+have withlist &&
+_withlist()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--lock --interactive \
+            --run --all --quiet --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _withlist withlist
+
+have newlist &&
+_newlist()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--language --quiet --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _newlist newlist
+
+have rmlist &&
+_rmlist()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--archives --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _rmlist rmlist
+
+have config_list &&
+_config_list()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -i|-o|--inputfile|--outputfile)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--inputfile --outputfile \
+            --checkonly --verbose --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _config_list config_list
+
+# Try to detect whether this is the mailman "arch" to avoid installing
+# it for the coreutils/util-linux-ng one.
+have arch && have mailmanctl &&
+_arch()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -w|-g|-d|--welcome-msg|--goodbye-msg|--digest)
+            COMPREPLY=( $( compgen -W 'y n' -- "$cur") )
+            return 0
+            ;;
+        -d|--file)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--wipe --start --end --quiet \
+            --help' -- "$cur" ) )
+    else
+        args=$COMP_CWORD
+        for (( i=1; i < COMP_CWORD; i++ )); do
+            if [[ "${COMP_WORDS[i]}" == -* ]]; then
+                args=$(($args-1))
+            fi
+        done
+        case $args in
+            1)
+                _mailman_lists
+                ;;
+            2)
+                _filedir
+                ;;
+        esac
+    fi
+
+} &&
+complete -F _arch arch
+
+have cleanarch &&
+_cleanarch()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--status --dry-run --quiet \
+            --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _cleanarch cleanarch
+
+have inject &&
+_inject()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -l|--listname)
+            _mailman_lists
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--listname --queue --help' -- "$cur" ) )
+    else
+        _filedir
+    fi
+
+} &&
+complete -F _inject inject
+
+have dumpdb &&
+_dumpdb()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--marshal --pickle --noprint \
+            --help' -- "$cur" ) )
+    else
+        _filedir
+    fi
+
+} &&
+complete -F _dumpdb dumpdb
+
+have check_db &&
+_check_db()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--all --verbose --help' -- "$cur" ) )
+    else
+        _mailman_lists
+    fi
+
+} &&
+complete -F _check_db check_db
+
+have check_perms &&
+_check_perms()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-f -v -h' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _check_perms check_perms
+
+have genaliases &&
+_genaliases()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--quiet --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _genaliases genaliases
+
+have mmsitepass &&
+_mmsitepass()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--listcreator --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _mmsitepass mmsitepass
+
+have qrunner &&
+_qrunner()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--runner --once \
+            --list --verbose --subproc --help' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _qrunner qrunner
+
+have mailmanctl &&
+_mailmanctl()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--no-restart --run-as-user \
+            --stale-lock-cleanup --quiet --help' -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -W 'start stop restart reopen' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _mailmanctl mailmanctl
+
+# 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
diff --git a/.bash/bash_completion.d/make b/.bash/bash_completion.d/make
new file mode 100644 (file)
index 0000000..76e9528
--- /dev/null
@@ -0,0 +1,78 @@
+# bash completion for GNU make
+
+have make || have gmake || have gnumake || have pmake &&
+_make()
+{
+    local file makef makef_dir="." makef_inc cur prev i split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -f|-o|-W|--file|--makefile|--old-file|--new-file|--assume-old|--assume-new|--what-if)
+            _filedir
+            return 0
+            ;;
+        -I|-C|--directory|--include-dir)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-b -m -B -C -d -e -f -h -i -I\
+            -j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
+            --always-make --directory --debug \
+            --environment-overrides --file --makefile --help \
+            --ignore-errors --include-dir --jobs --load-average \
+            --max-load --keep-going --just-print --dry-run \
+            --recon --old-file --assume-old --print-data-base \
+            --question --no-builtin-rules --no-builtin-variables \
+            --silent --quiet --no-keep-goind --stop --touch \
+            --version --print-directory --no-print-directory \
+            --what-if --new-file --assume-new \
+            --warn-undefined-variables' -- "$cur" ) )
+    else
+        # before we check for makefiles, see if a path was specified
+        # with -C/--directory
+        for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
+            if [[ ${COMP_WORDS[i]} == -@(C|-directory) ]]; then
+                # eval for tilde expansion
+                eval makef_dir=${COMP_WORDS[i+1]}
+                break
+            fi
+        done
+
+        # before we scan for targets, see if a Makefile name was
+        # specified with -f/--file/--makefile
+        for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
+            if [[ ${COMP_WORDS[i]} == -@(f|-?(make)file) ]]; then
+                # eval for tilde expansion
+                eval makef=${COMP_WORDS[i+1]}
+                break
+            fi
+        done
+
+        [ -n "$makef" ] && makef="-f ${makef}"
+        [ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}"
+
+        COMPREPLY=( $( compgen -W "$( make -qp $makef $makef_dir 2>/dev/null | \
+            awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
+            {split($1,A,/ /);for(i in A)print A[i]}' )" \
+            -- "$cur" ) )
+
+    fi
+} &&
+complete -F _make make gmake gnumake pmake
+
+# 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
diff --git a/.bash/bash_completion.d/man b/.bash/bash_completion.d/man
new file mode 100644 (file)
index 0000000..9e5cd3a
--- /dev/null
@@ -0,0 +1,80 @@
+# man(1) completion
+
+[ $USERLAND = GNU -o $UNAME = Darwin \
+  -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
+  -o $UNAME = OpenBSD ] &&
+_man()
+{
+    local cur i prev sect manpath manext mansect uname
+
+    manext="@([0-9lnp]|[0-9][px]|man|3pm)?(.@([gx]z|bz2|lzma|Z))"
+    mansect="@([0-9lnp]|[0-9][px]|3pm)"
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+
+    if [[ "$prev" == -l ]]; then
+        _filedir $manext
+        return 0
+    fi
+
+    _expand || return 0
+
+    # file based completion if parameter contains /
+    if [[ "$cur" == */* ]]; then
+        _filedir $manext
+        return 0
+    fi
+
+    uname=$( uname -s )
+    if [[ $uname == @(Linux|GNU|GNU/*|FreeBSD|Cygwin|CYGWIN_*) ]]; then
+        manpath=$( manpath 2>/dev/null || command man --path )
+    else
+        manpath=$MANPATH
+    fi
+
+    if [ -z "$manpath" ]; then
+        COMPREPLY=( $( compgen -c -- "$cur" ) )
+        return 0
+    fi
+
+    # determine manual section to search
+    [[ "$prev" == $mansect ]] && sect=$prev || sect='*'
+
+    manpath=$manpath:
+    if [ -n "$cur" ]; then
+        manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
+    else
+        manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
+    fi
+
+    # redirect stderr for when path doesn't exist
+    COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) )
+    # weed out directory path names and paths to man pages
+    COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
+    # strip suffix from man pages
+    COMPREPLY=( ${COMPREPLY[@]%.@([gx]z|bz2|lzma|Z)} )
+    COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
+
+    if [[ "$prev" != $mansect ]]; then
+        # File based completion for the rest, prepending ./ if needed
+        # (man 1.6f needs that for man pages in current dir)
+        local start=${#COMPREPLY[@]}
+        _filedir $manext
+        for (( i=$start; i < ${#COMPREPLY[@]}; i++ )); do
+            [[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}
+        done
+    fi
+
+    __ltrim_colon_completions "$cur"
+    return 0
+} &&
+complete -F _man man apropos whatis
+
+# 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
diff --git a/.bash/bash_completion.d/mc b/.bash/bash_completion.d/mc
new file mode 100644 (file)
index 0000000..09e9eab
--- /dev/null
@@ -0,0 +1,47 @@
+# bash completion for mc
+
+have mc &&
+_mc()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -e|--edit|-v|--view|-l|--ftplog|-P|--printwd)
+            _filedir
+            return 0
+            ;;
+        -C|--colors|-D|--debuglevel)
+            # argument required but no completions available
+            return 0
+            ;;
+        -h|--help|-V|--version)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--stickchars --nocolor --color --colors \
+            --nomouse --edit --datadir --resetsoft --ftplog --printwd --slow \
+            --termcap --nosubshell --subshell --view --version --xterm \
+            --debuglevel --help' -- "$cur" ) )
+    else
+        _filedir -d
+    fi
+} &&
+complete -F _mc mc
+
+# 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
diff --git a/.bash/bash_completion.d/mcrypt b/.bash/bash_completion.d/mcrypt
new file mode 100644 (file)
index 0000000..32c4f89
--- /dev/null
@@ -0,0 +1,84 @@
+# mcrypt(1) completion by Ariel Fermani <the_end@bbs.frc.utn.edu.ar>
+
+have mcrypt || have mdecrypt &&
+_mcrypt()
+{
+    local cur prev i decrypt
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -g|--openpgp-z)
+            COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" ) )
+            return 0
+            ;;
+        -o|--keymode)
+            COMPREPLY=( $( compgen -W '$( mcrypt --list-keymodes \
+                2>/dev/null )' -- "$cur" ) )
+            return 0
+            ;;
+        -m|--mode)
+            COMPREPLY=( $( compgen -W "$( mcrypt --list \
+                2>/dev/null | sed -e 's/.*: //' -e 's/ $//' | \
+                sort -u )" -- "$cur" ) )
+            return 0
+            ;;
+        -a|--algorithm)
+            COMPREPLY=( $( compgen -W "$( mcrypt --list 2>/dev/null | \
+                awk '{print $1}' )" -- "$cur" ) )
+            return 0
+            ;;
+        -h|--hash)
+            COMPREPLY=( $( compgen -W '$( mcrypt --list-hash 2>/dev/null | \
+                sed -e 1d )' -- "$cur" ) )
+            return 0
+            ;;
+        -k|-s|--key|--keysize)
+            return 0
+            ;;
+        -f|-c|--keyfile|--config)
+            _filedir
+            return 0
+            ;;
+        --algorithms-directory|--modes-directory)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--openpgp --openpgp-z \
+            --decrypt --keysize --keymode --keyfile \
+            --config --algorithm --algorithms-directory \
+            --mode --modes-directory --hash --key \
+            --noiv --bare --gzip --bzip2 --flush \
+            --doublecheck --unlink --nodelete --time \
+            --force --echo --random --list --list-keymodes \
+            --list-hash --verbose --quiet --help \
+            --version --license' -- "$cur" ) )
+    elif [[ ${COMP_WORDS[0]} == mdecrypt ]]; then
+        _filedir nc
+    else
+        decrypt=0
+        for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
+            if [[ ${COMP_WORDS[i]} == -@(d|-decrypt) ]]; then
+                _filedir nc
+                decrypt=1
+                break
+            fi
+        done
+        if [[ $decrypt -eq 0 ]]; then
+            _filedir
+        fi
+    fi
+} &&
+complete -F _mcrypt mcrypt mdecrypt
+
+# 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
diff --git a/.bash/bash_completion.d/mdadm b/.bash/bash_completion.d/mdadm
new file mode 100644 (file)
index 0000000..9cbaad7
--- /dev/null
@@ -0,0 +1,162 @@
+# bash completion for mdadm
+
+have mdadm &&
+{
+_mdadm_raid_level()
+{
+    local mode
+
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        case ${COMP_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 < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == -@(l|-level) ]]; then
+            level=${COMP_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 mode options split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    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
+
+    options='--help --help-options --version --verbose --quiet \
+        --brief --force --config --scan --metadata --homehost'
+
+    if [[ "$cur" == -* ]]; then
+        if [[ $COMP_CWORD -eq 1 ]] ; then
+            COMPREPLY=( $( compgen -W "$options --assemble --build \
+                --create --monitor --grow" -- "$cur" ) )
+        else
+            case ${COMP_WORDS[COMP_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
+    else
+        cur=${cur:=/dev/}
+        _filedir
+    fi
+}
+complete -F _mdadm mdadm
+}
+
+# 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
diff --git a/.bash/bash_completion.d/medusa b/.bash/bash_completion.d/medusa
new file mode 100644 (file)
index 0000000..d8dcfe4
--- /dev/null
@@ -0,0 +1,41 @@
+# bash completion for medusa
+
+have medusa &&
+_medusa()
+{
+    local cur prev
+
+    COMPREPLY=()
+    cur=`_get_cword`
+    prev=`_get_pword`
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H|-U|-P|-C|-O)
+            _filedir
+            return 0
+            ;;
+        -M)
+            COMPREPLY=( $( compgen -W "$(medusa -d | awk '/^ +\+/ {print $2}' \
+                | sed -e 's/\.mod$//')" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-h -H -u -U -p -P -C -O -e -M -m -d -n -s \
+            -g -r -R -t -T -L -f -F -b -q -v -w -V -Z' -- "$cur" ) )
+    fi
+} &&
+complete -F _medusa medusa
+
+# 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
diff --git a/.bash/bash_completion.d/minicom b/.bash/bash_completion.d/minicom
new file mode 100644 (file)
index 0000000..7655331
--- /dev/null
@@ -0,0 +1,53 @@
+# bash completion for minicom
+
+have minicom &&
+_minicom()
+{
+    local cur prev confdir
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -a|-c)
+            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+            return 0
+            ;;
+        -S|-C)
+            _filedir
+            return 0
+            ;;
+        -P)
+            COMPREPLY=( $( printf '%s\n' /dev/tty* ) )
+            COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \
+                -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t \
+            -c -S -d -p -C -T -7 -8' -- "$cur" ) )
+        return 0
+    else
+        [ -n "$( command ls /etc/minirc.* 2>/dev/null)" ] \
+            && confdir=/etc
+        [ -n "$( command ls /etc/minicom/minirc.* 2>/dev/null)" ] \
+            && confdir=/etc/minicom
+        if [ -n "$confdir" ]; then
+            COMPREPLY=( $( compgen -W '$( printf "%s\n" $confdir/minirc.* | \
+                sed -e "s|$confdir/minirc.||")' -- "$cur" ) )
+            return 0
+        fi
+    fi
+} &&
+complete -F _minicom -o default minicom
+
+# 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
diff --git a/.bash/bash_completion.d/mkinitrd b/.bash/bash_completion.d/mkinitrd
new file mode 100644 (file)
index 0000000..4889347
--- /dev/null
@@ -0,0 +1,59 @@
+# bash completion for mkinitrd
+
+have mkinitrd &&
+_mkinitrd()
+{
+    local cur prev args split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        --preload|--with|--builtin)
+            _modules
+            return 0
+            ;;
+        --fstab|--dsdt)
+            _filedir
+            return 0
+            ;;
+        --net-dev)
+            _available_interfaces
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--version --help -v -f --preload \
+            --force-scsi-probe --omit-scsi-modules \
+            --omit-ide-modules --image-version --force-raid-probe \
+            --omit-raid-modules --with --force-lvm-probe \
+            --omit-lvm-modules --builtin --omit-dmraid --net-dev \
+            --fstab --nocompress --dsdt --bootchart' -- "$cur" ) )
+    else
+        _count_args
+
+        case $args in
+            1)
+                _filedir
+                ;;
+            2)
+                _kernel_versions
+                ;;
+        esac
+    fi
+
+} &&
+complete -F _mkinitrd mkinitrd
+
+# 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
diff --git a/.bash/bash_completion.d/module-init-tools b/.bash/bash_completion.d/module-init-tools
new file mode 100644 (file)
index 0000000..bf2d24d
--- /dev/null
@@ -0,0 +1,61 @@
+# bash completion for Linux module-init-tools
+
+# Linux rmmod(8) completion. This completes on a list of all currently
+# installed kernel modules.
+#
+have rmmod &&
+_rmmod()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _installed_modules "$cur"
+    return 0
+} &&
+complete -F _rmmod rmmod
+
+# Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
+# list of all available modules for the version of the kernel currently
+# running.
+#
+have insmod || have modprobe || have modinfo &&
+_insmod()
+{
+    local cur prev modpath
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    # behave like lsmod for modprobe -r
+    if [[ ${1##*/} == modprobe && "${COMP_WORDS[1]}" == -r ]]; then
+        _installed_modules "$cur"
+        return 0
+    fi
+
+    # do filename completion if we're giving a path to a module
+    if [[ "$cur" == */* ]]; then
+        _filedir '@(?(k)o?(.gz))'
+        return 0
+    fi
+
+    if [[ $COMP_CWORD -gt 1 && "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
+        # do module parameter completion
+        COMPREPLY=( $( compgen -W "$( /sbin/modinfo -p ${COMP_WORDS[1]} | \
+            cut -d: -f1 )" -- "$cur" ) )
+    else
+        _modules $(uname -r)
+    fi
+
+    return 0
+} &&
+complete -F _insmod insmod modprobe modinfo
+
+# 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
diff --git a/.bash/bash_completion.d/monodevelop b/.bash/bash_completion.d/monodevelop
new file mode 100644 (file)
index 0000000..69b2344
--- /dev/null
@@ -0,0 +1,86 @@
+# Monodevelop completion
+
+have monodevelop &&
+_monodevelop()
+{
+    local cur
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-? -help -help2 -ipc-tcp -newwindow -nologo \
+            -usage -V -version' -- "$cur" ) )
+    else
+        _filedir
+    fi
+    return 0
+} &&
+complete -F _monodevelop monodevelop
+
+have mdtool &&
+_mdtool()
+{
+    local cur prev command i
+
+    COMPREPLY=()
+
+    _get_comp_words_by_ref cur prev
+
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        if [[ ${COMP_WORDS[i]} == @(build|generate-makefiles|setup) ]]; then
+            command=${COMP_WORDS[i]}
+        fi
+    done
+
+    if [[ -n "$command" ]]; then
+        case $command in
+            "build")
+                COMPREPLY=( $( compgen -W '--f --buildfile --p --project' \
+                    -S":" -- "$cur" ) )
+                # TODO: This does not work :(
+                #if [[ "$prev" == *: ]]; then
+                #   case $prev in
+                #       @(--p:|--project:))
+                #           COMPREPLY=( $( compgen -f -G "*.mdp" -- "$cur" ) )
+                #           ;;
+                #       @(--f:|--buildfile:))
+                #           COMPREPLY=( $( compgen -f -G "*.mdp" -G "*.mds" -- "$cur" ) )
+                #           ;;
+                #   esac
+                #fi
+                return 0
+                ;;
+            "generate-makefiles")
+                _compopt_o_filenames
+                COMPREPLY=( $( compgen -o filenames -G"*.mds" -- "$cur" ) )
+                if [[ "$prev" == *mds ]]; then
+                    COMPREPLY=( $( compgen -W '--simple-makefiles --s --d:' \
+                        -- "$cur" ) )
+                fi
+                return 0
+                ;;
+            "setup")
+                # TODO: at least return filenames after these options.
+                COMPREPLY=( $( compgen -W 'install i uninstall u check-install \
+                    ci update up list l list-av la list-update lu rep-add ra \
+                    rep-remove rr rep-update ru rep-list rl reg-update \
+                    reg-build rgu info rep-build rb pack p help h dump-file' \
+                    -- "$cur" ) )
+                return 0
+                ;;
+        esac
+    fi
+
+    COMPREPLY=( $( compgen -W 'gsetup build dbgen project-export \
+        generate-makefiles gettext-update setup -q' -- "$cur" ) )
+
+    return 0
+} &&
+complete -F _mdtool mdtool
+
+# 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
diff --git a/.bash/bash_completion.d/mount b/.bash/bash_completion.d/mount
new file mode 100644 (file)
index 0000000..b14eef3
--- /dev/null
@@ -0,0 +1,165 @@
+# mount(8) completion. 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.
+#
+have mount &&
+{
+
+# 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
+
+    _reply_compgen_array
+}
+
+_mount()
+{
+    local cur sm host prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+
+    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 Linux
+        if [ "$prev" = -L ]; then
+            _linux_fstab -L < /etc/fstab
+        elif [ "$prev" = -U ]; then
+            COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- "$cur" ) )
+        else
+            _linux_fstab < /etc/fstab
+        fi
+    fi
+
+    return 0
+} &&
+complete -F _mount -o default -o dirnames mount
+
+# umount(8) completion. This relies on the mount point being the third
+# space-delimited field in the output of mount(8)
+#
+have umount &&
+_umount()
+{
+    local cur
+    _get_comp_words_by_ref cur
+    COMPREPLY=()
+
+    if [[ $(uname -s) = Linux && -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
+
+    return 0
+} &&
+complete -F _umount -o dirnames umount
+
+}
+
+# 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
diff --git a/.bash/bash_completion.d/mplayer b/.bash/bash_completion.d/mplayer
new file mode 100644 (file)
index 0000000..3971137
--- /dev/null
@@ -0,0 +1,269 @@
+# mplayer(1) completion
+
+have mplayer && {
+_mplayer_options_list()
+{
+    cur=${cur%\\}
+    COMPREPLY=( $( compgen -W "$( $1 -nomsgcolor -nomsgmodule $2 help 2>/dev/null | \
+        sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' | \
+        sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' )" -- "$cur" ) )
+}
+
+_mplayer()
+{
+    local cmd cur prev i j k=0
+
+    COMPREPLY=()
+    cmd=${COMP_WORDS[0]}
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -[av][cfo]|-[av]fm|-vop|-fstype|-demuxer|-o[av]c|-of|-profile| \
+        -audio-demuxer|-sub-demuxer)
+            _mplayer_options_list $cmd $prev
+            return 0
+            ;;
+        -show-profile)
+            _mplayer_options_list $cmd -profile
+            return 0
+            ;;
+        -audiofile)
+            _filedir '@(mp3|mpg|ogg|w?(a)v|mid|flac|mka|ape)'
+            return 0
+            ;;
+        -font|-subfont)
+            if [ "$prev" = -font ]; then
+                _filedir '@(desc|ttf)'
+            else
+                _filedir ttf
+            fi
+            local IFS=$'\n'
+            COMPREPLY=( "${COMPREPLY[@]}"
+                $( compgen -W '$( fc-list 2>/dev/null )' -- "$cur" ) )
+            return 0
+            ;;
+        -sub)
+            _filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'
+            return 0
+            ;;
+        -vobsub)
+            _filedir '@(idx|ifo|sub)'
+            local IFS=$'\n'
+            COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
+                        if [[ -f $i && -r $i ]]; then
+                            printf '%s\n' ${i%.*}
+                        else
+                            printf '%s\n' $i
+                        fi
+                       done ) )
+            return 0
+            ;;
+        -ifo)
+            _filedir ifo
+            return 0
+            ;;
+        -cuefile)
+            _filedir '@(bin|cue)'
+            return 0
+            ;;
+        -skin)
+            # if you don't have installed mplayer in /usr you
+            # may want to set the MPLAYER_SKINS_DIR global variable
+            local -a dirs
+            if [ -n "$MPLAYER_SKINS_DIR" ]; then
+                dirs=($MPLAYER_SKINS_DIR)
+            else
+                dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins)
+            fi
+
+            local IFS=$'\n'
+            for i in ~/.mplayer/skins ${dirs[@]}; do
+                if [[ -d $i && -r $i ]]; then
+                    for j in $( compgen -d $i/$cur ); do
+                        COMPREPLY[$k]=${j#$i/}
+                        k=$((++k))
+                    done
+                fi
+            done
+            return 0
+            ;;
+        -cdrom-device)
+            _cd_devices
+            _dvd_devices
+            return 0
+            ;;
+        -dvd-device)
+            _filedir
+            return 0
+            ;;
+        -mixer|-dvdauth|-fb|-zrdev)
+            cur=${cur:=/dev/}
+            _filedir
+            return 0
+            ;;
+        -edl|-edlout|-lircconf|-menu-cfg|-playlist|-csslib|-dumpfile| \
+        -subfile|-vobsub|-aofile|-fbmodeconfig|-include|-o|-dvdkey| \
+        -passlogfile)
+            _filedir
+            return 0
+            ;;
+        -autoq|-autosync|-loop|-menu-root|-speed|-sstep|-aid|-alang| \
+        -bandwidth|-cache|-chapter| \
+        -dvd|-dvdangle|-fps|-frames|-mc|-passwd|-user|-sb|-srate|-ss|-vcd| \
+        -vi|-vid|-vivo|-ffactor|-sid|-slang|-spualign|-spuaa|-spugauss| \
+        -vobsubid|-delay|-bpp|-brightness|-contrast|-dfbopts|-display| \
+        -fbmode|-geometry|-guiwid|-hue|-icelayer|-screen[wh]|-wid| \
+        -monitoraspect|-monitor-dotclock|-monitor-[hv]freq|-panscan| \
+        -saturation|-xineramascreen|-zrcrop|-zrnorm|-zrquality| \
+        -zr[xy]doff|-zr[vh]dec|-aspect|-pp|-x|-y|-xy|-z|-stereo| \
+        -audio-density|-audio-delay|-audio-preload|-endpos|-osdlevel| \
+        -ffourcc|-sws|-channels|-skiplimit|-format|-ofps|-aadriver| \
+        -aaosdcolor|-aasubcolor|-vobsubout|-vobsuboutid|-vobsuboutindex| \
+        -sub-bg-alpha|-sub-bg-color|-sub-cp|-sub-delay|-sub-fps|-sub-pos| \
+        -sub-align|-sub-width|-subfont-blur|-subfont-outline| \
+        -subfont-autoscale|-subfont-encoding|-subfont-osd-scale| \
+        -subfont-osd-text)
+            return 0
+            ;;
+        -lavdopts)
+            COMPREPLY=( $( compgen -W 'bitexact bug= debug= ec= er= fast gray idct= lowres= sb= st= skiploopfilter= skipidct= skipframe= threads= vismv= vstats' -- "$cur" ) )
+            return 0
+            ;;
+        -lavcopts)
+            COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= \
+                mbqmax= vqdiff= vmax_b_frames= vme= vhq v4mv keyint= \
+                vb_strategy= vpass= aspect= vbitrate= vratetol= vrc_maxrate= \
+                vrc_minrate= vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset= \
+                vi_qoffset= vqblur= vqcomp= vrc_eq= vrc_override= \
+                vrc_init_cplx= vqsquish= vlelim= vcelim= vstrict= vdpart \
+                vpsize= gray vfdct= idct= lumi_mask= dark_mask= tcplx_mask= \
+                scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp= \
+                predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic \
+                umv' -- "$cur" ) )
+            return 0
+            ;;
+        -ssf)
+            COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= cvs=' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -jpeg)
+            COMPREPLY=( $( compgen -W 'noprogressive progressive nobaseline \
+                baseline optimize= smooth= quality= outdir=' -- "$cur" ) )
+            return 0
+            ;;
+        -xvidopts)
+            COMPREPLY=( $( compgen -W 'dr2 nodr2' -- "$cur" ) )
+            return 0
+            ;;
+        -xvidencopts)
+            COMPREPLY=( $( compgen -W 'pass= bitrate= fixed_quant= me_quality= \
+                4mv rc_reaction_delay_factor= rc_averaging_period= rc_buffer= \
+                quant_range= min_key_interval= max_key_interval= mpeg_quant \
+                mod_quant lumi_mask hintedme hintfile debug keyframe_boost= \
+                kfthreshold= kfreduction=' -- "$cur" ) )
+            return 0
+            ;;
+        -divx4opts)
+            COMPREPLY=( $( compgen -W 'br= key= deinterlace q= min_quant= \
+                max_quant= rc_period= rc_reaction_period= crispness= \
+                rc_reaction_ratio= pass= vbrpass= help' -- "$cur" ) )
+            return 0
+            ;;
+        -info)
+            COMPREPLY=( $( compgen -W 'name= artist= genre= subject= \
+                copyright= srcform= comment= help' -- "$cur" ) )
+            return 0
+            ;;
+        -lameopts)
+            COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= ratio= vol= \
+                mode= padding= fast preset= help' -- "$cur" ) )
+            return 0
+            ;;
+        -rawaudio)
+            COMPREPLY=( $( compgen -W 'on channels= rate= samplesize= format=' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -rawvideo)
+            COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w= \
+                h= y420 yv12 yuy2 y8 format= size=' -- "$cur" ) )
+            return 0
+            ;;
+        -aop)
+            COMPREPLY=( $( compgen -W 'list= delay= format= fout= volume= mul= \
+                softclip' -- "$cur" ) )
+            return 0
+            ;;
+        -dxr2)
+            COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded iec958-decoded \
+                mute ucode= 75ire bw color interlaced macrovision= norm= \
+                square-pixel ccir601-pixel cr-left= cr-right= cr-top= cr-bot= \
+                ck-rmin= ck-gmin= ck-bmin= ck-rmax= ck-gmax= ck-bmax= ck-r= \
+                ck-g= ck-b= ignore-cache= ol-osd= olh-cor= olw-cor= olx-cor= \
+                oly-cor= overlay overlay-ratio= update-cache' -- "$cur" ))
+            return 0
+            ;;
+        -tv)
+            COMPREPLY=( $( compgen -W 'on noaudio driver= device= input= freq= \
+                outfmt= width= height= buffersize= norm= channel= chanlist= \
+                audiorate= forceaudio alsa amode= forcechan= adevice= audioid= \
+                volume= bass= treble= balance= fps= channels= immediatemode=' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -mf)
+            COMPREPLY=( $( compgen -W 'on w= h= fps= type=' -- "$cur" ) )
+            return 0
+            ;;
+        -cdda)
+            COMPREPLY=( $( compgen -W 'speed= paranoia= generic-dev= \
+                sector-size= overlap= toc-bias toc-offset= skip noskip' \ 
+                -- "$cur" ) )
+            return 0
+            ;;
+        -input)
+            COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate keylist cmdlist \
+                js-dev file' -- "$cur" ) )
+            return 0
+            ;;
+        -af)
+            COMPREPLY=( $( compgen -W 'resample resample= channels channels= \
+                format format= volume volume= delay delay= pan pan= sub sub= \
+                surround surround=' -- "$cur" ) )
+            return 0
+            ;;
+        -af-adv)
+            COMPREPLY=( $( compgen -W 'force= list=' -- "$cur" ) )
+            return 0
+            ;;
+        -noconfig)
+            COMPREPLY=( $( compgen -W 'all gui system user' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    case $cur in
+        -*)
+            COMPREPLY=( $( compgen -W '$( $cmd -nomsgcolor -nomsgmodule -list-options 2>/dev/null | \
+                sed -ne '1,/^[[:space:]]*Name/d' \
+                    -e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \
+                    -e "/^-\(Total\|.*\*\)\{0,1\}$/!p" )' -- "$cur" ) )
+            ;;
+        *)
+            _filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m4[av]|M4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m[24]v|M[24]V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|webm|WEBM|amr|AMR|awb|AWB|iso|ISO)?(.part)'
+            ;;
+    esac
+
+    return 0
+}
+complete -F _mplayer mplayer mencoder gmplayer kplayer
+}
+
+# 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
diff --git a/.bash/bash_completion.d/msynctool b/.bash/bash_completion.d/msynctool
new file mode 100644 (file)
index 0000000..3f9afb7
--- /dev/null
@@ -0,0 +1,51 @@
+# bash completion for msynctool
+
+have msynctool &&
+_msynctool()
+{
+    local cur prev anteprev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev anteprev
+
+    case $anteprev in
+        --configure)
+            COMPREPLY=( $( compgen -W "$(msynctool --showgroup \
+                $prev | awk '/^Member/ {print $2}' | sed \
+                -e 's/:$//' )" -- "$cur" ) )
+            return 0
+            ;;
+        --addmember)
+            COMPREPLY=( $( compgen -W '$(msynctool --listplugins \
+                | sed -e '1d' )' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    case $prev in
+        --configure|--addgroup|--delgroup|--showgroup|--sync|--addmember)
+            COMPREPLY=( $( compgen -W '$(msynctool --listgroups \
+                | sed -e '1d' )' -- "$cur" ) )
+            return 0
+            ;;
+        --showformats|--filter-objtype|--slow-sync)
+            COMPREPLY=( $( compgen -W '$(msynctool --listobjects \
+                | sed -e '1d' )' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    COMPREPLY=( $( compgen -W '--listgroups --listplugins --listobjects \
+        --showformats --showgroup --sync --filter-objtype --slow-sync \
+        --wait --multi --addgroup --delgroup --addmember --configure \
+        --manual --configdir --conflict' -- "$cur" ) )
+} &&
+complete -F _msynctool msynctool
+
+# 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
diff --git a/.bash/bash_completion.d/mtx b/.bash/bash_completion.d/mtx
new file mode 100644 (file)
index 0000000..0454f03
--- /dev/null
@@ -0,0 +1,51 @@
+# mtx completion by Jon Middleton <jjm@ixtab.org.uk>
+
+have mtx &&
+_mtx()
+{
+    local cur prev options tapes drives
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    options="-f nobarcode invert noattach --version inquiry noattach \
+        inventory status load unload eepos first last next"
+
+    tapes=$(mtx status | \
+        awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
+    tapes=${tapes//:Full}
+
+    drives=$(mtx status | \
+        awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
+    drives=${drives//:Full}
+    drives=${drives//:Empty}
+
+    if [ $COMP_CWORD -gt 1 ]; then
+        case $prev in
+            load)
+                COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) )
+                ;;
+            unload|first|last|next)
+                COMPREPLY=( $( compgen -W "$drives" -- "$cur" ) )
+                ;;
+            -f)
+                true
+                ;;
+            *)
+                true
+                ;;
+        esac
+    else
+        COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+    fi
+    return 0
+} &&
+complete -F _mtx mtx
+
+# 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
diff --git a/.bash/bash_completion.d/munin-node b/.bash/bash_completion.d/munin-node
new file mode 100644 (file)
index 0000000..abf2b0f
--- /dev/null
@@ -0,0 +1,113 @@
+# bash completion for munin node
+
+have munin-run &&
+_munin_run()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --config|--sconffile)
+            _filedir
+            return 0
+            ;;
+        --servicedir|--sconfdir)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--config --servicedir --sconfdir \
+            --sconffile --help --debug --version' -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -W '$( command ls /etc/munin/plugins )' \
+            -- "$cur" ) )
+    fi
+} &&
+complete -F _munin_run munin-run
+
+have munindoc &&
+_munindoc()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    COMPREPLY=( $( compgen -W '$( command ls /usr/share/munin/plugins )' \
+        -- "$cur" ) )
+} &&
+complete -F _munindoc munindoc
+
+have munin-update &&
+_munin_update()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --config)
+            _filedir
+            return 0
+            ;;
+        --host)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--force-root --[no]force-root \
+            --service --host --config --help --debug --nodebug \
+            --fork --nofork --stdout --nostdout --timeout' -- "$cur" ) )
+    fi
+} &&
+complete -F _munin_update munin-update
+
+have munin-node-configure &&
+_munin_node_configure()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --config)
+            _filedir
+            return 0
+            ;;
+        --servicedir|--libdir)
+            _filedir -d
+            return 0
+            ;;
+        --snmp)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        --snmpversion)
+            COMPREPLY=( $( compgen -W '1 2c 3' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --version --debug --config \
+            --servicedir --libdir --families --suggest --shell \
+            --remove-also --snmp --snmpversion --snmpcommunity' -- "$cur" ) )
+    fi
+} &&
+complete -F _munin_node_configure munin-node-configure
+
+# 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
diff --git a/.bash/bash_completion.d/mutt b/.bash/bash_completion.d/mutt
new file mode 100644 (file)
index 0000000..e5e9d28
--- /dev/null
@@ -0,0 +1,186 @@
+# mutt completion
+#
+# Mutt doesn't have an "addressbook" like Pine, but it has aliases and
+# a "query" function to retrieve addresses, so that's what we use here.
+
+have mutt || have muttng && {
+
+# @param $1 (cur) Current word to complete
+_muttaddr()
+{
+    _muttaliases "$1"
+    _muttquery "$1"
+
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -u -- "$1" ) )
+
+    return 0
+} # _muttaddr()
+
+
+# Find muttrc to use
+# @output  muttrc filename
+_muttrc()
+{
+    # Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument
+    set -- "${COMP_WORDS[@]}"
+    while [ $# -gt 0 ]; do
+        if [ "${1:0:2}" = -F ]; then
+            if [ ${#1} -gt 2 ]; then
+                muttrc="$(dequote "${1:2}")"
+            else
+                shift
+                [ "$1" ] && muttrc="$(dequote "$1")"
+            fi
+            break
+        fi
+        shift
+    done
+
+    if [ -z "$muttrc" ]; then
+        if [ -f ~/.${muttcmd}rc ]; then
+            muttrc="~/.${muttcmd}rc"
+        elif [ -f ~/.${muttcmd}/${muttcmd}rc ]; then
+            muttrc="~/.${muttcmd}/${muttcmd}rc"
+        fi
+    fi
+    printf "%s" "$muttrc"
+} # _muttrc()
+
+
+# Recursively build list of sourced config files
+# @param $1  List of config files found so far
+# @param $2  Config file to process
+# @output  List of config files
+_muttconffiles()
+{
+    local file sofar
+    local -a newconffiles
+
+    sofar=" $1 "
+    shift
+    while [[ "$1" ]]; do
+        newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ) )
+        for file in "${newconffiles[@]}"; do
+            [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] &&
+                continue
+            sofar="$sofar $file"
+            sofar=" $(eval _muttconffiles \"$sofar\" $file) "
+        done
+        shift
+    done
+    printf '%s\n' $sofar
+} # _muttconffiles()
+
+
+# @param $1 (cur) Current word to complete
+_muttaliases()
+{
+    local cur=$1 muttrc muttcmd=${COMP_WORDS[0]}
+    local -a conffiles aliases
+
+    muttrc=$(_muttrc)
+    [ -z "$muttrc" ] && return 0
+
+    conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
+    aliases=( $( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \
+        $(eval echo "${conffiles[@]}") ) )
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- "$cur" ) )
+
+    return 0
+}
+
+
+# @param $1 (cur) Current word to complete
+_muttquery()
+{
+    local cur=$1 querycmd muttcmd=${COMP_WORDS[0]}
+    local -a queryresults
+
+    querycmd="$( $muttcmd -Q query_command | sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|' )"
+    if [[ -z "$cur" || -z "$querycmd" ]]; then
+        queryresults=()
+    else
+        queryresults=( $( $querycmd | \
+            sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p' ) )
+    fi
+
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \
+        -- "$cur" ) )
+
+    return 0
+}
+
+
+# @param $1 (cur) Current word to complete
+_muttfiledir()
+{
+    local cur=$1 folder muttrc spoolfile muttcmd=${COMP_WORDS[0]}
+
+    muttrc=$(_muttrc)
+    if [[ $cur == [=+]* ]]; then
+        folder="$( $muttcmd -F "$muttrc" -Q folder | sed -e 's|^folder=\"\(.*\)\"$|\1|' )"
+        : folder:=~/Mail
+
+        # Match any file in $folder beginning with $cur
+        # (minus the leading '=' sign).
+        _compopt_o_filenames
+        COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) )
+        COMPREPLY=( ${COMPREPLY[@]#$folder/} )
+        return 0
+    elif [ "$cur" == !* ]; then
+        spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile | \
+            sed -e 's|^spoolfile=\"\(.*\)\"$|\1|' )"
+        [ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}";
+    fi
+    _filedir
+
+    return 0
+} # _muttfiledir
+
+
+_mutt()
+{
+    local cur prev
+    _get_comp_words_by_ref -n =+! cur prev
+    #cur=`_get_cword =+!`
+    #prev=`_get_pword =+!`
+
+    COMPREPLY=()
+
+    case $cur in
+    -*)
+        COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \
+            -p -Q -R -s -v -x -y -z -Z -h' -- "$cur" ) )
+        return 0
+        ;;
+    *)
+        case $prev in
+        -a|-f|-F|-H|-i)
+            _muttfiledir "$cur"
+            return 0
+            ;;
+        -A)
+            _muttaliases "$cur"
+            return 0
+            ;;
+        -e|-m|-Q|-s|-h|-p|-R|-v|-y|-z|-Z)
+            return 0
+            ;;
+        *)
+            _muttaddr "$cur"
+            return 0
+            ;;
+        esac
+        ;;
+    esac
+} # _mutt()
+complete -F _mutt -o default mutt muttng
+} # have mutt
+
+# 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
diff --git a/.bash/bash_completion.d/mysqladmin b/.bash/bash_completion.d/mysqladmin
new file mode 100644 (file)
index 0000000..c941569
--- /dev/null
@@ -0,0 +1,71 @@
+# bash completion for mysqladmin
+
+have mysqladmin &&
+_mysqladmin()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -u|--user)
+            COMPREPLY=( $( compgen -u -- "$cur" ) )
+            return 0
+            ;;
+        -h|--host)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        --character-sets-dir|--ssl-capath)
+            _filedir -d
+            return 0
+            ;;
+        -S|--socket)
+            _filedir sock
+            return 0
+            ;;
+        --defaults-file|--defaults-extra-file)
+            _filedir
+            return 0
+            ;;
+        -c|--count|--default-character-set|-P|--port|-O|--set-variable|\
+        -i|--sleep|--ssl-ca|--ssl-cert|--ssl-cipher|--ssl-key|-w|--wait|\
+        --connect_timeout|--shutdown_timeout)
+            # Argument required but no completions available
+            return 0
+            ;;
+        '-?'|--help|-V|--version)
+            # All other options are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    COMPREPLY=( $( compgen -W '--count --debug-check --debug-info --force \
+        --compress --character-sets-dir --default-character-set --help --host \
+        --no-beep --password --port --protocol --relative --set-variable \
+        --silent --socket --sleep --ssl --ssl-ca --ssl-capath --ssl-cert \
+        --ssl-cipher --ssl-key --ssl-verify-server-cert --user --verbose \
+        --version --vertical --wait --connect_timeout --shutdown_timeout \
+        --print-defaults --no-defaults --defaults-file --defaults-extra-file' \
+        -- "$cur" ) )
+
+    COMPREPLY=( "${COMPREPLY[@]}" \
+        $( compgen -W 'create debug drop extended-status flush-hosts \
+        flush-logs flush-status flush-tables flush-threads flush-privileges \
+        kill password old-password ping processlist reload refresh shutdown \
+        status start-slave stop-slave variables version' -- "$cur" ) )
+} &&
+complete -F _mysqladmin mysqladmin
+
+# 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
diff --git a/.bash/bash_completion.d/ncftp b/.bash/bash_completion.d/ncftp
new file mode 100644 (file)
index 0000000..b831f44
--- /dev/null
@@ -0,0 +1,26 @@
+# bash completion for ncftp
+
+have ncftp &&
+_ncftp()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ $COMP_CWORD -eq 1 && -f ~/.ncftp/bookmarks ]]; then
+        COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
+            ~/.ncftp/bookmarks )' -- "$cur" ) )
+    fi
+
+    return 0
+} &&
+complete -F _ncftp -o default ncftp
+
+# 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
diff --git a/.bash/bash_completion.d/net-tools b/.bash/bash_completion.d/net-tools
new file mode 100644 (file)
index 0000000..e7de2b0
--- /dev/null
@@ -0,0 +1,131 @@
+# bash completion for net tools
+
+have mii-tool &&
+_mii_tool()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--force)
+            COMPREPLY=( $( compgen -W '100baseTx-FD 100baseTx-HD \
+                10baseT-FD 10baseT-HD' -- "$cur" ) )
+            return 0
+            ;;
+        -A|--advertise)
+            COMPREPLY=( $( compgen -W '100baseT4 100baseTx-FD 100baseTx-HD \
+                10baseT-FD 10baseT-HD' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--verbose --version --reset --restart \
+            --watch --log --advertise --force' -- "$cur" ) )
+    else
+        _available_interfaces -a
+    fi
+} &&
+complete -F _mii_tool -o default mii-tool
+
+have mii-diag &&
+_mii_diag()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|-A|--advertise|--fixed-speed)
+            COMPREPLY=( $( compgen -W '100baseT4 100baseTx \
+                100baseTx-FD 100baseTx-HD 10baseT 10baseT-FD \
+                10baseT-HD' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--advertise --fixed-speed --all-interfaces \
+            --status --debug --read-parameters --set-parameters --msg-level \
+            --phy --restart --reset --verbose --version --watch --help' \
+            -- "$cur" ) )
+    else
+        _available_interfaces -a
+    fi
+} &&
+complete -F _mii_diag -o default mii-diag
+
+# Linux route(8) completion
+#
+[ $UNAME = Linux ] && have route &&
+_route()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [ "$prev" = dev ]; then
+        _available_interfaces
+        return 0
+    fi
+
+    # Remove already given options from completions
+    local i found
+    for opt in add del -host -net netmask metric mss window irtt reject mod \
+        dyn reinstate dev default gw; do
+        found=false
+        for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
+            [ "${COMP_WORDS[i]}" = "$opt" ] && found=true && break
+        done
+        $found || COMPREPLY[${#COMPREPLY[@]}]="$opt"
+    done
+
+    COMPREPLY=( $( compgen -W '"${COMPREPLY[@]}"' -- "$cur" ) )
+} &&
+complete -F _route route
+
+have ether-wake &&
+_ether_wake()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref -n : cur prev
+
+    case $prev in
+        -i)
+            _available_interfaces
+            return 0
+            ;;
+        -p)
+            return 0
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '-b -D -i -p -V' -- "$cur" ) )
+        return 0
+    fi
+
+    _mac_addresses
+} &&
+complete -F _ether_wake ether-wake
+
+# 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
diff --git a/.bash/bash_completion.d/nmap b/.bash/bash_completion.d/nmap
new file mode 100644 (file)
index 0000000..19f0a07
--- /dev/null
@@ -0,0 +1,60 @@
+# bash completion for nmap
+
+have nmap &&
+_nmap()
+{
+    local cur prev
+
+    COMPREPLY=()
+    cur=`_get_cword`
+    prev=`_get_pword`
+
+    case $prev in
+        -iL|-oN|-oX|-oS|-oG|---excludefile|--resume|--stylesheet)
+            _filedir
+            return 0
+            ;;
+        -oA|--datadir)
+            _filedir -d
+            return 0
+            ;;
+        -e)
+            _available_interfaces
+            return 0
+            ;;
+        -b|--dns-servers)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-iL -iR --exclude --excludefile -sL -sP \
+            -PN -PS -PA -PU -PY -PE -PP -PM -PO -n -R --dns-servers \
+            --system-dns --traceroute -sS -sT -sA -sW -sM -sU -sN -sF -sX \
+            --scanflags -sI -sY -sZ -sO -b -p -F -r --top-ports --port-ratio \
+            -sV --version-intensity --version-light --version-all \
+            --version-trace -sC --script= --script-args= --script-trace \
+            --script-updatedb -O --osscan-limit --osscan-guess -T0 -T1 -T2 -T3 \
+            -T4 -T5 --min-hostgroup --max-hostgroup --min-parallelism \
+            --max-parallelism --min-rtt-timeout --max-rtt-timeout \
+            --initial-rtt-timeout --max-retries --host-timeout --scan-delay \
+            --max-scan-delay --min-rate --max-rate -f --mtu -D -S -e \
+            --source-port --data-length --ip-options --ttl --spoof-mac \
+            --badsum --adler32 -oN -oX -oS -oG -oA -v -d --reason --open \
+            --packet-trace --iflist --log-errors --append-output --resume \
+            --stylesheet --webxml --no-stylesheet -6 -A --datadir --send-eth \
+            --send-ip --privilege--unprivileged -V -h' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+} &&
+complete -F _nmap nmap
+
+# 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
diff --git a/.bash/bash_completion.d/ntpdate b/.bash/bash_completion.d/ntpdate
new file mode 100644 (file)
index 0000000..bf004b5
--- /dev/null
@@ -0,0 +1,37 @@
+# bash completion for ntpdate
+
+have ntpdate &&
+_ntpdate()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -k)
+            _filedir
+            return 0
+            ;;
+        -U)
+            COMPREPLY=( $( compgen -u "$cur"  ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
+            -e -k -p -o -r -t' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+} &&
+complete -F _ntpdate ntpdate
+
+# 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
diff --git a/.bash/bash_completion.d/open-iscsi b/.bash/bash_completion.d/open-iscsi
new file mode 100644 (file)
index 0000000..8c650d5
--- /dev/null
@@ -0,0 +1,78 @@
+# iscsiadm(1) completion
+
+have iscsiadm &&
+_iscsiadm()
+{
+    local cur prev mode split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -m|--mode)
+            COMPREPLY=( $( compgen -W 'discovery node session iface fw host' \
+                -- "$cur" ) )
+            return 0;
+            ;;
+        -o|--op)
+            COMPREPLY=( $( compgen -W 'new delete update show' -- "$cur" ) )
+            return 0;
+            ;;
+        -t|--type)
+            COMPREPLY=( $( compgen -W 'sendtargets st slp isns fw' -- "$cur" ) )
+            return 0;
+            ;;
+        -L|-U|--loginall|--logoutall)
+            COMPREPLY=( $( compgen -W 'all manual automatic' -- "$cur" ) )
+            return 0;
+            ;;
+    esac
+
+    $split && return 0
+
+    local options
+    if [[ $COMP_CWORD -gt 1 ]] ; then
+        mode=${COMP_WORDS[2]}
+
+        case $mode in
+            discovery)
+                options='--help --version --debug --print --interface --type \
+                    --portal --login --op --name --value'
+                ;;
+            node)
+                options='--help --version --debug --print --loginall \
+                    --logoutall--show  -T --portal --interface --login \
+                    --logout --rescan --stats --op --name --value'
+                ;;
+            session)
+                options='--help --version --debug --print --sid --logout \
+                    --rescan --stats'
+                ;;
+            iface)
+                options='--help --version --debug --print --interface --op \
+                    --name --value'
+                ;;
+            fw)
+                options='--login'
+                ;;
+            host)
+                options='--print -H'
+                ;;
+        esac
+    else
+        options='--mode'
+    fi
+
+    COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+} &&
+complete -F _iscsiadm iscsiadm
+
+# 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
diff --git a/.bash/bash_completion.d/openldap b/.bash/bash_completion.d/openldap
new file mode 100644 (file)
index 0000000..e4bbba1
--- /dev/null
@@ -0,0 +1,266 @@
+# bash completion for openldap
+
+have ldapsearch && {
+_ldap_uris()
+{
+    COMPREPLY=( $( compgen -W 'ldap:// ldaps://' -- "$cur" ) )
+}
+
+_ldap_protocols()
+{
+    COMPREPLY=( $( compgen -W '2 3' -- "$cur" ) )
+}
+
+_ldapsearch()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H)
+            _ldap_uris
+            return 0
+            ;;
+        -T)
+            _filedir -d
+            return 0
+            ;;
+        -f|-y)
+            _filedir
+            return 0
+            ;;
+        -s)
+            COMPREPLY=( $( compgen -W 'base one sub children' -- "$cur" ) )
+            return 0
+            ;;
+        -a)
+            COMPREPLY=( $( compgen -W 'never always search find' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -P)
+            _ldap_protocols
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-n -u -v -t -tt -T -F -A -C -L -LL \
+            -LLL -M -MM -S -d -f -x -D -W -w -y -H -h -p -b -s -a \
+            -P -e -E -l -z -O -I -Q -U -R -X -Y -Z -ZZ' -- "$cur" ) )
+    fi
+}
+complete -F _ldapsearch ldapsearch
+
+_ldapaddmodify()
+{
+    local cur prev options
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H)
+            _ldap_uris
+            return 0
+            ;;
+        -S|-f|-y)
+            _filedir
+            return 0
+            ;;
+        -P)
+            _ldap_protocols
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        options='-c -S -n -v -M -MM -d -D -W -w -y -h -H -p -P -O -I \
+            -Q -U -R -x -X -Y -Z -ZZ -f'
+        if [[ ${COMP_WORDS[0]} == ldapmodify ]]; then
+            options="$options -a"
+        fi
+        COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+    fi
+}
+complete -F _ldapaddmodify ldapadd ldapmodify
+
+_ldapdelete()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H)
+            _ldap_uris
+            return 0
+            ;;
+        -f|-y)
+            _filedir
+            return 0
+            ;;
+        -P)
+            _ldap_protocols
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-n -v -c -M -MM -d -f -D -W -w -y \
+            -H -h -P -p -O -U -R -r -x -I -Q -X -Y -Z -ZZ' -- "$cur" ) )
+    fi
+}
+complete -F _ldapdelete ldapdelete
+
+_ldapcompare()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H)
+            _ldap_uris
+            return 0
+            ;;
+        -y)
+            _filedir
+            return 0
+            ;;
+        -P)
+            _ldap_protocols
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-n -v -z -M -MM -d -D -W -w -y \
+            -H -h -P -p -O -I -Q -U -R -x -X -Y -Z -ZZ' -- "$cur" ) )
+    fi
+}
+complete -F _ldapcompare ldapcompare
+
+_ldapmodrdn()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H)
+            _ldap_uris
+            return 0
+            ;;
+        -f|-y)
+            _filedir
+            return 0
+            ;;
+        -P)
+            _ldap_protocols
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-r -s -n -v -c -M -MM -d -D -W -w \
+            -y -H -h -P -p -O -I -Q -U -R -x -X -Y -Z -ZZ -f' -- "$cur" ) )
+    fi
+}
+complete -F _ldapmodrdn ldapmodrdn
+
+_ldapwhoami()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H)
+            _ldap_uris
+            return 0
+            ;;
+        -f|-y)
+            _filedir
+            return 0
+            ;;
+        -P)
+            _ldap_protocols
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-n -v -z -d -D -W -w -y -H -h -p -P \
+            -O -I -Q -U -R -x -X -Y -Z -ZZ' -- "$cur" ) )
+    fi
+}
+complete -F _ldapwhoami ldapwhoami
+
+_ldappasswd()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -H)
+            _ldap_uris
+            return 0
+            ;;
+        -t|-T|-y)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-A -a -t -d -D -H -h -n -p -S -s -T \
+            -v -W -w -y -O -I -Q -U -R -x -X -Y -Z -ZZ' -- "$cur" ) )
+    fi
+}
+complete -F _ldappasswd ldappasswd
+}
+
+# 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
diff --git a/.bash/bash_completion.d/openssl b/.bash/bash_completion.d/openssl
new file mode 100644 (file)
index 0000000..e9796e6
--- /dev/null
@@ -0,0 +1,254 @@
+# bash completion for openssl
+
+have openssl && {
+_openssl_sections()
+{
+    local config f
+
+    # check if a specific configuration file is used
+    for (( i=2; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == -config ]]; then
+            config=${COMP_WORDS[i+1]}
+            break
+        fi
+    done
+
+    # if no config given, check some usual default locations
+    if [ -z "$config" ]; then
+        for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \
+            /usr/share/ssl/openssl.cnf; do
+            [ -f $f ] && config=$f && break
+        done
+    fi
+
+    [ ! -f "$config" ] && return 0
+
+    COMPREPLY=( $( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" \
+        -- "$cur" ) )
+}
+
+_openssl()
+{
+    local cur prev commands command options formats
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    commands='asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa \
+        dsaparam ec ecparam enc engine errstr gendh gendsa genrsa \
+        nseq ocsp passwd pkcs12 pkcs7 pkcs8 prime rand req rsa \
+        rsautl s_client s_server s_time sess_id smime speed spkac \
+        verify version x509 md2 md4 md5 rmd160 sha sha1 aes-128-cbc \
+        aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc aes-256-ecb \
+        base64 bf bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc \
+        camellia-128-ecb camellia-192-cbc camellia-192-ecb \
+        camellia-256-cbc camellia-256-ecb cast cast-cbc cast5-cbc \
+        cast5-cfb cast5-ecb cast5-ofb des des-cbc des-cfb des-ecb \
+        des-ede des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 \
+        des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
+        rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \
+        rc4-40'
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
+    else
+        command=${COMP_WORDS[1]}
+        case $prev in
+            -CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \
+            -dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \
+            -out|-oid|-prvrify|-rand|-recip|-revoke|-sess_in|-sess_out| \
+            -spkac|-sign|-signkey|-signer|-signature|-ss_cert|-untrusted| \
+            -verify)
+                _filedir
+                return 0
+                ;;
+            -outdir|-CApath)
+                _filedir -d
+                return 0
+                ;;
+            -name|-crlexts|-extensions)
+                _openssl_sections
+                return 0
+                ;;
+            -inform|-outform|-keyform|-certform|-CAform|-CAkeyform|-dkeyform|-dcertform)
+                formats='DER PEM'
+                case $command in
+                    x509)
+                        formats="$formats NET"
+                        ;;
+                    smime)
+                        formats="$formats SMIME"
+                        ;;
+                esac
+                COMPREPLY=( $( compgen -W "$formats" -- "$cur" ) )
+                return 0
+                ;;
+            -connect)
+                _known_hosts_real "$cur"
+                return 0
+                ;;
+            -starttls)
+                COMPREPLY=( $( compgen -W 'smtp pop3 imap ftp' \
+                    -- "$cur" ) )
+                return 0
+                ;;
+            -cipher)
+                COMPREPLY=( $( compgen -W "$(openssl ciphers | \
+                    tr ':' '\n')" -- "$cur" ) )
+                return 0
+                ;;
+        esac
+
+        if [[ "$cur" == -* ]]; then
+            # possible options for the command
+            case $command in
+                asn1parse)
+                    options='-inform -in -out -noout -offset -length -i -oid \
+                        -strparse'
+                    ;;
+                ca)
+                    options='-verbose -config -name -gencrl -revoke \
+                        -crl_reason -crl_hold -crl_compromise \
+                        -crl_CA_compromise -crldays -crlhours -crlexts \
+                        -startdate -enddate -days -md -policy -keyfile -key \
+                        -passin -cert -selfsig -in -out -notext -outdir \
+                        -infiles -spkac -ss_cert -preserveDN -noemailDN \
+                        -batch -msie_hack -extensions -extfile -engine \
+                        -subj -utf8 -multivalue-rdn'
+                        ;;
+                ciphers)
+                    options='-v -ssl2 -ssl3 -tls1'
+                    ;;
+                crl)
+                    options='-inform -outform -text -in -out -noout -hash \
+                        -issuer -lastupdate -nextupdate -CAfile -CApath'
+                    ;;
+                crl2pkcs7)
+                    options='-inform -outform -in -out -print_certs'
+                    ;;
+                dgst)
+                    options='-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
+                        -c -d -hex -binary -out -sign -verify -prverify \
+                        -signature'
+                    ;;
+                dsa)
+                    options='-inform -outform -in -passin -out -passout -des \
+                        -des3 -idea -text -noout -modulus -pubin -pubout'
+                    ;;
+                dsaparam)
+                    options='-inform -outform -in -out -noout -text -C -rand \
+                        -genkey'
+                    ;;
+                enc)
+                    options='-ciphername -in -out -pass -e -d -a -A -k -kfile \
+                        -S -K -iv -p -P -bufsize -debug'
+                    ;;
+                dhparam)
+                    options='-inform -outform -in -out -dsaparam -noout -text \
+                        -C -2 -5 -rand'
+                    ;;
+                gendsa)
+                    options='-out -des -des3 -idea -rand'
+                    ;;
+                genrsa)
+                    options='-out -passout -des -des3 -idea -f4 -3 -rand'
+                    ;;
+                pkcs7)
+                    options='-inform -outform -in -out -print_certs -text \
+                        -noout'
+                    ;;
+                rand)
+                    options='-out -rand -base64'
+                    ;;
+                req)
+                    options='-inform -outform -in -passin -out -passout -text \
+                        -noout -verify -modulus -new -rand -newkey -newkey \
+                        -nodes -key -keyform -keyout -md5 -sha1 -md2 -mdc2 \
+                        -config -x509 -days -asn1-kludge -newhdr -extensions \
+                        -reqexts section'
+                    ;;
+                rsa)
+                    options='-inform -outform -in -passin -out -passout \
+                        -sgckey -des -des3 -idea -text -noout -modulus -check \
+                        -pubin -pubout -engine'
+                    ;;
+                rsautl)
+                    options='-in -out -inkey -pubin -certin -sign -verify \
+                        -encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse'
+                    ;;
+                s_client)
+                    options='-connect -verify -cert -certform -key -keyform \
+                        -pass -CApath -CAfile -reconnect -pause -showcerts \
+                        -debug -msg -nbio_test -state -nbio -crlf -ign_eof \
+                        -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \
+                        -bugs -cipher -starttls -engine -tlsextdebug \
+                        -no_ticket -sess_out -sess_in -rand'
+                    ;;
+                s_server)
+                    options='-accept -context -verify -Verify -crl_check \
+                        -crl_check_all -cert -certform -key -keyform -pass \
+                        -dcert -dcertform -dkey -dkeyform -dpass -dhparam \
+                        -nbio -nbio_test -crlf -debug -msg -state -CApath \
+                        -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 \
+                        -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 -no_dhe \
+                        -bugs -hack -www -WWW -HTTP -engine -tlsextdebug \
+                        -no_ticket -id_prefix -rand'
+                    ;;
+                s_time)
+                    options='-connect -www -cert -key -CApath -CAfile -reuse \
+                        -new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher'
+                    ;;
+                sess_id)
+                    options='-inform -outform -in -out -text -noout -context \
+                        ID'
+                    ;;
+                smime)
+                    options='-encrypt -decrypt -sign -verify -pk7out -des \
+                        -des3 -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 \
+                        -in -certfile -signer -recip -inform -passin -inkey \
+                        -out -outform -content -to -from -subject -text -rand'
+                    ;;
+                speed)
+                    options='-engine'
+                    ;;
+                verify)
+                    options='-CApath -CAfile -purpose -untrusted -help \
+                        -issuer_checks -verbose -certificates'
+                    ;;
+                x509)
+                    options='-inform -outform -keyform -CAform -CAkeyform -in \
+                        -out -serial -hash -subject_hash -issuer_hash -subject \
+                        -issuer -nameopt -email -startdate -enddate -purpose \
+                        -dates -modulus -fingerprint -alias -noout -trustout \
+                        -clrtrust -clrreject -addtrust -addreject -setalias \
+                        -days -set_serial -signkey -x509toreq -req -CA -CAkey \
+                        -CAcreateserial -CAserial -text -C -md2 -md5 -sha1 \
+                        -mdc2 -clrext -extfile -extensions -engine'
+                    ;;
+                md5|md4|md2|sha1|sha|mdc2|ripemd160)
+                    options='-c -d'
+                    ;;
+            esac
+            COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+        else
+            if [[ "$command" == speed ]]; then
+                COMPREPLY=( $( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 \
+                    idea-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 \
+                    rsa512 rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea \
+                    rc2 des rsa blowfish' -- "$cur" ) )
+            else
+                _filedir
+            fi
+        fi
+    fi
+}
+complete -F _openssl -o default openssl
+}
+
+# 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
diff --git a/.bash/bash_completion.d/p4 b/.bash/bash_completion.d/p4
new file mode 100644 (file)
index 0000000..59b02c1
--- /dev/null
@@ -0,0 +1,58 @@
+# Perforce completion by Frank Cusack <frank@google.com>
+
+have p4 &&
+_p4()
+{
+    local cur prev words cword p4commands p4filetypes
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev words cword
+
+    # rename isn't really a command
+    p4commands="$( p4 help commands | awk 'NF>3 {print $1}' )"
+    p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \
+        uresource uxbinary xbinary xltext xtempobj xtext \
+        text binary resource"
+
+    if [ $cword -eq 1 ]; then
+        COMPREPLY=( $( compgen -W "$p4commands" -- "$cur" ) )
+    elif [ $cword -eq 2 ]; then
+        case $prev in
+            help)
+                COMPREPLY=( $( compgen -W "simple commands \
+                    environment filetypes jobview revisions \
+                    usage views $p4commands" -- "$cur" ) )
+                ;;
+            admin)
+                COMPREPLY=( $( compgen -W "checkpoint stop" -- "$cur" ) )
+                ;;
+            *)
+                ;;
+        esac
+    elif [ $cword -gt 2 ]; then
+        case $prev in
+            -t)
+                case ${words[$cword-2]} in
+                    add|edit|reopen)
+                        COMPREPLY=( $( compgen -W "$p4filetypes" -- "$cur") )
+                        ;;
+                    *)
+                        ;;
+                esac
+                ;;
+            *)
+                ;;
+        esac
+    fi
+
+    return 0
+} &&
+complete -F _p4 -o default p4 g4
+
+# 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
diff --git a/.bash/bash_completion.d/perl b/.bash/bash_completion.d/perl
new file mode 100644 (file)
index 0000000..843e249
--- /dev/null
@@ -0,0 +1,131 @@
+# bash completion for perl
+
+have perl &&
+{
+_perlmodules()
+{
+    COMPREPLY=( $( compgen -P "$prefix" -W "$( $1 ${BASH_SOURCE[0]%/*}/helpers/perl modules $cur )" -- "$cur" ) )
+    __ltrim_colon_completions "$prefix$cur"
+}
+
+_perlfunctions()
+{
+    COMPREPLY=( $( compgen -P "$prefix" -W "$( ${BASH_SOURCE[0]%/*}/helpers/perl functions $cur )" -- "$cur" ) )
+}
+
+_perl()
+{
+    local cur prev prefix temp
+    local optPrefix optSuffix
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+    prefix=""
+
+    # If option not followed by whitespace, reassign prev and cur
+    if [[ "$cur" == -?* ]]; then
+        temp=$cur
+        prev=${temp:0:2}
+        cur=${temp:2}
+        optPrefix=-P$prev
+        optSuffix=-S/
+        prefix=$prev
+    fi
+
+    case $prev in
+        -D|-e|-E|-i|-F|-l)
+            return 0
+            ;;
+        -I|-x)
+            local IFS=$'\n'
+            _compopt_o_filenames
+            COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- "$cur" ) )
+            return 0
+            ;;
+        -m|-M)
+            temp="${cur#-}"
+            prefix="$prefix${cur%$temp}"
+            cur="$temp"
+            _perlmodules $1
+            return 0
+            ;;
+        -V)
+            if [[ $cur == :* ]]; then
+                temp="${cur##+(:)}"
+                prefix="$prefix${cur%$temp}"
+                local IFS=$'\n'
+                COMPREPLY=( $( compgen -P "$prefix" -W \
+                    '$( $1 -MConfig -e "print join \"\\n\",
+                        keys %Config::Config" 2>/dev/null )' -- "$temp" ) )
+                __ltrim_colon_completions "$prefix$temp"
+            fi
+            return 0
+            ;;
+        -d|-dt)
+            if [[ $cur == :* ]]; then
+                temp="${cur#:}"
+                prefix="$prefix${cur%$temp}"
+                cur="Devel::$temp"
+                _perlmodules $1
+            fi
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d \
+            -D -p -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- "$cur" ) )
+    else
+        _filedir
+    fi
+}
+complete -F _perl perl
+
+_perldoc()
+{
+    local cur prev prefix temp
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+    prefix=""
+
+    # completing an option (may or may not be separated by a space)
+    if [[ "$cur" == -?* ]]; then
+        temp=$cur
+        prev=${temp:0:2}
+        cur=${temp:2}
+        prefix=$prev
+    fi
+
+    # complete builtin perl functions
+    case $prev in
+        -f)
+            _perlfunctions "$cur"
+             return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- "$cur" ))
+    else
+        # return available modules (unless it is clearly a file)
+        if [[ "$cur" != */* ]]; then
+            _perlmodules
+            COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
+                '$( PAGER=/bin/cat man perl |  \
+                sed -ne "/perl.*Perl overview/,/perlwin32/p" | \
+                awk "\$NF=2 { print \$1}" | command grep perl )' -- "$cur" ) )
+        fi
+        _filedir 'p@(l|m|od)'
+    fi
+}
+complete -F _perldoc -o bashdefault perldoc
+}
+
+# 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
diff --git a/.bash/bash_completion.d/pine b/.bash/bash_completion.d/pine
new file mode 100644 (file)
index 0000000..2f06928
--- /dev/null
@@ -0,0 +1,22 @@
+# PINE address-book completion
+
+have pine || have alpine &&
+_pineaddr()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook \
+        2>/dev/null)' -- "$cur" ) )
+} &&
+complete -F _pineaddr -o default pine alpine
+
+# 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
diff --git a/.bash/bash_completion.d/pkg-config b/.bash/bash_completion.d/pkg-config
new file mode 100644 (file)
index 0000000..b999bd8
--- /dev/null
@@ -0,0 +1,51 @@
+# bash completion for pkgconfig
+
+have pkg-config &&
+_pkg_config()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        --variable|--define-variable|--atleast-version|--atleast-pkgconfig-version| \
+        --exact-version|--max-version)
+            # argument required but no completions available
+            return 0
+            ;;
+        -\?|--help|--version|--usage)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        # return list of available options
+        COMPREPLY=( $( compgen -W '--version --modversion \
+            --atleast-pkgconfig-version --libs --static \
+            --short-errors --libs-only-l --libs-only-other \
+            --libs-only-L --cflags --cflags-only-I \
+            --cflags-only-other --variable --define-variable \
+            --exists --uninstalled --atleast-version \
+            --exact-version --max-version --list-all --debug \
+            --print-errors --silence-errors --errors-to-stdout \
+            --print-provides --print-requires --help --usage' -- "$cur") )
+    else
+        COMPREPLY=( $( compgen -W "$( pkg-config --list-all \
+            2>/dev/null | awk '{print $1}' )" -- "$cur" ) )
+    fi
+} &&
+complete -F _pkg_config pkg-config
+
+# 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
diff --git a/.bash/bash_completion.d/pkg_install b/.bash/bash_completion.d/pkg_install
new file mode 100644 (file)
index 0000000..577d9c9
--- /dev/null
@@ -0,0 +1,30 @@
+# bash completion for FreeBSD base package management tools
+
+[ $UNAME = FreeBSD ] &&
+{
+
+_pkg_delete()
+{
+    local cur pkgdir prev
+
+    pkgdir=${PKG_DBDIR:-/var/db/pkg}/
+    _get_comp_words_by_ref cur prev
+
+    [[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return 0
+
+    COMPREPLY=( $( compgen -d "$pkgdir$cur" ) )
+    COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
+
+    return 0
+}
+complete -F _pkg_delete -o dirnames pkg_delete pkg_info
+
+}
+
+# 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
diff --git a/.bash/bash_completion.d/pkgtools b/.bash/bash_completion.d/pkgtools
new file mode 100644 (file)
index 0000000..3a5df27
--- /dev/null
@@ -0,0 +1,22 @@
+# bash completion for Slackware Linux pkgtools
+
+have removepkg && [ -f /etc/slackware-version ] &&
+_removepkg()
+{
+    local packages cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    COMPREPLY=( $( (cd /var/log/packages; compgen -f -- "$cur") ) )
+} &&
+complete -F _removepkg -o filenames removepkg &&
+    complete -o dirnames -f -X '!*.t[bglx]z' installpkg upgradepkg explodepkg
+
+# 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
diff --git a/.bash/bash_completion.d/pm-utils b/.bash/bash_completion.d/pm-utils
new file mode 100644 (file)
index 0000000..4deb82e
--- /dev/null
@@ -0,0 +1,37 @@
+# bash completion for pm-utils
+
+have pm-is-supported &&
+_pm_is_supported()
+{
+    local cur
+    _get_comp_words_by_ref cur
+    COMPREPLY=( $( compgen -W '--help --suspend --hibernate --suspend-hybrid' \
+        -- "$cur" ) )
+} &&
+complete -F _pm_is_supported pm-is-supported
+
+have pm-hibernate || have pm-suspend || have pm-suspend-hybrid &&
+_pm_action()
+{
+    local cur
+    _get_comp_words_by_ref cur
+    COMPREPLY=( $( compgen -W "--help $( _parse_help "$1" )" -- "$cur" ) )
+} &&
+complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid
+
+have pm-powersave &&
+_pm_powersave()
+{
+    local cur
+    _get_comp_words_by_ref cur
+    COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
+} &&
+complete -F _pm_powersave pm-powersave
+
+# 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
diff --git a/.bash/bash_completion.d/portupgrade b/.bash/bash_completion.d/portupgrade
new file mode 100644 (file)
index 0000000..5389a5c
--- /dev/null
@@ -0,0 +1,57 @@
+# bash completion for FreeBSD portupgrade package
+
+have portupgrade &&
+_portupgrade()
+{
+    local cur pkgdir prev
+
+    pkgdir=${PKG_DBDIR:-/var/db/pkg}/
+    _get_comp_words_by_ref cur prev
+
+    [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
+
+    COMPREPLY=( $( compgen -d "$pkgdir$cur" ) )
+    COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
+    COMPREPLY=( ${COMPREPLY[@]%-*} )
+
+    return 0
+} &&
+complete -F _portupgrade -o dirnames portupgrade
+
+have portinstall &&
+_portinstall()
+{
+    local cur portsdir prev indexfile
+    local -a COMPREPLY2
+
+    portsdir=${PORTSDIR:-/usr/ports}/
+    _get_comp_words_by_ref cur prev
+    # First try INDEX-5
+    indexfile=$portsdir/INDEX-5
+    # Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
+    [[ "${OSTYPE%.*}" == freebsd5 && -f $indexfile ]] ||
+        indexfile=$portsdir/INDEX
+
+    [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
+
+    COMPREPLY=( $( command grep -E "^$cur" < $indexfile | cut -d'|' -f1 ) )
+    COMPREPLY2=( $( command grep -E "^[^\|]+\|$portsdir$cur" < $indexfile | \
+        cut -d'|' -f2 ) )
+    COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
+    COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
+
+    return 0
+} &&
+complete -F _portinstall -o dirnames portinstall
+
+# _pkg_delete is in pkg_install
+type _pkg_delete &>/dev/null && have pkg_deinstall && \
+complete -F _pkg_delete -o dirnames pkg_deinstall
+
+# 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
diff --git a/.bash/bash_completion.d/postfix b/.bash/bash_completion.d/postfix
new file mode 100644 (file)
index 0000000..1311c98
--- /dev/null
@@ -0,0 +1,233 @@
+# bash completion for postfix
+
+have postfix && {
+# postfix(1)
+#
+_postfix()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -c)
+            _filedir -d
+            return 0
+            ;;
+        -D)
+            COMPREPLY=( $( compgen -W 'start' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '-c -D -v' -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -W 'check start stop abort flush reload status \
+        set-permissions upgrade-configuration' -- "$cur" ) )
+}
+complete -F _postfix postfix
+
+# postalias(1) and postmap(1)
+#
+_postmap()
+{
+    local cur prev len idx
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -c)
+            _filedir -d
+            return 0
+            ;;
+        -[dq])
+            return 0
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '-N -f -i -n -o -p -r -v -w -c -d -q' \
+            -- "$cur" ) )
+        return 0
+    fi
+
+    if [[ "$cur" == *:* ]]; then
+        _compopt_o_filenames
+        COMPREPLY=( $( compgen -f -- "${cur#*:}" ) )
+    else
+        len=${#cur}
+        idx=0
+        for pval in $( /usr/sbin/postconf -m ); do
+            if [[ "$cur" == "${pval:0:$len}" ]]; then
+                COMPREPLY[$idx]="$pval:"
+                idx=$(($idx+1))
+            fi
+        done
+        if [[ $idx -eq 0 ]]; then
+            _compopt_o_filenames
+            COMPREPLY=( $( compgen -f -- "$cur" ) )
+        fi
+    fi
+    return 0
+}
+complete -F _postmap postmap postalias
+
+# postcat(1)
+#
+_postcat()
+{
+    local cur prev pval len idx qfile
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -c)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '-c -q -v' -- "$cur" ) )
+        return 0
+    fi
+
+    qfile=0
+    for idx in "${COMP_WORDS[@]}"; do
+        [[ "$idx" = -q ]] && qfile=1 && break
+    done
+    if [[ $qfile == 1 ]]; then
+        len=${#cur}
+        idx=0
+        for pval in $( mailq 2>/dev/null | \
+            sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do
+            if [[ "$cur" == "${pval:0:$len}" ]]; then
+                COMPREPLY[$idx]=$pval
+                idx=$(($idx+1))
+            fi
+        done
+        return 0
+    else
+        _filedir
+        return 0
+    fi
+}
+complete -F _postcat postcat
+
+# postconf(1)
+#
+_postconf()
+{
+    local cur prev pval len idx eqext
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -b|-t)
+            _filedir
+            return 0
+            ;;
+        -c)
+            _filedir -d
+            return 0
+            ;;
+        -e)
+            cur=${cur#[\"\']}
+            eqext='='
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '-A -a -b -c -d -e -h -m -l -n -t -v' \
+            -- "$cur" ) )
+        return 0
+    fi
+
+    len=${#cur}
+    idx=0
+    for pval in $( /usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1 ); do
+        if [[ "$cur" == "${pval:0:$len}" ]]; then
+            COMPREPLY[$idx]="$pval$eqext"
+            idx=$(($idx+1))
+        fi
+    done
+    return 0
+}
+complete -F _postconf postconf
+
+# postsuper(1)
+#
+_postsuper()
+{
+    local cur prev pval len idx
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -c)
+            _filedir -d
+            return 0
+            ;;
+        -[dr])
+            len=${#cur}
+            idx=0
+            for pval in ALL $( mailq 2>/dev/null | \
+                sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//' ); do
+                if [[ "$cur" == "${pval:0:$len}" ]]; then
+                    COMPREPLY[$idx]=$pval
+                    idx=$(($idx+1))
+                fi
+            done
+            return 0
+            ;;
+        -h)
+            len=${#cur}
+            idx=0
+            for pval in ALL $( mailq 2>/dev/null | \
+                sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d' ); do
+                if [[ "$cur" == "${pval:0:$len}" ]]; then
+                    COMPREPLY[$idx]=$pval
+                    idx=$(($idx+1))
+                fi
+            done
+            return 0
+            ;;
+        -H)
+            len=${#cur}
+            idx=0
+            for pval in ALL $( mailq 2>/dev/null | \
+                sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
+                if [[ "$cur" == "${pval:0:$len}" ]]; then
+                    COMPREPLY[$idx]=$pval
+                    idx=$(($idx+1))
+                fi
+            done
+            return 0
+            ;;
+    esac
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '-c -d -h -H -p -r -s -v' -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- "$cur" ) )
+}
+complete -F _postsuper postsuper
+}
+
+# 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
diff --git a/.bash/bash_completion.d/postgresql b/.bash/bash_completion.d/postgresql
new file mode 100644 (file)
index 0000000..f874b67
--- /dev/null
@@ -0,0 +1,162 @@
+# bash completion for Postgresql
+
+have psql && {
+_pg_databases()
+{
+    # -w was introduced in 8.4, https://launchpad.net/bugs/164772
+    # "Access privileges" in output may contain linefeeds, hence the NF > 1
+    COMPREPLY=( $( compgen -W "$( psql -AtqwlF $'\t' 2>/dev/null | \
+        awk 'NF > 1 { print $1 }' )" -- "$cur" ) )
+}
+
+_pg_users()
+{
+    # -w was introduced in 8.4, https://launchpad.net/bugs/164772
+    COMPREPLY=( $( compgen -W "$( psql -Atqwc 'select usename from pg_user' \
+        template1 2>/dev/null )" -- "$cur" ) )
+    [ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- "$cur" ) )
+}
+
+# createdb(1) completion
+#
+_createdb()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -h|--host)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -U|--username|-O|--owner)
+            _pg_users
+            return 0
+            ;;
+        -p|--port|-D|--tablespace|-E|--encoding|-T|--template)
+            # argument required but no completions available
+            return 0
+            ;;
+        --help|--version)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--tablespace --template --encoding --host \
+            --port --username --password --echo --quiet --help --version' \
+            -- "$cur" ) )
+    else
+        _pg_databases
+    fi
+}
+complete -F _createdb -o default createdb
+
+# dropdb(1) completion
+#
+_dropdb()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -h|--host)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -U|--username)
+            _pg_users
+            return 0
+            ;;
+        --help|--version)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--host --port --username --password \
+            --interactive --echo --quiet --help --version' -- "$cur" ) )
+    else
+        _pg_databases
+    fi
+}
+complete -F _dropdb -o default dropdb
+
+# psql(1) completion
+#
+_psql()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -h|--host)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -U|--username)
+            _pg_users
+            return 0
+            ;;
+        -d|--dbname)
+            _pg_databases
+            return 0
+            ;;
+        -o|--output|-f|--file|-L|--log-file)
+            _filedir
+            return 0
+            ;;
+        -c|--command|-F|--field-separator|-p|--port|-P|--pset|\
+        -R|--record-separator|-T|--table-attr|-v|--set|--variable)
+            # argument required but no completions available
+            return 0
+            ;;
+        -\?|--help|-V|--version)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        # return list of available options
+        COMPREPLY=( $( compgen -W '--echo-all --no-align --command --dbname \
+            --echo-queries --echo-hidden --file --field-separator --host \
+            --html --list --log-file --output --port --pset --quiet \
+            --record-separator --single-step --single-line --tuples-only \
+            --table-attr --username --set --version --password --expanded \
+            --no-psqlrc --single-transaction --help' -- "$cur" ) )
+    else
+        # return list of available databases
+        _pg_databases
+    fi
+}
+complete -F _psql psql
+}
+
+# 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
diff --git a/.bash/bash_completion.d/povray b/.bash/bash_completion.d/povray
new file mode 100644 (file)
index 0000000..a843a5c
--- /dev/null
@@ -0,0 +1,65 @@
+# povray completion by "David Necas (Yeti)" <yeti@physics.muni.cz>
+
+have povray || have xpovray || have spovray &&
+_povray()
+{
+    local cur prev povcur pfx oext defoext
+    defoext=png # default output extension, if cannot be determined FIXME
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -c povcur prev
+
+    _expand || return 0
+
+    case $povcur in
+        [-+]I*)
+            cur="${povcur#[-+]I}" # to confuse _filedir
+            pfx="${povcur%"$cur"}"
+            _filedir pov
+            COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
+            return 0
+            ;;
+        [-+]O*)
+            # guess what output file type user may want
+            case $( ( IFS=$'\n'; command grep '^[-+]F' <<<"${COMP_WORDS[*]}" ) ) in
+                [-+]FN) oext=png ;;
+                [-+]FP) oext=ppm ;;
+                [-+]F[CT]) oext=tga ;;
+                *) oext=$defoext ;;
+            esac
+            # complete filename corresponding to previously specified +I
+            COMPREPLY=( $( ( IFS=$'\n'; command grep '^[-+]I' <<<"${COMP_WORDS[*]}" ) ) )
+            COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
+            COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
+            cur="${povcur#[-+]O}" # to confuse _filedir
+            pfx="${povcur%"$cur"}"
+            _filedir $oext
+            COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
+            return 0
+            ;;
+        *.ini\[|*.ini\[*[^]]) # sections in .ini files
+            cur="${povcur#*\[}"
+            pfx="${povcur%\["$cur"}" # prefix == filename
+            [ -r "$pfx" ] || return 0
+            COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \
+                -e 't' -e 'd' -- "$pfx") )
+            # to prevent [bar] expand to nothing.  can be done more easily?
+            COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" )
+            return 0
+            ;;
+        *)
+            cur="$povcur"
+            _filedir '@(ini|pov)'
+            return 0
+            ;;
+    esac
+} &&
+complete -F _povray povray xpovray spovray
+
+# 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
diff --git a/.bash/bash_completion.d/procps b/.bash/bash_completion.d/procps
new file mode 100644 (file)
index 0000000..db8fc3d
--- /dev/null
@@ -0,0 +1,49 @@
+# Completions for tools included in procps and related
+
+# killall(1) (Linux and FreeBSD) and pkill(1) completion.
+#
+[[ $UNAME == Linux || $UNAME == FreeBSD ]] || have pkill &&
+_killall()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then
+        _signals
+    else
+        _pnames
+    fi
+
+    return 0
+}
+[[ $UNAME == Linux || $UNAME == FreeBSD ]] && complete -F _killall killall
+have pkill && complete -F _killall pkill
+
+# pgrep(1) completion.
+#
+[ $UNAME = Linux ] || have pgrep &&
+_pgrep()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    _pnames
+
+    return 0
+}
+have pgrep && complete -F _pgrep pgrep
+
+# Linux pidof(8) completion.
+[ $UNAME = Linux ] && complete -F _pgrep pidof
+
+# 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
diff --git a/.bash/bash_completion.d/python b/.bash/bash_completion.d/python
new file mode 100644 (file)
index 0000000..17f96f5
--- /dev/null
@@ -0,0 +1,55 @@
+# bash completion for python
+
+have python &&
+_python()
+{
+    local prev cur i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -'?'|-h|--help|-V|--version|-c|-m)
+            return 0
+            ;;
+        -Q)
+            COMPREPLY=( $( compgen -W "old new warn warnall" -- "$cur" ) )
+            return 0
+            ;;
+        -W)
+            COMPREPLY=( $( compgen -W "ignore default all module once error" \
+                -- "$cur" ) )
+            return 0
+            ;;
+        !(?(*/)python*([0-9.])|-?))
+            [[ $COMP_CWORD -lt 2 || ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] \
+                && _filedir
+            ;;
+    esac
+
+
+    # if '-c' is already given, complete all kind of files.
+    for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
+        if [[ ${COMP_WORDS[i]} == -c ]]; then
+            _filedir
+        fi
+    done
+
+
+    if [[ "$cur" != -* ]]; then
+        _filedir 'py?([co])'
+    else
+        COMPREPLY=( $( compgen -W "$( _parse_help $1 -h )" -- "$cur" ) )
+    fi
+
+    return 0
+} &&
+complete -F _python python python2 python3
+
+# 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
diff --git a/.bash/bash_completion.d/qdbus b/.bash/bash_completion.d/qdbus
new file mode 100644 (file)
index 0000000..879df68
--- /dev/null
@@ -0,0 +1,23 @@
+# Qt qdbus, dcop completion
+
+have qdbus || have dcop &&
+_qdbus()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    [ -n "$cur" ] && unset COMP_WORDS[${#COMP_WORDS[@]}-1]
+    COMPREPLY=( $( compgen -W '$( command ${COMP_WORDS[@]} 2>/dev/null | \
+        sed s/\(.*\)// )' -- "$cur" ) )
+} &&
+complete -F _qdbus qdbus dcop
+
+# 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
diff --git a/.bash/bash_completion.d/qemu b/.bash/bash_completion.d/qemu
new file mode 100644 (file)
index 0000000..03fa563
--- /dev/null
@@ -0,0 +1,132 @@
+# bash completion for qemu
+
+have qemu &&
+_qemu()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -fd[ab]|-hd[abcd]|-cdrom|-option-rom|-kernel|-initrd|-bootp|-pidfile| \
+        -loadvm|-mtdblock|-sd|-pflash|-bios)
+            _filedir
+            return 0
+            ;;
+        -tftp|-smb|-L|-chroot)
+            _filedir -d
+            return 0
+            ;;
+        -boot)
+            COMPREPLY=( $( compgen -W 'a c d n' -- "$cur" ) )
+            return 0
+            ;;
+        -k)
+            COMPREPLY=( $( compgen -W 'ar de-ch es fo fr-ca hu ja \
+                mk no pt-br sv da en-gb et fr fr-ch is lt nl pl\
+                ru th de en-us fi fr-be hr it lv nl-be pt sl tr' -- "$cur" ) )
+            return 0
+            ;;
+        -soundhw)
+            COMPREPLY=( $( compgen -W "$( qemu -soundhw ? | awk \
+                '/^[[:lower:]]/ {print $1}' ) all" -- "$cur" ) )
+            return 0
+            ;;
+        -M)
+            COMPREPLY=( $( compgen -W "$( qemu -M ? | awk \
+                '/^[[:lower:]]/ {print $1}' )" -- "$cur" ) )
+            return 0
+            ;;
+        -cpu)
+            COMPREPLY=( $( compgen -W "$( qemu -cpu ? | awk \
+                '{print $2}' )" -- "$cur" ) )
+            return 0
+            ;;
+        -usbdevice)
+            COMPREPLY=( $( compgen -W 'mouse tablet disk: host: \
+                serial: braille net' -- "$cur" ) )
+            return 0
+            ;;
+        -net)
+            COMPREPLY=( $( compgen -W 'nic user tap socket vde none dump' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -serial|-parallel|-monitor)
+            COMPREPLY=( $( compgen -W 'vc pty none null /dev/ \
+                file: stdio pipe: COM udp: tcp: telnet: unix: \
+                mon: braille' -- "$cur" ) )
+            return 0
+            ;;
+        -redir)
+            COMPREPLY=( $( compgen -S":" -W 'tcp udp' -- "$cur" ) )
+            return 0
+            ;;
+        -bt)
+            COMPREPLY=( $( compgen -W 'hci vhci device' -- "$cur" ) )
+            return 0
+            ;;
+        -vga)
+            COMPREPLY=( $( compgen -W 'cirrus std vmware xenfb none' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -drive)
+            COMPREPLY=( $( compgen -S"=" -W 'file if bus unit index media \
+                cyls snapshot cache format serial addr' -- "$cur" ) )
+            return 0
+            ;;
+        -ballon)
+            COMPREPLY=( $( compgen -W 'none virtio' -- "$cur" ) )
+            return 0
+            ;;
+        -smbios)
+            COMPREPLY=( $( compgen -W 'file type' -- "$cur" ) )
+            return 0
+            ;;
+        -watchdog)
+            COMPREPLY=( $( compgen -W "$( qemu -watchdog ? 2>&1 | \
+                awk '{print $1}' )" -- "$cur" ) )
+            return 0
+            ;;
+        -watchdog-action)
+            COMPREPLY=( $( compgen -W 'reset shutdown poweroff pause debug \
+                none' -- "$cur" ) )
+            return 0
+            ;;
+        -runas)
+            _allowed_users
+            return 0
+            ;;
+    esac
+
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-M -fda -fdb -hda -hdb -hdc -hdd \
+            -cdrom -boot -snapshot -no-fd-bootchk -m -smp -nographic -vnc \
+            -k -audio-help -soundhw -localtime -full-screen -pidfile \
+            -daemonize -win2k-hack -option-rom -usb -usbdevice -net -tftp \
+            -smb -redir -kernel -append -initrd -serial -parallel -monitor \
+            -s -p -S -d -hdachs -L -std-vga -no-acpi -no-reboot -loadvm \
+            -semihosting -cpu -bt -vga -drive -startdate -name -curses \
+            -no-frame -no-quit -bootp -echr -no-shutdown -icount -g \
+            -prom-env -help -version -numa -mtdblock -sd -pflash \
+            -device -uuid -alt-grab -sdl -portrait -rtc-td-hack -no-hpet \
+            -balloon -acpitable -smbios -singlestep -gdb -hdachs -bios \
+            -kernel-kqemu -enable-kqemu -enable-kvm -clock -watchdog \
+            -watchdog-action -virtioconsole -show-cursor -tb-size -incoming \
+            -chroot -runas' -- "$cur" ) )
+    else
+        _filedir
+    fi
+} &&
+complete -F _qemu qemu
+
+# 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
diff --git a/.bash/bash_completion.d/quota-tools b/.bash/bash_completion.d/quota-tools
new file mode 100644 (file)
index 0000000..2b528d9
--- /dev/null
@@ -0,0 +1,257 @@
+# bash completion for quota-tools
+
+have quota && {
+_user_or_group()
+{
+    local i
+
+    # complete on groups if -g was given
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == -g ]]; then
+            COMPREPLY=( $( compgen -g -- "$cur" ) )
+            return 0
+        fi
+    done
+
+    # otherwise complete on users
+    COMPREPLY=( $( compgen -u -- "$cur" ) )
+}
+
+_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 split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--format)
+            _quota_formats
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-F --format -g --group -u --user -v \
+            --verbose -s --human-readable -p --raw-grace -i --no-autofs -l \
+            --local-only -A --all-nfs -m --no-mixed-pathnames -q --quiet -Q \
+            --quiet-refuse -w --no-wrap' -- "$cur" ) )
+    else
+        _user_or_group
+    fi
+}
+complete -F _quota -o default quota
+
+_setquota()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--format)
+            _quota_formats
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
+            -F --format -g --group -u --user -p --prototype -b --batch \
+            -c --continue-batch -t --edit-period -T --edit-times -a --all' \
+            -- "$cur" ) )
+    else
+        _count_args
+
+        case $args in
+            1)
+                _user_or_group
+                ;;
+            2)
+                _filesystems
+                ;;
+        esac
+
+    fi
+}
+complete -F _setquota -o default setquota
+
+_edquota()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--format)
+            _quota_formats
+            return 0
+            ;;
+        -f|--filesystem)
+            _filesystems
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
+            -g --group -u --user -p --prototype -F --format -f --filesystem \
+            -t --edit-period -T --edit-times' -- "$cur" ) )
+    else
+        _user_or_group
+    fi
+}
+complete -F _edquota -o default edquota
+
+_quotacheck()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--format)
+            _quota_formats
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-b --backup -v --verbose -d --debug \
+            -g --group -u --user -c --create-files -f --force -i \
+            --interactive -n --use-first-dquot -M --try-remount -m \
+            --no-remount -R --exclude-root -F --format -a --all' -- "$cur" ) )
+    else
+        _filesystems
+    fi
+}
+complete -F _quotacheck -o default quotacheck
+
+_repquota()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--format)
+            _quota_formats
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a --all -v --verbose -s --human-readable \
+            -c --batch-translation -C --no-batch-translation -t \
+            --truncate-names -n --no-names -p --raw-grace -i --no-autofs \
+            -u --user -g --group -F --format' -- "$cur" ) )
+    else
+        _filesystems
+    fi
+}
+complete -F _repquota -o default repquota
+
+_quotaon()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--format)
+            _quota_formats
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
+            -g --group -f --off -p --print-state -F --format' -- "$cur" ) )
+    else
+        _filesystems
+    fi
+}
+complete -F _quotaon -o default quotaon
+
+_quotaoff()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -F|--format)
+            _quota_formats
+            return 0
+            ;;
+        -x|--xfs-command)
+            COMPREPLY=( $( compgen -W 'delete enforce' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
+            -g --group -p --print-state -x --xfs-command -F --format' \
+            -- "$cur" ) )
+    else
+        _filesystems
+    fi
+}
+complete -F _quotaoff -o default quotaoff
+}
+
+# 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
diff --git a/.bash/bash_completion.d/rcs b/.bash/bash_completion.d/rcs
new file mode 100644 (file)
index 0000000..d859b8a
--- /dev/null
@@ -0,0 +1,43 @@
+# bash completion for rcs
+
+have rcs &&
+_rcs()
+{
+    local cur prev file dir i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    file=${cur##*/}
+    dir=${cur%/*}
+
+    # deal with relative directory
+    [ "$file" = "$dir" ] && dir=.
+
+    COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )
+
+    for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
+        file=${COMPREPLY[$i]##*/}
+        dir=${COMPREPLY[$i]%RCS/*}
+        COMPREPLY[$i]=$dir$file
+    done
+
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
+
+    for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
+        COMPREPLY[$i]=${COMPREPLY[$i]%,v}
+    done
+
+    # default to files if nothing returned and we're checking in.
+    # otherwise, default to directories
+    [[ ${#COMPREPLY[@]} -eq 0 && $1 == ci ]] && _filedir || _filedir -d
+} &&
+complete -F _rcs ci co rlog rcs rcsdiff
+
+# 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
diff --git a/.bash/bash_completion.d/rdesktop b/.bash/bash_completion.d/rdesktop
new file mode 100644 (file)
index 0000000..7acf47a
--- /dev/null
@@ -0,0 +1,57 @@
+# bash completion for rdesktop
+
+have rdesktop &&
+_rdesktop()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -k)
+            COMPREPLY=( $( command ls \
+                /usr/share/rdesktop/keymaps 2>/dev/null | \
+                command grep -E -v '(common|modifiers)' ) )
+            COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \
+                $HOME/.rdesktop/keymaps 2>/dev/null ) )
+            COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \
+                ./keymaps 2>/dev/null ) )
+            COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
+            return 0
+            ;;
+        -a)
+            COMPREPLY=( $( compgen -W '8 15 16 24' -- "$cur" ) )
+            return 0
+            ;;
+        -x)
+            COMPREPLY=( $( compgen -W 'b broadband m modem l lan' \
+                -- $cur ) )
+            return 0
+            ;;
+        -r)
+            # FIXME: should do -o nospace for the colon options
+            COMPREPLY=( $( compgen -W 'comport: disk: lptport: \
+                printer: sound: lspci scard' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-u -d -s -c -p -n -k -g -f -b -L \
+            -A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \
+            -0 -4 -5' -- "$cur" ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+
+} &&
+complete -F _rdesktop rdesktop
+
+# 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
diff --git a/.bash/bash_completion.d/reportbug b/.bash/bash_completion.d/reportbug
new file mode 100644 (file)
index 0000000..0c44bd6
--- /dev/null
@@ -0,0 +1,132 @@
+# bash completion for (Debian) reportbug package
+
+have reportbug &&
+_reportbug()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -f|--filename|-i|--include|--mta|-o|--output)
+            _filedir
+            return 0
+            ;;
+        -B|--bts)
+            COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
+                "$cur" ))
+            return 0
+            ;;
+        -e|--editor|--mua)
+            COMP_WORDS=(COMP_WORDS[0] "$cur")
+            COMP_CWORD=1
+            _command
+            return 0
+            ;;
+        --mode)
+            COMPREPLY=( $( compgen -W "novice standard expert" -- "$cur" ) )
+            return 0
+            ;;
+        -S|--severity)
+            COMPREPLY=( $( compgen -W "grave serious important normal \
+                minor wishlist" -- "$cur" ) )
+            return 0
+            ;;
+        -u|--ui|--interface)
+            COMPREPLY=( $( compgen -W "newt text gnome" -- "$cur" ) )
+            return 0
+            ;;
+        -t|--type)
+            COMPREPLY=( $( compgen -W "gnats debbugs" -- "$cur" ) )
+            return 0
+            ;;
+        -T|--tag)
+            COMPREPLY=( $( compgen -W "none \
+                woody potato sarge sarge-ignore etch etch-ignore \
+                lenny lenny-ignore sid experimental confirmed \
+                d-i fixed fixed-in-experimental fixed-upstream \
+                help l10n moreinfo patch pending security \
+                unreproducible upstream wontfix ipv6 lfs" -- "$cur" ))
+            return 0
+            ;;
+        --from-buildd)
+            COMPREPLY=( $( compgen -S "_" -W '$( apt-cache dumpavail | \
+                command grep "^Source: $cur" | sort -u | cut -f2 -d" " )' ))
+            return 0
+            ;;
+        *)
+            ;;
+    esac
+
+    COMPREPLY=($( compgen -W '--help --version --attach \
+        --no-query-bts --query-bts --bts --body --body-file --bodyfile \
+        --no-config-files --class --configure --check-available --debug \
+        --no-check-available --debconf --test --draftpath --editor --email \
+        --exit-prompt --filename --from-buildd --gnupg --gpg --path --gnus \
+        --header --include --no-check-installed --check-installed \
+        --justification --kudos --keyid --license --list-cc \
+        --maintonly --mirror --mode --mua --mta --mutt --mh --nmh \
+        --bugnumber --no-bug-script --no-cc-menu --output --offline \
+        --print --paranoid --no-paranoid --pgp --proxy --http_proxy \
+        --pseudo-header --quiet --query-only --query-source --no-query-source \
+        --realname --report-quiet --reply-to --replyto --subject --severity \
+        --smtphost --timeout --tls --smtpuser --smtppasswd --src --source --type \
+        --tag --template --verify --no-verify --no-cc --package-version \
+        --no-compress --ui --interface \
+        wnpp boot-floppies kernel bugs.debian.org \
+        cdimage.debian.org general installation-reports \
+        listarchives lists.debian.org mirrors nm.debian.org \
+        press project qa.debian.org release-notes \
+        security.debian.org tech-ctte upgrade-reports \
+        www.debian.org' -- "$cur" ) \
+        $( apt-cache pkgnames -- "$cur" 2> /dev/null) )
+    _filedir
+    return 0
+} &&
+complete -F _reportbug reportbug
+
+have querybts &&
+_querybts()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -B|--bts)
+            COMPREPLY=( $( compgen -W "debian guug kde mandrake help" \
+                -- "$cur" ))
+            return 0
+            ;;
+        -u|--ui|--interface)
+            COMPREPLY=($( compgen -W "newt text gnome" -- "$cur" ))
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \
+        -B --bts -l --ldap --no-ldap --proxy --http_proxy \
+        -s --source -w --web -u --ui --interface \
+        wnpp boot-floppies kernel bugs.debian.org \
+        cdimage.debian.org general installation-reports \
+        listarchives lists.debian.org mirrors nm.debian.org \
+        press project qa.debian.org release-notes \
+        security.debian.org tech-ctte upgrade-reports \
+        www.debian.org' -- "$cur" ) \
+        $( apt-cache pkgnames -- "$cur" 2> /dev/null) )
+} &&
+complete -F _querybts querybts
+
+# 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
diff --git a/.bash/bash_completion.d/resolvconf b/.bash/bash_completion.d/resolvconf
new file mode 100644 (file)
index 0000000..9773696
--- /dev/null
@@ -0,0 +1,30 @@
+# bash completion for resolvconf
+
+have resolvconf &&
+_resolvconf()
+{
+    local cur command
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -a|-d)
+            _available_interfaces
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -d -u' -- "$cur" ) )
+    fi
+} &&
+complete -F _resolvconf resolvconf
+
+# 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
diff --git a/.bash/bash_completion.d/rfkill b/.bash/bash_completion.d/rfkill
new file mode 100644 (file)
index 0000000..5c51ff9
--- /dev/null
@@ -0,0 +1,37 @@
+# bash completion for rfkill
+
+have rfkill &&
+_rfkill()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--version' -- "$cur" ) )
+    else
+        case $COMP_CWORD in
+            1)
+                COMPREPLY=( $( compgen -W "help event list block unblock" \
+                    -- "$cur" ) )
+                ;;
+            2)
+                if [[ $prev == block || $prev == unblock ]]; then
+                    COMPREPLY=( $( compgen -W "$(rfkill list | awk -F: \
+                        '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \
+                        wwan gps" -- "$cur" ) )
+                fi
+                ;;
+        esac
+    fi
+} &&
+complete -F _rfkill rfkill
+
+# 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
diff --git a/.bash/bash_completion.d/ri b/.bash/bash_completion.d/ri
new file mode 100644 (file)
index 0000000..be66d98
--- /dev/null
@@ -0,0 +1,96 @@
+# ri completion for Ruby documentation by Ian Macdonald <ian@caliban.org>
+
+have ri && {
+ri_get_methods()
+{
+    local regex
+
+    if [ "$ri_version" = integrated ]; then
+        if [ -z "$separator" ]; then
+            regex="(Instance|Class)"
+        elif [ "$separator" = "#" ]; then
+            regex=Instance
+        else
+            regex=Class
+        fi
+
+        COMPREPLY=( ${COMPREPLY[@]} \
+            "$( ri ${classes[@]} 2>/dev/null | ruby -ane \
+            'if /^'"$regex"' methods:/.../^------------------|^$/ and \
+            /^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \
+            end' | sort -u )" )
+    else
+        # older versions of ri didn't distinguish between class/module and
+        # instance methods
+        COMPREPLY=( ${COMPREPLY[@]} \
+            "$( ruby -W0 $ri_path ${classes[@]} | ruby -ane \
+            'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \
+            print $_.split(/, |,$| +/).grep(/^[^\[]*$/).join("\n"); \
+            end' | sort -u )" )
+    fi
+    COMPREPLY=( $( compgen $prefix -W '${COMPREPLY[@]}' -- $method ) )
+}
+
+# needs at least Ruby 1.8.0 in order to use -W0
+_ri()
+{
+    local cur class method prefix ri_path ri_version separator IFS
+    local -a classes
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    ri_path=$(type -p ri)
+    # which version of ri are we using?
+    # -W0 is required here to stop warnings from older versions of ri
+    # from being captured when used with Ruby 1.8.1 and later
+    ri_version="$(ruby -W0 $ri_path -v 2>&1)" || ri_version=integrated
+    [ "$ri_version" != "${ri_version%200*}" ] && ri_version=integrated
+
+    # need to also split on commas
+    IFS=$', \n\t'
+    if [[ "$cur" == [A-Z]*[#.]* ]]; then
+        [[ "$cur" == *#* ]] && separator=# || separator=.
+        # we're completing on class and method
+        class=${cur%$separator*}
+        method=${cur#*$separator}
+        classes=( $class )
+        prefix="-P $class$separator"
+        ri_get_methods
+        return 0
+    fi
+
+    if [ "$ri_version" = integrated ]; then
+        # integrated ri from Ruby 1.9
+        classes=( $( ri -c | ruby -ne 'if /^\s*$/..$stdin.eof then \
+        if /, [A-Z]+/ then print; end; end' ) )
+    elif [ "$ri_version" = "ri 1.8a" ]; then
+        classes=( $( ruby -W0 $ri_path | \
+            ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \
+            if /^ .*[A-Z]/ then print; end; end' ))
+    else
+        classes=( $( ruby -W0 $ri_path | \
+            ruby -ne 'if /^I have/..$stdin.eof then \
+                if /^ .*[A-Z]/ then print; end; end' ))
+    fi
+
+    COMPREPLY=( $( compgen -W '${classes[@]}' -- "$cur" ) )
+    if [[ "$cur" == [A-Z]* ]]; then
+        # we're completing on class or module alone
+        return 0
+    fi
+
+    # we're completing on methods
+    method=$cur
+    ri_get_methods
+}
+complete -F _ri ri
+}
+
+# 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
diff --git a/.bash/bash_completion.d/rpcdebug b/.bash/bash_completion.d/rpcdebug
new file mode 100644 (file)
index 0000000..be2a870
--- /dev/null
@@ -0,0 +1,57 @@
+# bash completion for rpcdebug
+
+have rpcdebug && {
+_rpcdebug_flags()
+{
+
+    local i module
+
+    for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
+        if [[ ${COMP_WORDS[i]} == -m ]]; then
+            module=${COMP_WORDS[i+1]}
+        fi
+    done
+
+    if [ -n "$module" ]; then
+        COMPREPLY=( $( compgen -W "$(rpcdebug -vh 2>&1 \
+            | command grep '^'$module' '\
+            | awk '{$1 = ""; print $0}')" -- "$cur" ) )
+    fi
+}
+
+_rpcdebug()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -s)
+            _rpcdebug_flags
+            return 0
+            ;;
+        -c)
+            _rpcdebug_flags
+            return 0
+            ;;
+        -m)
+            COMPREPLY=( $( compgen -W 'rpc nfs nfsd nlm' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-v -h -m -s -c' -- "$cur" ) )
+    fi
+}
+complete -F _rpcdebug rpcdebug
+}
+
+# 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
diff --git a/.bash/bash_completion.d/rpm b/.bash/bash_completion.d/rpm
new file mode 100644 (file)
index 0000000..bbab036
--- /dev/null
@@ -0,0 +1,309 @@
+# bash completion for rpm
+
+have rpm && {
+# helper functions
+
+_rpm_installed_packages()
+{
+    local nodig="$1" nosig="$2"
+
+    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
+        _rpm_nodigsig
+        COMPREPLY=( $( rpm -qa $nodig $nosig --qf='%{NAME} ' "$cur*" ) )
+    fi
+}
+
+_rpm_groups()
+{
+    local IFS=$'\n'
+    COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig --queryformat \
+        '%{group}\n' )" -- "$cur" ) )
+}
+
+_rpm_nodigsig()
+{
+    if [[ -z "$nodig" && -z "$nosig" ]]; then
+        local rpmver
+
+        rpmver=$(rpm --version)
+        rpmver=${rpmver##* }
+
+        if [[ "$rpmver" > "4.0.4" ]]; then
+            nodig="--nodigest"
+        fi
+        if [[ "$rpmver" > "4.0.99" ]]; then
+            nosig="--nosignature"
+        fi
+    fi
+}
+
+# rpm(8) completion
+#
+_rpm()
+{
+    local cur prev opts nodig nosig
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+    nodig=""
+    nosig=""
+    _rpm_nodigsig
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        # first parameter on line
+        case $cur in
+            -b*)
+                COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs' \
+                    -- "$cur" ) )
+                ;;
+            -t*)
+                COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts' \
+                    -- "$cur" ) )
+                ;;
+            --*)
+                COMPREPLY=( $( compgen -W '--help --version --initdb \
+                    --checksig --recompile --rebuild --resign --addsign \
+                    --rebuilddb --showrc --setperms --setugids --tarbuild \
+                    --eval --install --upgrade --query --freshen --erase \
+                    --verify --querytags --rmsource --rmspec --clean \
+                    --import' -- "$cur" ) )
+                ;;
+            *)
+                COMPREPLY=( $( compgen -W '-b -e -E -F -i -q -t -U -V' \
+                    -- "$cur" ) )
+                ;;
+        esac
+
+    return 0
+    fi
+
+    case $prev in
+        --dbpath|--excludepath|--prefix|--relocate|--root)
+            _filedir -d
+            return 0
+            ;;
+        --eval|-E)
+            # get a list of macros
+            COMPREPLY=( $( compgen -W "$( rpm --showrc | sed -ne \
+                's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p' )" \
+                -- "$cur" ) )
+            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 "$( rpm -qa $nodig $nosig \
+                    --queryformat='%{providename}\n' )" -- "$cur" ) )
+            fi
+            return 0
+            ;;
+        --whatrequires)
+            if [[ "$cur" == */* ]]; then
+                _filedir
+            else
+                # complete on capabilities
+                local IFS=$'\n'
+                COMPREPLY=( $( compgen -W "$( rpm -qa $nodig $nosig \
+                        --queryformat='%{requirename}\n' )" -- "$cur" ) )
+            fi
+            return 0
+            ;;
+        --target)
+            COMPREPLY=( $( compgen -W "$( command rpm --showrc | sed -ne \
+                's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p' )" \
+                -- "$cur" ) )
+            return 0
+            ;;
+        --define|-D|--fileid|--hdrid|--pkgid)
+            # argument required but no completions available
+            return 0
+            ;;
+    esac
+
+    # options common to all modes
+    opts="--define --eval --macros --nodigest --nosignature --rcfile \
+        --quiet --pipe --verbose"
+
+    case ${COMP_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 "$nodig" "$nosig"
+            fi
+            ;;
+        -q*|--query)
+            # options common to all query types
+            opts="$opts --changelog --configfiles --conflicts --docfiles
+                --dump --enhances --filesbypkg --filecaps --fileclass
+                --filecolor --fileprovide --filerequire --filesbypkg --info
+                --list --obsoletes --pipe --provides --queryformat --rcfile
+                --requires --scripts --suggests --triggers --xml"
+
+            if [[ $COMP_LINE == *\ -@(*([^ -])f|-file )* ]]; then
+                # -qf completion
+                if [[ "$cur" == -* ]]; then
+                    COMPREPLY=( $( compgen -W "$opts --dbpath --fscontext \
+                        --last --root --state" -- "$cur" ) )
+                else
+                    _filedir
+                fi
+            elif [[ $COMP_LINE == *\ -@(*([^ -])g|-group )* ]]; then
+                # -qg completion
+                _rpm_groups
+            elif [[ $COMP_LINE == *\ -@(*([^ -])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 [[ $COMP_LINE != *\ -@(*([^ -])a|-all )* ]]; then
+                    _rpm_installed_packages "$nodig" "$nosig"
+                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 [[ $COMP_LINE == *\ -@(*([^ -])f|-file )* ]]; then
+                _filedir
+            elif [[ $COMP_LINE == *\ -@(*([^ -])g|-group )* ]]; then
+                _rpm_groups
+            elif [[ $COMP_LINE == *\ -@(*([^ -])p|-package )* ]]; then
+                _filedir '[rs]pm'
+            else
+                _rpm_installed_packages "$nodig" "$nosig"
+            fi
+            ;;
+        -[bt]*)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W "$opts --short-circuit --timecheck \
+                    --clean --rmsource --rmspec --test --sign --buildroot \
+                    --target --nobuild --nodeps --nodirtokens" -- "$cur" ) )
+            elif [[ ${COMP_WORDS[1]} == -b* ]]; then
+                _filedir spec
+            else
+                _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))'
+            fi
+            ;;
+        --rebuild|--recompile)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W "$opts --nodeps --rmsource \
+                  --rmspec --sign --nodirtokens --target" -- "$cur" ) )
+            else
+                _filedir '@(?(no)src.r|s)pm'
+            fi
+            ;;
+        --tarbuild)
+            _filedir '@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))'
+            ;;
+        --resign|--addsign)
+            _filedir '[rs]pm'
+            ;;
+        --setperms|--setgids)
+            _rpm_installed_packages "$nodig" "$nosig"
+            ;;
+        --clean|--rmsource|--rmspec)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W '--clean --rmsource --rmspec' \
+                    -- "$cur" ) )
+            else
+                _filedir spec
+            fi
+            ;;
+        --import|--dbpath|--root)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W '--import --dbpath --root' \
+                    -- "$cur" ) )
+            else
+                _filedir
+            fi
+            ;;
+    esac
+
+    return 0
+}
+complete -F _rpm rpm rpmbuild
+}
+
+have gendiff &&
+_gendiff()
+{
+    COMPREPLY=()
+    local cur cword
+    _get_comp_words_by_ref cur cword
+    [[ $cword != 1 ]] || _filedir -d
+} &&
+complete -F _gendiff gendiff
+
+# 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
diff --git a/.bash/bash_completion.d/rpmcheck b/.bash/bash_completion.d/rpmcheck
new file mode 100644 (file)
index 0000000..5d9aada
--- /dev/null
@@ -0,0 +1,33 @@
+# bash completion for rpmcheck
+
+have rpmcheck &&
+_rpmcheck()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -base)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-explain -failures -successes \
+            -dump -dump-all -base -help -compressed-input' -- "$cur" ) )
+    else
+        _filedir
+    fi
+} &&
+complete -F _rpmcheck rpmcheck $files
+
+# 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
diff --git a/.bash/bash_completion.d/rrdtool b/.bash/bash_completion.d/rrdtool
new file mode 100644 (file)
index 0000000..0b15a23
--- /dev/null
@@ -0,0 +1,20 @@
+# bash completion for rrdtool
+
+have rrdtool &&
+_rrdtool ()
+{
+    local cur
+    _get_comp_words_by_ref cur
+
+    COMPREPLY=( $( compgen -W 'create update updatev graph dump restore last \
+        lastupdate first info fetch tune resize xport' -- "$cur" ) )
+} &&
+complete -F _rrdtool rrdtool
+
+# 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
diff --git a/.bash/bash_completion.d/rsync b/.bash/bash_completion.d/rsync
new file mode 100644 (file)
index 0000000..b0f2d10
--- /dev/null
@@ -0,0 +1,92 @@
+# bash completion for rsync
+
+have rsync &&
+_rsync()
+{
+    # TODO: _split_longopt
+
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref -n : cur prev
+
+    _expand || return 0
+
+    case $prev in
+        --config|--password-file|--include-from|--exclude-from)
+            _filedir
+            return 0
+            ;;
+        -T|--temp-dir|--compare-dest)
+            _filedir -d
+            return 0
+            ;;
+        -e|--rsh)
+            COMPREPLY=( $( compgen -W 'rsh ssh' -- "$cur" ) )
+            return 0
+            ;;
+        --compress-level)
+            COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    case $cur in
+        -*)
+            COMPREPLY=( $( compgen -W '--verbose --quiet --no-motd --checksum \
+                --archive --recursive --relative --no-implied-dirs \
+                --backup --backup-dir --suffix= --update --inplace --append \
+                --append-verify --dirs --old-dirs --links --copy-links \
+                --copy-unsafe-links --safe-links --copy-dirlinks \
+                --keep-dirlinks --hard-links --perms --executability --chmod= \
+                --acls --xattrs --owner --group --devices --copy-devices \
+                --specials --times --omit-dir-times --super --fake-super \
+                --sparse --dry-run --whole-file --no-whole-file \
+                --one-file-system --block-size= --rsh= --rsync-path= \
+                --existing --ignore-existing --remove-source-files --delete \
+                --delete-before --delete-during --delete-delay --delete-after \
+                --delete-excluded --ignore-errors --force --max-delete= \
+                --max-size= --min-size= --partial --partial-dir= \
+                --delay-updates --prune-empty-dirs --numeric-ids --timeout= \
+                --contimeout= --ignore-times --size-only --modify-window= \
+                --temp-dir= --fuzzy --compare-dest= --copy-dest= --link-dest= \
+                --compress --compress-level= --skip-compress= --cvs-exclude \
+                --filter= --exclude= --exclude-from= --include= \
+                --include-from= --files-from= --from0 --protect-args \
+                --address= --port= --sockopts= --blocking-io --no-blocking-io \
+                --stats --8-bit-output --human-readable --progress \
+                --itemize-changes --out-format= --log-file= \
+                --log-file-format= --password-file= --list-only --bwlimit= \
+                --write-batch= --only-write-batch= --read-batch= --protocol= \
+                --iconv= --ipv4 --ipv6 --version --help --daemon --config= \
+                --no-detach' -- "$cur" ) )
+            ;;
+        *:*)
+            if type _scp_remote_files &>/dev/null; then
+                # find which remote shell is used
+                local i shell=ssh
+                for (( i=1; i < COMP_CWORD; i++ )); do
+                    if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
+                        shell=${COMP_WORDS[i+1]}
+                        break
+                    fi
+                done
+                [ "$shell" = ssh ] && _scp_remote_files
+            fi
+            ;;
+        *)
+            _known_hosts_real -c -a "$cur"
+            type _scp_local_files &>/dev/null && _scp_local_files || _filedir
+            ;;
+    esac
+
+    return 0
+} &&
+complete -F _rsync -o nospace rsync
+
+# 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
diff --git a/.bash/bash_completion.d/rtcwake b/.bash/bash_completion.d/rtcwake
new file mode 100644 (file)
index 0000000..c95c1d7
--- /dev/null
@@ -0,0 +1,40 @@
+# bash completion for rtcwake
+
+have rtcwake &&
+_rtcwake()
+{
+    COMPREPLY=()
+    local cur prev split=false
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case "$prev" in
+        --help|-h|--version|-V|--seconds|-s|--time|-t)
+            return 0
+            ;;
+        --mode|-m)
+            COMPREPLY=( $( compgen -W 'standby mem disk on no off' -- "$cur" ) )
+            return 0
+            ;;
+        --device|-d)
+            COMPREPLY=( $( command ls -d /dev/rtc?* 2>/dev/null ) )
+            COMPREPLY=( $( compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    COMPREPLY=( $( compgen -W '--device --local --mode --seconds --time --utc \
+        --verbose --version --help' -- "$cur" ) )
+} &&
+complete -F _rtcwake rtcwake
+
+# 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
diff --git a/.bash/bash_completion.d/samba b/.bash/bash_completion.d/samba
new file mode 100644 (file)
index 0000000..61d78ab
--- /dev/null
@@ -0,0 +1,298 @@
+# bash completion for samba
+
+have smbclient && {
+_samba_resolve_order()
+{
+    COMPREPLY=( $( compgen -W 'lmhosts host wins bcast' -- "$cur" ) )
+}
+
+_samba_domains()
+{
+    if [ -n "${COMP_SAMBA_SCAN:-}" ]; then
+        COMPREPLY=( $( compgen -W '$( smbtree -N -D )' -- "$cur" ) )
+    fi
+}
+
+_samba_hosts()
+{
+    if [ -n "${COMP_SAMBA_SCAN:-}" ]; then
+        COMPREPLY=( $( compgen -W "$( smbtree -N -S | \
+            sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \
+            )" -- $cur ) )
+    fi
+}
+
+_samba_debuglevel()
+{
+    COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- "$cur" ) )
+}
+
+_smbclient()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -R)
+            _samba_resolve_order
+            return 0;
+            ;;
+        -t)
+            COMPREPLY=( $( compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \
+                -- "$cur" ) )
+            return 0;
+            ;;
+        -s|-A|--authentication-file)
+            _filedir
+            return 0;
+            ;;
+        -l|--log-basename|-D)
+            _filedir -d
+            return 0;
+            ;;
+        -O)
+            COMPREPLY=( $( compgen -W 'SO_KEEPALIVE SO_REUSEADDR \
+                SO_BROADCAST TCP_NODELAY IPTOS_LOWDELAY \
+                IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF \
+                SO_SNDLOWAT SO_RCVLOWAT' -- "$cur" ) )
+            return 0;
+            ;;
+        -T)
+            COMPREPLY=( $( compgen -W 'c x I X F b g q r N a' -- "$cur" ) )
+            return 0;
+            ;;
+        -W|--workgroup)
+            _samba_domains
+            return 0;
+            ;;
+        -d|--debuglevel)
+            _samba_debuglevel
+            return 0
+            ;;
+        -p|--port|-M|-I|-b|-U|--user|-n|-i|-T|-c)
+            # argument required but no completions available
+            return 0
+            ;;
+        -\?|--help|-V|--version)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-b -d -L -U -I -M -m -A -N -i -O \
+            -p -R -s -k -P -c -D -W -l -E --debuglevel \
+            --log-basename --workgroup' -- "$cur" ) )
+    fi
+}
+complete -F _smbclient smbclient
+
+_smbget()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -o|-f|--outputfile|--rcfile)
+            _filedir
+            return 0;
+            ;;
+        -d|--debuglevel)
+            _samba_debuglevel
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a --guest -r --resume -R --recursive -u \
+            --username -p --password -w --workgroup -n --nonprompt -d \
+            --debuglevel -D --dots -P --keep-permissions -o --outputfile -f \
+            --rcfile -q --quiet -v --verbose -b --blocksize -? --help --usage' \
+            -- "$cur" ) )
+    fi
+}
+complete -F _smbget smbget
+
+_smbcacls()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -s)
+            _filedir
+            return 0;
+            ;;
+        -l|--log-basename)
+            _filedir -d
+            return 0;
+            ;;
+        -d|--debuglevel)
+            _samba_debuglevel
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -M -D -S -U -C -G --numeric -t \
+            -h --help -V -s -d --debuglevel -l --log-basename' -- "$cur" ) )
+    fi
+}
+complete -F _smbcacls smbcacls
+
+_smbcquotas()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -s|-A|--authentication-file)
+            _filedir
+            return 0;
+            ;;
+        -l|--log-basename)
+            _filedir -d
+            return 0;
+            ;;
+        -d|--debuglevel)
+            _samba_debuglevel
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-u -L -F -S -n -t -v -h --help -V \
+            -s --debuglevel --log-basename -N -k \
+            --authentication-file --user' -- "$cur" ) )
+    fi
+}
+complete -F _smbcquotas smbcquotas
+
+_smbpasswd()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -r)
+            _samba_hosts
+            return 0;
+            ;;
+        -R)
+            _samba_resolve_order
+            return 0;
+            ;;
+        -c)
+            _filedir
+            return 0;
+            ;;
+        -D)
+            _samba_debuglevel
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -c -x -d -e -D -n -r -R -m -U -h \
+            -s -w -W -i -L' -- "$cur" ) )
+    fi
+}
+complete -F _smbpasswd smbpasswd
+
+_smbtar()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -r|-t)
+            _filedir tar
+            return 0;
+            ;;
+        -s)
+            _samba_hosts
+            return 0;
+            ;;
+        -l)
+            _samba_debuglevel
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-r -i -a -v -s -p -x -X -N -b -d -l -u -t' \
+            -- "$cur" ) )
+    fi
+}
+complete -F _smbtar smbtar
+
+_smbtree()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -s|-A|--authentication-file)
+            _filedir
+            return 0;
+            ;;
+        -l|--log-basename)
+            _filedir -d
+            return 0;
+            ;;
+        -d|--debuglevel)
+            _samba_debuglevel
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-b -D -S -V -s -d --debuglevel -l \
+            --log-basename -N -k -A --authentication-file -U --user\
+            -h --help' -- "$cur" ) )
+    fi
+}
+complete -F _smbtree smbtree
+}
+
+# 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
diff --git a/.bash/bash_completion.d/sbcl b/.bash/bash_completion.d/sbcl
new file mode 100644 (file)
index 0000000..33671a6
--- /dev/null
@@ -0,0 +1,31 @@
+# bash programmable completion for various Common Lisp implementations by
+# Nikodemus Siivola <nikodemus@random-state.net>
+
+have sbcl || have sbcl-mt &&
+_sbcl()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    # completing an option (may or may not be separated by a space)
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--core --noinform --help --version
+            --sysinit --userinit --eval --noprint --disable-debugger
+            --end-runtime-options --end-toplevel-options ' -- "$cur" ) )
+    else
+        _filedir
+    fi
+
+    return 0
+} &&
+complete -F _sbcl sbcl sbcl-mt
+
+# 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
diff --git a/.bash/bash_completion.d/screen b/.bash/bash_completion.d/screen
new file mode 100644 (file)
index 0000000..952d976
--- /dev/null
@@ -0,0 +1,66 @@
+# bash completion for screen
+
+have screen &&
+_screen_sessions()
+{
+    COMPREPLY=( $( compgen -W "$( command screen -ls | sed -ne \
+        's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p' )" \
+        -- "$cur" ) )
+} &&
+_screen()
+{
+    local cur prev words cword
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev words cword
+
+    if ((cword > 2)); then
+        case ${words[cword-2]} in
+            -[dD])
+                _screen_sessions
+                return 0
+                ;;
+        esac
+    fi
+
+    case $prev in
+        -[rR])
+            # list detached
+            _screen_sessions 'Detached'
+            return 0
+            ;;
+        -[dD])
+            # list attached
+            _screen_sessions 'Attached'
+            return 0
+            ;;
+        -x)
+            # list both
+            _screen_sessions
+            return 0
+            ;;
+        -s)
+            _shells
+            return 0
+            ;;
+        -c)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -A -c -d -D -e -f -fn -fa -h -i -ln \
+            -list -L -m -O -p -q -r -R -s -S -t -U -v -wipe -x -X --help \
+            --version' -- "$cur" ) )
+    fi
+} &&
+complete -F _screen -o default screen
+
+# 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
diff --git a/.bash/bash_completion.d/service b/.bash/bash_completion.d/service
new file mode 100644 (file)
index 0000000..1a36f59
--- /dev/null
@@ -0,0 +1,47 @@
+# service(8) and /etc/init.d/* completion
+
+# 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
+#
+{ have service || [ -d /etc/init.d/ ]; } &&
+_service()
+{
+    local cur prev sysvdir
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    # don't complete for things like killall, ssh and mysql if it's
+    # the standalone command, rather than the init script
+    [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0
+
+    # don't complete past 2nd token
+    [ $COMP_CWORD -gt 2 ] && return 0
+
+    if [[ $COMP_CWORD -eq 1 && $prev == "service" ]]; then
+        _services
+    else
+        [ -d /etc/rc.d/init.d ] && \
+            sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
+        COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
+            -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
+            $sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" ) )
+    fi
+
+    return 0
+} &&
+complete -F _service service
+for svc in /etc/init.d/*; do
+    [ ! -x "$svc" ] || complete -p "${svc##*/}" &>/dev/null || \
+        complete -F _service -o default "${svc##*/}"
+done
+unset svc
+
+# 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
diff --git a/.bash/bash_completion.d/sh b/.bash/bash_completion.d/sh
new file mode 100644 (file)
index 0000000..9c7ca02
--- /dev/null
@@ -0,0 +1,41 @@
+# POSIX sh(1) completion
+
+have sh &&
+_sh()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -c)
+            return 0
+            ;;
+        -o|+o)
+            COMPREPLY=( $( compgen -W 'allexport errexit ignoreeof monitor
+                noclobber noglob noexec nolog notify nounset verbose vi
+                xtrace' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x"
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W "$opts -c -s" -- "$cur" ) )
+        return 0
+    elif [[ "$cur" == +* ]]; then
+        COMPREPLY=( $( compgen -W "${opts//-/+}" -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir sh
+} &&
+complete -F _sh sh
+
+# 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
diff --git a/.bash/bash_completion.d/shadow b/.bash/bash_completion.d/shadow
new file mode 100644 (file)
index 0000000..6aea045
--- /dev/null
@@ -0,0 +1,482 @@
+# bash completion for shadow utils
+
+have useradd &&
+_useradd()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    # 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|-k|--skel)
+            _filedir -d
+            return 0
+            ;;
+        -g|--gid)
+            _gids
+            COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        -G|--groups)
+            COMPREPLY=( $( compgen -g -- "$cur" ) )
+            return 0
+            ;;
+        -s|--shell)
+            _shells
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--base-dir --comment --home-dir --defaults \
+            --expiredate --inactive --gid --groups --help --skel --key \
+            --no-log-init --create-home --no-create-home --no-user-group \
+            --non-unique --password --system --shell --uid --user-group \
+            --selinux-user' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _useradd useradd
+
+have usermod &&
+_usermod()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    # 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)
+            COMPREPLY=( $( compgen -g -- "$cur" ) )
+            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 '--append --comment --home --expiredate \
+            --inactive --gid --groups --help --login --lock --move-home \
+            --non-unique --password --shell --uid --unlock --selinux-user' \
+            -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -u -- "$cur" ) )
+} &&
+complete -F _usermod usermod
+
+have userdel &&
+_userdel()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--force --help --remove' -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -u -- "$cur" ) )
+} &&
+complete -F _userdel userdel
+
+have chage &&
+_chage()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    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 '--lastday --expiredate --help --inactive \
+            --list --mindays --maxdays --warndays' -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -u -- "$cur" ) )
+} &&
+complete -F _chage chage
+
+have passwd &&
+_passwd()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -n|-x|-w|-i|-\?|--help|--usage)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-k -l --stdin -u -d -n -x -w -i -S \
+            -? --help --usage' -- "$cur" ) )
+        return 0
+    fi
+
+    _allowed_users
+} &&
+complete -F _passwd passwd
+
+have chpasswd &&
+_chpasswd()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    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
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--crypt-method --encrypted \
+            --help --md5 --sha-rounds' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _chpasswd chpasswd
+
+have newusers &&
+_newusers()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    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
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--crypt-method --help --system \
+            --sha-rounds' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _newusers newusers
+
+have pwck &&
+_pwck()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-q -r -s' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _pwck pwck
+
+have groupadd &&
+_groupadd()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    # 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 '--force --gid --help \
+            --key --non-unique --password --system' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _groupadd groupadd
+
+have groupmod &&
+_groupmod()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    # 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 '--gid --help --new-name \
+            --non-unique --password' -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -g -- "$cur" ) )
+} &&
+complete -F _groupmod groupmod
+
+complete -g groupdel
+
+have newgrp &&
+_newgrp()
+{
+    COMPREPLY=()
+    if [[ "`_get_cword`" == "-" ]]; then
+        COMPREPLY=( - )
+    else
+        _allowed_groups
+    fi
+} &&
+complete -F _newgrp newgrp
+
+have gpasswd &&
+_gpasswd()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -a|-d|-A|-M)
+            COMPREPLY=( $( compgen -u -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -d -r -R -A -M' -- "$cur" ) )
+        return 0
+    fi
+
+    COMPREPLY=( $( compgen -g -- "$cur" ) )
+} &&
+complete -F _gpasswd gpasswd
+
+have groupmems &&
+_groupmems()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -a|-d)
+            COMPREPLY=( $( compgen -u -- "$cur" ) )
+            return 0
+            ;;
+        -g)
+            COMPREPLY=( $( compgen -g -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -d -p -g -l' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _groupmems groupmems
+
+have grpck &&
+_grpck()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-r -s' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _grpck grpck
+
+have vipw || have vigr &&
+_vipw()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -h|--help)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--group --help --passwd \
+            --quiet --shadow' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _vipw vipw vigr
+
+have faillog &&
+_faillog()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -h|--help|-l|--lock-time|-m|--maximum|-t|--time)
+            return 0
+            ;;
+        -u|--user)
+            COMPREPLY=( $( compgen -u -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--all --help --lock-time \
+            --maximum --reset --time --user' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _faillog faillog
+
+have lastlog &&
+_lastlog()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -b|--before|-h|--help|-t|--time)
+            return 0
+            ;;
+        -u|--user)
+            COMPREPLY=( $( compgen -u -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--before --help --time --user' -- "$cur" ) )
+        return 0
+    fi
+} &&
+complete -F _lastlog lastlog
+
+# 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
diff --git a/.bash/bash_completion.d/sitecopy b/.bash/bash_completion.d/sitecopy
new file mode 100644 (file)
index 0000000..616bc5e
--- /dev/null
@@ -0,0 +1,40 @@
+# sitecopy(1) completion
+# Copyright 2003 Eelco Lempsink <eelcolempsink@gmx.net>
+# License: GNU GPL v2 or later
+
+have sitecopy &&
+_sitecopy()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    case $cur in
+        --*)
+            COMPREPLY=( $( compgen -W "$(sitecopy -h | command grep -e '--\w' |\
+                awk '{sub (/=(FILE|PATH)/, "", $2); print $2}')" -- "$cur" ) )
+            ;;
+        -*)
+            COMPREPLY=( $( compgen -W "$(sitecopy -h | command grep -e '-\w' | \
+                awk '{sub (",", "", $1); print $1}')" -- "$cur" ) )
+            ;;
+        *)
+            if [ -r ~/.sitecopyrc ]; then
+                COMPREPLY=( $( compgen -W "$(command grep '^["$'\t '"]*site' \
+                    ~/.sitecopyrc | awk '{print $2}')" -- "$cur" ) )
+            fi
+            ;;
+    esac
+
+    return 0
+} &&
+complete -F _sitecopy -o default sitecopy
+
+# 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
diff --git a/.bash/bash_completion.d/smartctl b/.bash/bash_completion.d/smartctl
new file mode 100644 (file)
index 0000000..74e4281
--- /dev/null
@@ -0,0 +1,146 @@
+# bash completion for smartctl(8)
+
+have smartctl &&
+{
+_smartctl_quietmode()
+{
+    COMPREPLY=( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) )
+}
+_smartctl_device()
+{
+    local i opts='ata scsi sat marvell hpt cciss'
+    for (( i=0; i <= 31; i++ )) ; do
+        opts="$opts 3ware,$i"
+    done
+    COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
+}
+_smartctl_tolerance()
+{
+    COMPREPLY=( $( compgen -W 'normal conservative permissive \
+        verypermissive' -- "$cur" ) )
+}
+_smartctl_badsum()
+{
+    COMPREPLY=( $( compgen -W 'warn exit ignore' -- "$cur" ) )
+}
+_smartctl_report()
+{
+    COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) )
+}
+_smartctl_powermode()
+{
+    COMPREPLY=( $( compgen -W 'never sleep standby idle' -- "$cur" ) )
+}
+_smartctl_feature()
+{
+    COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+}
+_smartctl_log()
+{
+    COMPREPLY=( $( compgen -W 'error selftest selective directory' -- "$cur" ) )
+}
+_smartctl_vendorattribute()
+{
+    COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
+                9,temp 192,emergencyretractcyclect 193,loadunload \
+                194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
+                200,writeerrorcount 201,detectedtacount 220,temp' -- "$cur" ) )
+}
+_smartctl_firmwarebug()
+{
+    COMPREPLY=( $( compgen -W 'none samsung samsung2 samsung3 swapid' \
+        -- "$cur" ) )
+}
+_smartctl_presets()
+{
+    COMPREPLY=( $( compgen -W 'use ignore show showall' -- "$cur" ) )
+}
+_smartctl_test()
+{
+    COMPREPLY=( $( compgen -W 'offline short long conveyance select \
+                afterselect,on afterselect,off pending scttempint' -- "$cur" ) )
+}
+
+
+_smartctl()
+{
+    local cur prev split=false
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _split_longopt && split=true
+
+    case $prev in
+        -q|--quietmode)
+            _smartctl_quietmode
+            ;;
+        -d|--device)
+            _smartctl_device
+            return 0
+            ;;
+        -t|--tolerance)
+            _smartctl_tolerance
+            return 0
+            ;;
+        -b|--badsum)
+            _smartctl_badsum
+            return 0
+            ;;
+        -r|--report)
+            _smartctl_report
+            return 0
+            ;;
+        -n|--nocheck)
+            _smartctl_powermode
+            return 0
+            ;;
+        -s|--smart|-o|--offlineauto|-S|--saveauto)
+            _smartctl_feature
+            return 0
+            ;;
+        -l|--log)
+            _smartctl_log
+            return 0
+            ;;
+        -v|--vendorattribute)
+            _smartctl_vendorattribute
+            return 0
+            ;;
+        -F|--firmwarebug)
+            _smartctl_firmwarebug
+            return 0
+            ;;
+        -P|--presets)
+            _smartctl_presets
+            return 0
+            ;;
+        -t|--test)
+            _smartctl_test
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --version --info --all --quietmode \
+            --device --tolerance --badsum --report --nocheck --smart \
+            --offlineauto --saveauto --health --capabilities --attributes \
+            --log --vendorattribute --firmwarebug --presets --test --captive \
+            --abort' -- "$cur" ) )
+    else
+        cur=${cur:=/dev/}
+        _filedir
+    fi
+}
+complete -F _smartctl smartctl
+}
+
+# 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
diff --git a/.bash/bash_completion.d/snownews b/.bash/bash_completion.d/snownews
new file mode 100644 (file)
index 0000000..9c99ed7
--- /dev/null
@@ -0,0 +1,25 @@
+# snownews(1) completion
+
+have snownews &&
+_snownews()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        # return list of available options
+        COMPREPLY=( $( compgen -W '--update --help --version \
+            --disable-versioncheck -u -h -V' -- "$cur"))
+    fi
+} &&
+complete -F _snownews snownews
+
+# 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
diff --git a/.bash/bash_completion.d/source-highlight b/.bash/bash_completion.d/source-highlight
new file mode 100644 (file)
index 0000000..c33604b
--- /dev/null
@@ -0,0 +1,52 @@
+# completion for source-highlight
+# by Tiziano Muller, dev-zero
+
+_source_highlight()
+{
+    local cur prev opts 
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    opts="-h --help -V --version -i --input -o --output -s --src-lang \
+    --lang-list --outlang-list -f --out-format -d --doc --no-doc -c --css \
+    -T --title -t --tab -H --header -F --footer --style-file --outlang-def \
+    --outlang-map --data-dir --output-dir --lang-def --lang-map --show-lang-elements \
+    --infer-lang -n --line-number --line-number-ref --line-range --range-separator --range-context --regex-range --gen-references --ctags-file \
+    --ctags -v --verbose --statistics --gen-version --check-lang --check-outlang \
+    --failsafe -g --debug-langdef --show-regex"
+
+    if [[ "${cur}" == -* || ${COMP_CWORD} -eq 1 ]] ; then
+       COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
+       return 0
+    fi
+
+    case "${prev}" in
+       -T|--title|-t|--tab|--gen-references|--line-range|--range-separator|--range-context|--regex-range)
+           COMPREPLY=()
+           ;;
+       -i|--input|-o|--output|-c|--css|-H|--header|-F|--footer|--style-file|--outlang-def|--outlang-map|--lang-def|--lang-map|--show-lang-elements|--ctags-file|--check-lang|--check-outlang|--show-regex)
+           COMPREPLY=($(compgen -A file -- "${cur}"))
+           ;;
+       -s|--src-lang)
+           COMPREPLY=($(compgen -W "C H ac ada am applescript asm autoconf awk bat bib bison c caml cc changelog clipper cls cobol conf cpp cs csh csharp css \
+               d diff docbook dtx el eps erlang fixed-fortran flex fortran free-fortran glsl h haskell haxe hh hpp htm html hx in ini islisp java javalog javascript js kcfg kdevelop kidl ksh l lang \
+               langdef latex ldap ldif lex lgt lilypond lisp ll log logtalk lsm lua m4 manifest ml mli moc opa outlang oz pas pascal patch pc perl php php3 php4 php5 \
+               pl pm po pot postscript prolog properties proto ps py python rb rc ruby scala scheme sh shell sig sl slang slsh sml spec sql sty style syslog tcl tcsh texinfo \
+               tex tk tml txt ui upc vala vbscript xhtml xml xorg y yacc yy" -- "${cur}"))
+           ;;
+       -f|--out-format)
+           COMPREPLY=($(compgen -W "docbook esc html html-css htmltable\
+           javadoc latex latexcolor odf texinfo xhtml xhtml-css xhtmltable" -- "${cur}"))
+           ;;
+       --data-dir|--output-dir)
+           COMPREPLY=($(compgen -A directory -- "${cur}"))
+           ;;
+       *)
+           COMPREPLY=($(compgen -W "${opts/${preprev}}" -- "${cur}"))
+           ;;
+    esac
+}
+complete -F _source_highlight source-highlight
+
+# vim: set ft=sh tw=80 sw=4 et :
diff --git a/.bash/bash_completion.d/sqlite3 b/.bash/bash_completion.d/sqlite3
new file mode 100644 (file)
index 0000000..b37c55f
--- /dev/null
@@ -0,0 +1,39 @@
+# sqlite3(1) completion
+
+have sqlite3 &&
+_sqlite3()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    local dbexts='@(sqlite?(3)|?(s?(3))db)'
+
+    case $prev in
+        -help|-version|-separator|-nullvalue|*.$dbexts)
+            return 0
+            ;;
+        -init)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-help -init -echo -header -noheader -bail
+            -interactive -batch -column -csv -html -line -list -separator
+            -nullvalue -version' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir $dbexts
+} &&
+complete -F _sqlite3 sqlite3
+
+# 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
diff --git a/.bash/bash_completion.d/ssh b/.bash/bash_completion.d/ssh
new file mode 100644 (file)
index 0000000..cf966ae
--- /dev/null
@@ -0,0 +1,428 @@
+# ssh(1) completion
+
+have ssh &&
+{
+
+_ssh_bindaddress()
+{
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
+        "$( PATH="$PATH:/sbin" ifconfig -a | \
+        sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \
+            -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \
+        -- "$cur" ) )
+}
+
+_ssh_ciphers()
+{
+    COMPREPLY=( "${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=( "${COMPREPLY[@]}" $( compgen -W 'hmac-md5 hmac-sha1 \
+        umac-64@openssh.com hmac-ripemd160 hmac-sha1-96 hmac-md5-96' \
+        -- "$cur" ) )
+}
+
+_ssh_options()
+{
+    type compopt &>/dev/null && compopt -o nospace
+    COMPREPLY=( $( compgen -S = -W 'AddressFamily BatchMode BindAddress \
+        ChallengeResponseAuthentication CheckHostIP Cipher Ciphers \
+        ClearAllForwardings Compression CompressionLevel ConnectionAttempts \
+        ConnectTimeout ControlMaster ControlPath DynamicForward EscapeChar \
+        ExitOnForwardFailure ForwardAgent ForwardX11 ForwardX11Trusted \
+        GatewayPorts GlobalKnownHostsFile GSSAPIAuthentication \
+        GSSAPIDelegateCredentials HashKnownHosts Host HostbasedAuthentication \
+        HostKeyAlgorithms HostKeyAlias HostName IdentityFile IdentitiesOnly \
+        KbdInteractiveDevices LocalCommand LocalForward LogLevel MACs \
+        NoHostAuthenticationForLocalhost NumberOfPasswordPrompts \
+        PasswordAuthentication PermitLocalCommand Port \
+        PreferredAuthentications Protocol ProxyCommand PubkeyAuthentication \
+        RekeyLimit RemoteForward RhostsRSAAuthentication RSAAuthentication \
+        SendEnv ServerAliveInterval ServerAliveCountMax 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|Compression|ExitOnForwardFailure|ForwardAgent|\
+        ForwardX11|ForwardX11Trusted|GatewayPorts|GSSAPIAuthentication|\
+        GSSAPIKeyExchange|GSSAPIDelegateCredentials|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)
+            _ssh_bindaddress
+            ;;
+        Cipher)
+            COMPREPLY=( $( compgen -W 'blowfish des 3des' -- "$cur" ) )
+            ;;
+        Protocol)
+            COMPREPLY=( $( compgen -W '1 2 1,2 2,1' -- "$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 configfile
+    local -a config
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+    #cur=`_get_cword :`
+    #prev=`_get_pword`
+
+    _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)
+            _ssh_options
+            return 0
+            ;;
+        -w)
+            _available_interfaces
+            return 0
+            ;;
+        -b)
+            _ssh_bindaddress
+            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 '-1 -2 -4 -6 -A -a -C -f -g -K -k -M \
+            -N -n -q -s -T -t -V -v -X -v -Y -y -b -b -c -D -e -F \
+            -i -L -l -m -O -o -p -R -S -w' -- "$cur" ) )
+    else
+        # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
+        set -- "${COMP_WORDS[@]}"
+        while [ $# -gt 0 ]; do
+            if [ "${1:0:2}" = -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 [ $COMP_CWORD -ne 1 ]; then
+            _compopt_o_filenames
+            COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- "$cur" ) )
+        fi
+    fi
+
+    return 0
+}
+shopt -u hostcomplete && complete -F _ssh ssh slogin autossh
+
+# sftp(1) completion
+#
+_sftp()
+{
+    local cur prev configfile
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    _ssh_suboption_check && return 0
+
+    case $prev in
+        -b|-F|-P)
+            _filedir
+            return 0
+            ;;
+        -o)
+            _ssh_options
+            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 '-1 -C -v -B -b -F -o -P -R -S -s' \
+            -- "$cur" ) )
+    else
+        # Search COMP_WORDS for '-F configfile' argument
+        set -- "${COMP_WORDS[@]}"
+        while [ $# -gt 0 ]; do
+            if [ "${1:0:2}" = -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 -aF1d "$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 -aF1d "$path*" 2>/dev/null | \
+            sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \
+            -e 's/[^\/]$/& /g' )
+    fi
+    COMPREPLY=( "${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=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | \
+            sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") )
+    else
+        COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $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 configfile cur prev prefix
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+
+    _ssh_suboption_check && {
+        COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+        return 0
+    }
+
+    case $prev in
+        -l|-P)
+            return 0
+            ;;
+        -F|-i|-S)
+            _filedir
+            type compopt &>/dev/null && compopt +o nospace
+            return 0
+            ;;
+        -c)
+            _ssh_ciphers
+            COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+            return 0
+            ;;
+        -o)
+            _ssh_options
+            return 0
+            ;;
+    esac
+
+    _expand || return 0
+
+    if [[ "$cur" == *:* ]]; then
+        _scp_remote_files
+        return 0
+    fi
+
+    if [[ "$cur" == -F* ]]; then
+        cur=${cur#-F}
+        prefix=-F
+    else
+        # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
+        set -- "${COMP_WORDS[@]}"
+        while [ $# -gt 0 ]; do
+            if [ "${1:0:2}" = -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 '-1 -2 -4 -6 -B -C -c -F -i -l -o \
+                    -P -p -q -r -S -v' -- "$cur" ) )
+                COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+                return 0
+                ;;
+            */*)
+                # pass through
+                ;;
+            *)
+                _known_hosts_real -c -a -F "$configfile" "$cur"
+                ;;
+        esac
+    fi
+
+    _scp_local_files "$prefix"
+
+    return 0
+}
+complete -F _scp -o nospace scp
+
+# ssh-copy-id(1) completion
+#
+_ssh_copy_id()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -i)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-i' -- "$cur" ) )
+    else
+        _known_hosts_real -a "$cur"
+    fi
+
+    return 0
+}
+complete -F _ssh_copy_id ssh-copy-id
+}
+
+# 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
diff --git a/.bash/bash_completion.d/sshfs b/.bash/bash_completion.d/sshfs
new file mode 100644 (file)
index 0000000..d7945f8
--- /dev/null
@@ -0,0 +1,34 @@
+# sshfs(1) completion
+
+have sshfs &&
+_sshfs()
+{
+    local cur userhost path
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur
+
+    _expand || return 0
+
+    if [[ "$cur" == *:* ]] && type _scp_remote_files &>/dev/null ; then
+        _scp_remote_files -d
+        # unlike scp and rsync, sshfs works with 1 backslash instead of 3
+        COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" )
+        return 0
+    fi
+
+    [[ "$cur" == */* ]] || _known_hosts_real -c -a "$cur"
+
+    type _scp_local_files &>/dev/null && _scp_local_files -d
+
+    return 0
+} &&
+complete -F _sshfs -o nospace sshfs
+
+# 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
diff --git a/.bash/bash_completion.d/strace b/.bash/bash_completion.d/strace
new file mode 100644 (file)
index 0000000..0ee2737
--- /dev/null
@@ -0,0 +1,103 @@
+# bash completion for strace
+
+have strace &&
+_strace()
+{
+    local cur prev offset i syscalls arch unistd
+
+    # check if we're still completing strace
+    offset=0
+    for (( i=1; i <= COMP_CWORD; i++ )); do
+        case ${COMP_WORDS[$i]} in
+            -o|-e|-p)
+                i=$((i+1))
+                continue
+                ;;
+            -*)
+                continue
+                ;;
+        esac
+        offset=$i
+        break
+    done
+
+    if [ $offset -gt 0 ]; then
+        # FAIL: _command_offset is not defined anywhere. Guillame?
+        _command_offset $offset
+    else
+
+        COMPREPLY=()
+        _get_comp_words_by_ref cur prev
+
+        case $prev in
+            -e)
+                if [[ "$cur" == *=* ]]; then
+                    prev=${cur/=*/}
+                    cur=${cur/*=/}
+
+                    # Import arch-specific syscalls -- not foolproof IMHO
+                    #+                                     --David Paleino
+                    arch=$(command uname -m)
+                    syscalls=$(awk '/^#define __NR/ {print $2}' \
+                        /usr/include/asm/unistd.h | sed -e \
+                        's/__NR_//')
+                    if [ -z "$syscalls" ]; then
+                        if [[ "$arch" == *86 ]]; then
+                            unistd=/usr/include/asm/unistd_32.h
+                        else
+                            unistd=/usr/include/asm/unistd_64.h
+                        fi
+                        syscalls=$(awk '/^#define __NR/ {print $2}' \
+                            $unistd | sed -e 's/__NR_//')
+                    fi
+
+                    case $prev in
+                        trace)
+                            COMPREPLY=( $( compgen -W "$syscalls file process
+                                network signal ipc desc all none" -- "$cur") )
+                            return 0
+                            ;;
+                    esac
+                else
+                    COMPREPLY=( $( compgen -S"=" -W 'trace abbrev verbose raw
+                        signal read write' -- "$cur" ) )
+                fi
+                return 0
+                ;;
+            -o)
+                _filedir
+                return 0
+                ;;
+            -p)
+                _pids
+                return 0
+                ;;
+            -S)
+                COMPREPLY=( $( compgen -W 'time calls name nothing' \
+                    -- "$cur" ) )
+                return 0
+                ;;
+            -u)
+                _allowed_users
+                return 0
+                ;;
+        esac
+
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '-c -d -f -ff -F --help -i -q \
+                -r -t -tt -ttt -T -v -V -x -xx -a -e -o -O -p \
+                -s -S -u -E' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -c -- "$cur" ) )
+        fi
+    fi
+} &&
+complete -F _strace -o default strace
+
+# 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
diff --git a/.bash/bash_completion.d/svk b/.bash/bash_completion.d/svk
new file mode 100644 (file)
index 0000000..bda5997
--- /dev/null
@@ -0,0 +1,225 @@
+# svk(1) completion
+
+have svk &&
+_svk()
+{
+    local cur prev commands options command
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    commands='add admin annotate ann blame praise cat checkout co cleanup \
+        cmerge cm commit ci copy cp delete del remove rm depotmap \
+        depot describe desc diff di help h ? import info list ls log \
+        merge mirror mi mkdir move mv ren rename patch propdel pd pdel \
+        propedit pe pedit propget pg pget proplist pl plist propset ps \
+        pset pull push resolved revert smerge sm status st stat switch \
+        sw sync sy update up verify'
+
+    if [[ $COMP_CWORD -eq 1 ]] ; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--version' -- "$cur" ) )
+        else
+            COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
+        fi
+    else
+        case $prev in
+            -F|--file|--targets)
+                _filedir
+                return 0;
+                ;;
+            --encoding)
+                COMPREPLY=( $( compgen -W \
+                    '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) )
+                return 0;
+                ;;
+        esac
+
+        command=${COMP_WORDS[1]}
+
+        if [[ "$cur" == -* ]]; then
+            # possible options for the command
+            case $command in
+                add)
+                    options=' --non-recursive -N -q --quiet'
+                    ;;
+                blame|annotate|ann|praise)
+                    options='-r --revisions -x --cross'
+                    ;;
+                cat)
+                    options='-r --revision'
+                    ;;
+                checkout|co)
+                    options='-r --revision -q --quiet -N --non-recursive -l \
+                        --list -d --detach --export --relocate --purge'
+                    ;;
+                cleanup)
+                    options='-a --all'
+                    ;;
+                cmerge|cm)
+                    options='-c --change -l --log -r --revision -a --auto \
+                        --verbatim --no-ticket -m --message -F --file \
+                        --template --encoding -P --patch -S --sign -C \
+                        --check-only --direct'
+                    ;;
+                commit|ci)
+                    options='--import -m --message -F --file --encoding \
+                        --template -P --patch -S --sign -C --check-only -N \
+                        --non-recursive --direct'
+                    ;;
+                copy|cp)
+                    options='-r --revision -p --parent -q --quiet -m --message \
+                        -F --file --template --encoding -P --patch -S --sign \
+                        -C --check-only --direct'
+                    ;;
+                delete|del|remove|rm)
+                    options='-k --keep-local -m --message -F --file --encoding \
+                        --template -P --patch -S --sign -C --check-only \
+                        --direct'
+                    ;;
+                depotmap|depot)
+                    options='-i --init -l --list -d --detach --relocate'
+                    ;;
+                diff|di)
+                    options='-r --revision -s --summarize -b --verbose -N \
+                        --non-recursive'
+                    ;;
+                import)
+                    options='-f --from-checkout -t --to-checkout -m --message \
+                        -F --file --template --encoding -P --patch -S --sign \
+                        -C --check-only -N --non-recursive --direct'
+                    ;;
+                list|ls)
+                    options='-r --revision -v --verbose -R --recursive -d \
+                        --depth -f --full-path'
+                    ;;
+                log)
+                    options='-r --revision -l --limit -q --quiet -x --cross \
+                        -v --verbose'
+                    ;;
+                merge)
+                    options='-r --revision -c --change -I --incremental -a \
+                        --auto -l --log -s --sync -t --to -f --from \
+                        --verbatim --no-ticket --track-rename -m --message \
+                        -F --file --template --encoding -P --patch -S --sign \
+                        -C --check-only --direct'
+                    ;;
+                mirror|mi)
+                    options='-l --list -d --detach --relocate --recover \
+                        --unlock --upgrade'
+                    ;;
+                mkdir)
+                    options='-p --parent -m --message -F --file --template \
+                        --encoding -P --patch -S --sign -C --check-only \
+                        --direct'
+                    ;;
+                move|mv|rename|ren)
+                    options='-r --revision -p --parent -q --quiet -m \
+                        --message -F --file --encoding --template -P --patch \
+                        -S --sign -C --check-only --direct'
+                    ;;
+                patch)
+                    options='--depot'
+                    ;;
+                propdel|propset|pdel|pset|pd|ps)
+                    options='-R --recursive -r --revision --revprop -m \
+                        --message -F --file --template --encoding -P --patch \
+                        -S --sign -C --check-only -q --quiet --direct'
+                    ;;
+                propedit|pedit|pe)
+                    options='-R --recursive -r --revision --revprop -m \
+                        --message -F --file --template --encoding -P --patch \
+                        -S --sign -C --check-only --direct'
+                    ;;
+                propget|pget|pg)
+                    options='-R --recursive -r --revision --revprop --strict'
+                    ;;
+                proplist|plist|pl)
+                    options='-R --recursive -v --verbose \
+                        -r --revision --revprop'
+                    ;;
+                pull)
+                    options='-a --all -l --lump'
+                    ;;
+                push)
+                    options='-f --from -l --lump -C --check -P --patch -S \
+                        --sign --verbatim'
+                    ;;
+                resolved)
+                    options='-R --recursive'
+                    ;;
+                revert)
+                    options='-R --recursive -q --quiet'
+                    ;;
+                smerge|sm)
+                    options='-I --incremental -l --log -B --baseless -b \
+                        --base -s --sync -t --to -f --from --verbatim \
+                        --no-ticket --track-rename --host --remoterev -m \
+                        --message -F --file --template --encoding -P --patch \
+                        -S --sign -C --check-only --direct'
+                    ;;
+                status|stat|st)
+                    options='-q --quiet --no-ignore -N --non-recursive -v \
+                        --verbose'
+                    ;;
+                switch|sw)
+                    options='-r --revision -d --detach -q --quiet'
+                    ;;
+                sync|sy)
+                    options='-a --all -s --skipto -t --torev'
+                    ;;
+                update|up)
+                    options='-r --revision -N --non-recursive -C --check-only \
+                        -s --sync -m --merge -q --quiet'
+                    ;;
+            esac
+            options="$options --help -h"
+
+            COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+        else
+            case $command in
+                help|h|\?)
+                    COMPREPLY=( $( compgen -W "$commands \
+                        environment commands intro" -- "$cur" ) )
+                    ;;
+                admin)
+                    COMPREPLY=( $( compgen -W 'help deltify dump hotcopy \
+                        list-dblogs list-unused-dblogs load lstxns recover \
+                        rmtxns setlog verify rmcache' -- "$cur" ) )
+                    ;;
+                patch)
+                    COMPREPLY=( $( compgen -W '--ls --list --cat --view \
+                        --regen --regenerate --up --update --apply --rm \
+                        --delete' -- "$cur" ) )
+                    ;;
+                sync)
+                    COMPREPLY=( $( compgen -W "$( svk mirror --list \
+                        2>/dev/null | awk '/^\//{print $1}' )" -- "$cur" ) )
+                    ;;
+                co|checkout|push|pull)
+                    if [[ "$cur" == //*/* ]]; then
+                        path=${cur%/*}/
+                    else
+                        path=//
+                    fi
+                    COMPREPLY=( $( compgen -W "$( svk list $path 2>/dev/null | \
+                        sed -e 's|\(.*\)|'$path'\1|')" -- "$cur" ) )
+                    ;;
+                *)
+                    _filedir
+                    ;;
+            esac
+        fi
+    fi
+
+    return 0
+} &&
+complete -F _svk svk
+
+# 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
diff --git a/.bash/bash_completion.d/sysbench b/.bash/bash_completion.d/sysbench
new file mode 100644 (file)
index 0000000..3b309a9
--- /dev/null
@@ -0,0 +1,175 @@
+# bash completion for sysbench
+
+# We set -o nospace and turn it off in quite a few places for bash < 4
+# reasons; assuming bash >= 4 we could instead not turn it on
+# initially but only in the few cases where it's actually needed.
+
+have sysbench &&
+_sysbench()
+{
+    COMPREPLY=()
+    local cur prev words split=false
+    _get_comp_words_by_ref -n = cur prev words
+
+    # long options need the "=" (whitespace split doesn't work), but we split
+    # internally to make processing easier
+    _split_longopt && split=true
+
+    case $prev in
+        --num-threads|--max-requests|--max-time|--thread-stack-size| \
+        --help|--version|help|version)
+            return 0
+            ;;
+        --init-rng|--debug|--validate)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+            return 0
+            ;;
+        --test)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'fileio cpu memory threads mutex oltp' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        --cpu-max-prime)
+            return 0
+            ;;
+        --file-test-mode)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        --file-io-mode)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'sync async fastmmap slowmmap' \
+                -- "$cur" ) )
+            return 0
+            ;;
+        --file-extra-flags)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'sync dsync direct' -- "$cur" ) )
+            return 0
+            ;;
+        --file-fsync-all|--file-fsync-end)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+            return 0
+            ;;
+        --file-fsync-mode)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'fsync fdatasync' -- "$cur" ) )
+            return 0
+            ;;
+        --memory-scope)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'global local' -- "$cur" ) )
+            return 0
+            ;;
+        --memory-hugetlb)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+            return 0
+            ;;
+        --memory-oper)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'read write none' -- "$cur" ) )
+            return 0
+            ;;
+        --memory-access-mode)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'seq rnd' -- "$cur" ) )
+            return 0
+            ;;
+        --oltp-test-mode)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'simple complex nontrx sp' -- "$cur" ) )
+            return 0
+            ;;
+        --oltp-read-only|--oltp-skip-trx|--oltp-quto-inc|--mysql-ssl)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+            return 0
+            ;;
+        --oltp-nontrx-mode)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'select update_key update_nokey insert
+                delete' -- "$cur" ) )
+            return 0
+            ;;
+        --oltp-dist-type)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'uniform gaussian special' -- "$cur" ) )
+            return 0
+            ;;
+        --db-driver)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W "$( $1 --test=oltp help 2>/dev/null |
+                sed -e '/^.*database drivers:/,/^$/!d' \
+                   -ne 's/^  *\([^ ]*\) .*/\1/p' )" -- "$cur" ) )
+            return 0
+            ;;
+        --db-ps-mode)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'auto disable' -- "$cur" ) )
+            return 0
+            ;;
+        --mysql-socket)
+            compopt +o nospace &>/dev/null
+            _filedir sock
+            return 0
+            ;;
+        --mysql-table-engine)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'myisam innodb bdb heap ndbcluster
+                federated' -- "$cur" ) )
+            return 0
+            ;;
+        --mysql-engine-trx)
+            compopt +o nospace &>/dev/null
+            COMPREPLY=( $( compgen -W 'yes no auto' -- "$cur" ) )
+            return 0
+            ;;
+        --*)
+            $split && return 0
+            ;;
+    esac
+
+    # find out which test we're running
+    local i test
+    for (( i=1 ; $i < ${#words[@]}-1 ; i++ )); do
+        if [[ ${words[i]} == --test* ]]; then
+            test=${words[i]#*=}
+            break
+        fi
+    done
+
+    local opts="--num-threads= --max-requests= --max-time= --thread-stack-size=
+        --init-rng= --debug= --validate= --help --version"
+
+    if [[ $test ]]; then
+        local help=( $( _parse_help $1 "--test=$test help" ) )
+        opts="$opts ${help[@]/%/=} prepare run cleanup help version"
+    else
+        opts="$opts --test="
+    fi
+
+    if [[ "$cur" == -* || ! $test ]]; then
+        COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
+        [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \
+            compopt +o nospace &>/dev/null
+    else
+        compopt +o nospace &>/dev/null
+        COMPREPLY=( $( compgen -W "prepare run cleanup help version" \
+            -- "$cur" ) )
+    fi
+} &&
+complete -F _sysbench -o nospace sysbench
+
+# 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
diff --git a/.bash/bash_completion.d/sysctl b/.bash/bash_completion.d/sysctl
new file mode 100644 (file)
index 0000000..ac25f4e
--- /dev/null
@@ -0,0 +1,24 @@
+# bash completion for sysctl
+
+have sysctl &&
+_sysctl()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    COMPREPLY=( $( compgen -W \
+        "$( PATH="$PATH:/sbin" sysctl -N -a 2>/dev/null )" -- "$cur" ) )
+
+    return 0
+} &&
+complete -F _sysctl sysctl
+
+# 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
diff --git a/.bash/bash_completion.d/sysv-rc b/.bash/bash_completion.d/sysv-rc
new file mode 100644 (file)
index 0000000..735a404
--- /dev/null
@@ -0,0 +1,110 @@
+# update-rc.d(8) completion
+#
+# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
+
+have update-rc.d &&
+_update_rc_d()
+{
+    local cur prev sysvdir services options valid_options
+
+    _get_comp_words_by_ref cur prev
+
+    [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
+    || sysvdir=/etc/init.d
+
+    services=( $(printf '%s ' $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm@(orig|new|save))) )
+    services=( ${services[@]#$sysvdir/} )
+    options=( -f -n )
+
+    if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
+    valid_options=( $( \
+        tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \
+        | sed -ne "/$( sed "s/ /\\|/g" <<<"${options[@]}" )/p" \
+        | sort | uniq -u \
+        ) )
+    COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
+        -X '$( tr " " "|" <<<${COMP_WORDS[@]} )' -- "$cur" ) )
+    elif [[ "$prev" == ?($( tr " " "|" <<<${services[@]} )) ]]; then
+        COMPREPLY=( $( compgen -W 'remove defaults start stop' -- "$cur" ) )
+    elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
+        COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
+    elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
+        COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
+    elif [[ "$prev" == defaults && -z "$cur" ]]; then
+        COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k )
+    elif [[ "$prev" == ?(start|stop) ]]; then
+        if [[ "$cur" == [0-9] || -z "$cur" ]]; then
+            COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
+        elif [[ "$cur" == [0-9][0-9] ]]; then
+            COMPREPLY=( $cur )
+        else
+            COMPREPLY=()
+        fi
+    elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
+        if [[ -z "$cur" ]]; then
+            if [[ $prev == [0-9][0-9] ]]; then
+                COMPREPLY=( 0 1 2 3 4 5 6 S )
+            else
+                COMPREPLY=( 0 1 2 3 4 5 6 S . )
+            fi
+        elif [[ "$cur" == [0-6S.] ]]; then
+            COMPREPLY=( $cur )
+        else
+            COMPREPLY=()
+        fi
+    elif [[ "$prev" == "." ]]; then
+        COMPREPLY=( $(compgen -W "start stop" -- "$cur") )
+    else
+        COMPREPLY=()
+    fi
+
+    return 0
+} &&
+complete -F _update_rc_d update-rc.d
+
+# invoke-rc.d(8) completion
+#
+# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
+#
+have invoke-rc.d &&
+_invoke_rc_d()
+{
+    local cur prev sysvdir services options valid_options
+
+    _get_comp_words_by_ref cur prev
+
+    [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
+    || sysvdir=/etc/init.d
+
+    services=( $( printf '%s ' \
+        $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm@(orig|new|save)) ) )
+    services=( ${services[@]#$sysvdir/} )
+    options=( --help --quiet --force --try-anyway --disclose-deny --query \
+        --no-fallback )
+
+    if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
+    valid_options=( $( \
+        tr " " "\n" <<<"${COMP_WORDS[@]} ${options[@]}" \
+        | sed -ne "/$( sed "s/ /\\\\|/g" <<<"${options[@]}" )/p" \
+        | sort | uniq -u \
+        ) )
+    COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) )
+    elif [ -x $sysvdir/$prev ]; then
+        COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
+            -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
+            $sysvdir/$prev`' -- "$cur" ) )
+    else
+        COMPREPLY=()
+    fi
+
+    return 0
+} &&
+complete -F _invoke_rc_d invoke-rc.d
+
+# 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
diff --git a/.bash/bash_completion.d/tar b/.bash/bash_completion.d/tar
new file mode 100644 (file)
index 0000000..a5c0249
--- /dev/null
@@ -0,0 +1,72 @@
+# bash completion for GNU tar
+
+have tar && {
+_tar()
+{
+    local cur ext regex tar untar
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) )
+        return 0
+    fi
+
+    case ${COMP_WORDS[1]} in
+        ?(-)[cr]*f)
+            _filedir
+            return 0
+            ;;
+        +([^IZzJjy])f)
+            ext='@(@(tar|gem|spkg)?(.@(Z|[gx]z|bz?(2)|lzma))|t@([glx]z|bz?(2)))'
+            regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[gx]z\|bz?(2)\|lzma\)\)\?\|t\([glx]z\|bz2\?\)\)'
+            ;;
+        *[Zz]*f)
+            ext='@(t?(ar.)|gem.|spkg.)@(gz|Z)'
+            regex='\(t\(ar\.\)\?\|gem\.\|spkg\.\)\(gz\|Z\)'
+            ;;
+        *[Ijy]*f)
+            ext='@(@(t?(ar.)|gem.)bz?(2)|spkg)'
+            regex='\(\(t\(ar\.\)\?\|gem\.\)bz2\?\|spkg\)'
+            ;;
+        *[J]*f)
+            ext='@(t?(ar.)|gem.|spkg.)@(lz?(ma)|xz)'
+            regex='\(t\(ar\.\)\?\|gem\.\|spkg\.\)\(lzma\|xz\)\?'
+            ;;
+        *)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$COMP_LINE" == *$ext' ' ]]; then
+        # complete on files in tar file
+        #
+        # get name of tar file from command line
+        tar=$( sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' <<<"$COMP_LINE" )
+        # devise how to untar and list it
+        untar=t${COMP_WORDS[1]//[^Izjyf]/}
+
+        local IFS=$'\n'
+        COMPREPLY=( $( compgen -W "$( printf '%s\n' $( tar $untar $tar \
+            2>/dev/null ) )" -- "$cur" ) )
+        return 0
+    fi
+
+    # file completion on relevant files
+    _filedir "$ext"
+
+    return 0
+}
+[ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar -o dirnames tar ||
+    complete -F _tar tar
+}
+
+# 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
diff --git a/.bash/bash_completion.d/tcpdump b/.bash/bash_completion.d/tcpdump
new file mode 100644 (file)
index 0000000..259f13e
--- /dev/null
@@ -0,0 +1,37 @@
+# bash completion for tcpdump
+
+have tcpdump &&
+_tcpdump()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -r|-w|-F)
+            _filedir
+            return 0
+            ;;
+        -i)
+            _available_interfaces -a
+            return 0
+            ;;
+    esac
+
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-a -d -e -f -l -n -N -O -p \
+            -q -R -S -t -u -v -x -C -F -i -m -r -s -T -w -E' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _tcpdump tcpdump
+
+# 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
diff --git a/.bash/bash_completion.d/unace b/.bash/bash_completion.d/unace
new file mode 100644 (file)
index 0000000..9d27ef5
--- /dev/null
@@ -0,0 +1,29 @@
+# unace(1) completion
+
+have unace &&
+_unace()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur" ) )
+    else
+        if [ $COMP_CWORD -eq 1 ]; then
+            COMPREPLY=( $( compgen -W 'e l t v x' -- "$cur" ) )
+        else
+            _filedir ace
+        fi
+    fi
+} &&
+complete -F _unace unace
+
+# 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
diff --git a/.bash/bash_completion.d/unrar b/.bash/bash_completion.d/unrar
new file mode 100644 (file)
index 0000000..0a4fe27
--- /dev/null
@@ -0,0 +1,32 @@
+# unrar(1) completion
+
+have unrar &&
+_unrar()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu \
+            -dh -ep -f -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta \
+            -tb -tn -to -u -v -ver -vp -x -x@ -y' -- "$cur" ) )
+    else
+        if [ $COMP_CWORD -eq 1 ]; then
+            COMPREPLY=( $( compgen -W 'e l lb lt p t v vb vt x' -- "$cur" ) )
+        else
+            _filedir rar
+        fi
+    fi
+
+} &&
+complete -F _unrar unrar
+
+# 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
diff --git a/.bash/bash_completion.d/update-alternatives b/.bash/bash_completion.d/update-alternatives
new file mode 100644 (file)
index 0000000..ebed294
--- /dev/null
@@ -0,0 +1,100 @@
+# bash completion for update-alternatives
+
+have update-alternatives && {
+_installed_alternatives()
+{
+    local admindir
+    # find the admin dir
+    for i in alternatives dpkg/alternatives rpm/alternatives; do
+        [ -d /var/lib/$i ] && admindir=/var/lib/$i && break
+    done
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == --admindir ]]; then
+            admindir=${COMP_WORDS[i+1]}
+            break
+        fi
+    done
+    COMPREPLY=( $( compgen -W '$( command ls $admindir )' -- "$cur" ) )
+}
+
+_update_alternatives()
+{
+    local cur prev mode args i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --altdir|--admindir)
+            _filedir -d
+            return 0
+            ;;
+        --help|--usage|--version)
+            return 0
+            ;;
+    esac
+
+    # find which mode to use and how many real args used so far
+    for (( i=1; i < COMP_CWORD; i++ )); do
+        if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then
+            mode=${COMP_WORDS[i]}
+            args=$(($COMP_CWORD - i))
+            break
+        fi
+    done
+
+    case $mode in
+        --install)
+            case $args in
+                1|3)
+                    _filedir
+                    ;;
+                2)
+                    _installed_alternatives
+                    ;;
+                4)
+                    # priority - no completions
+                    ;;
+                *)
+                    case $((args % 4)) in
+                        0|2)
+                            _filedir
+                            ;;
+                        1)
+                            COMPREPLY=( $( compgen -W '--slave' -- "$cur" ) )
+                            ;;
+                        3)
+                            _installed_alternatives
+                            ;;
+                    esac
+            esac
+            ;;
+        --remove|--set)
+            case $args in
+                1)
+                    _installed_alternatives
+                    ;;
+                2)
+                    _filedir
+                    ;;
+            esac
+            ;;
+        --auto|--remove-all|--display|--config)
+            _installed_alternatives
+            ;;
+        *)
+            COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
+                --altdir --admindir --install --remove --auto --display \
+                --config --set' -- "$cur" ) )
+    esac
+}
+complete -F _update_alternatives update-alternatives alternatives
+}
+
+# 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
diff --git a/.bash/bash_completion.d/util-linux b/.bash/bash_completion.d/util-linux
new file mode 100644 (file)
index 0000000..f45ffd5
--- /dev/null
@@ -0,0 +1,76 @@
+# Completions for tools included in util-linux (not necessarily Linux specific)
+
+# renice(8) completion
+#
+have renice &&
+_renice()
+{
+    local command cur curopt i
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+    command=$1
+
+    i=0
+    # walk back through command line and find last option
+    while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do
+        curopt=${COMP_WORDS[COMP_CWORD-$i]}
+        case "$curopt" in
+            -u)
+                _allowed_users
+                ;;
+            -g)
+                _pgids
+                ;;
+            -p|$command)
+                _pids
+                ;;
+        esac
+        i=$(( ++i ))
+    done
+} &&
+complete -F _renice renice
+
+# kill(1) completion
+#
+have kill &&
+_kill()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then
+        # return list of available signals
+        _signals
+    else
+        # return list of available PIDs
+        _pids
+    fi
+} &&
+complete -F _kill kill
+
+# look(1) completion
+#
+have look &&
+_look()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [ $COMP_CWORD = 1 ]; then
+        COMPREPLY=( $( compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur" ) )
+    fi
+} &&
+complete -F _look -o default look
+
+# 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
diff --git a/.bash/bash_completion.d/vim-completion b/.bash/bash_completion.d/vim-completion
new file mode 100644 (file)
index 0000000..157b546
--- /dev/null
@@ -0,0 +1,36 @@
+# Author: Ciaran McCreesh <ciaranm@gentoo.org>
+#
+# completion for vim
+
+_vim()
+{
+    local cur prev cmd args
+
+    COMPREPLY=()
+    cur=${COMP_WORDS[COMP_CWORD]}
+    prev=${COMP_WORDS[COMP_CWORD-1]}
+    cmd=${COMP_WORDS[0]}
+
+    if [[ "${prev}" == "--servername" ]] ; then
+        local servers
+        servers=$(gvim --serverlist )
+        COMPREPLY=( $( compgen -W "${servers}" -- $cur ) )
+
+    elif [[ "${prev}" == -[uUi] ]] ; then
+        COMPREPLY=( $( compgen -W "NONE" ) \
+                $( compgen -f -X "!*vim*" -- "$cur" ) )
+
+    elif [[ "${cur}" == -* ]] ; then
+        args='-t -q -c -S --cmd -A -b -C -d -D -e -E -f --nofork \
+            -F -g -h -H -i -L -l -m -M -N -n -nb -o -R -r -s \
+            -T -u -U -V -v -w -W -x -X -y -Y -Z --echo-wid \
+            --help --literal --noplugin --version'
+        COMPREPLY=( $( compgen -W "${args}" -- $cur ) )
+    else
+        _filedir
+    fi
+}
+
+complete -o filenames -F _vim vim ex view evim rvim rview
+
+# vim: set ft=sh sw=4 et sts=4 :
diff --git a/.bash/bash_completion.d/vncviewer b/.bash/bash_completion.d/vncviewer
new file mode 100644 (file)
index 0000000..296eb8a
--- /dev/null
@@ -0,0 +1,130 @@
+# bash completion for vncviewer
+
+have vncviewer &&
+_vncviewer_bootstrap()
+{
+    local fname
+    case $(_realcommand vncviewer) in
+        *xvnc4viewer)      fname=_xvnc4viewer    ;;
+        *tightvncviewer)   fname=_tightvncviewer ;;
+        *)                 fname=_known_hosts    ;;
+    esac
+
+    # Install real completion for subsequent completions
+    complete -F $fname vncviewer
+    $fname  # Generate completions once for now
+    unset -f _vncviewer_bootstrap
+} &&
+complete -F _vncviewer_bootstrap vncviewer
+
+have tightvncviewer &&
+_tightvncviewer()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -passwd)
+            _filedir
+            return 0
+            ;;
+        -encodings)
+            COMPREPLY=( $( compgen -W 'copyrect tight hextile zlib \
+                corre rre raw' -- "$cur" ) )
+            return 0
+            ;;
+        -via)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-help -listen -via -shared -noshared\
+            -viewonly -fullscreen -noraiseonbeep -passwd -encodings\
+            -bgr233 -owncmap -truecolour -truecolor -depth \
+            -compresslevel -quality -nojpeg -nocursorshape \
+            -x11cursor' -- $cur ) )
+    else
+        _known_hosts_real "$cur"
+    fi
+} &&
+complete -F _tightvncviewer tightvncviewer
+
+
+# NOTE: - VNC Viewer options are case insensitive.
+#         Preferred case is taken from -help.
+#       - Both single dash (-) and double dash (--) are allowed as option prefix
+have xvnc4viewer &&
+_xvnc4viewer()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    # Convert double dash to single dash
+    case ${prev/#--/-} in
+        # -passwd, -PasswordFile
+        -[pP][aA][sS][sS][wW][dD]|-[pP][aA][sS][sS][wW][oO][rR][dD][fF][iI][lL][eE])
+            _filedir
+            return 0
+            ;;
+        # -PreferredEncoding
+        -[pP][rR][eE][fF][eE][rR][rR][eE][dD][eE][nN][cC][oO][dD][iI][nN][gG])
+            COMPREPLY=( $( compgen -W 'zrle hextile raw' -- $cur ) )
+            return 0
+            ;;
+        # -via
+        -[vV][iI][aA])
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* || "$cur" == --* ]]; then
+        # Default to vncviewer camelcase options, see `vncviewer -help'
+        local dash options=( \
+            AcceptClipboard AutoSelect DebugDelay display \
+            DotWhenNoCursor FullColor FullColour FullScreen \
+            geometry help listen Log \
+            LowColourLevel MenuKey name Parent \
+            passwd PasswordFile PointerEventInterval PreferredEncoding \
+            SendClipboard SendPrimary Shared UseLocalCursor \
+            via ViewOnly WMDecorationHeight WMDecorationWidth \
+            ZlibLevel \
+        )
+        [[ "$cur" == --* ]] && dash=-- || dash=-
+        # Is a `nocasematch' variable available (bash > v3.1)?
+        if shopt nocasematch 2> /dev/null | command grep -q ^nocasematch; then
+            # Variable `nocasematch' is available
+            # Use vncviewer camelcase options
+            local option oldNoCaseMatch=$(shopt -p nocasematch)
+            shopt -s nocasematch
+            COMPREPLY=( $( for option in "${options[@]}"; do
+                [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option
+            done ) )
+            eval "$oldNoCaseMatch" 2> /dev/null
+        else
+            # Variable 'nocasematch' isn't available;
+            # Convert completions to lowercase
+            COMPREPLY=( $( compgen -W \
+                "$( tr [:upper:] [:lower:] <<<${options[@]/#/$dash} )" \
+                -- "$( tr [:upper:] [:lower:] <<<"$cur" )" ) )
+        fi
+    else
+        _known_hosts_real "$cur"
+    fi
+} &&
+complete -F _xvnc4viewer xvnc4viewer
+
+# 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
diff --git a/.bash/bash_completion.d/vpnc b/.bash/bash_completion.d/vpnc
new file mode 100644 (file)
index 0000000..722fee3
--- /dev/null
@@ -0,0 +1,49 @@
+# bash completion for vpnc
+
+have vpnc &&
+_vpnc()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --pfs)
+            COMPREPLY=( $( compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur" ) )
+            return 0
+            ;;
+        --pfs)
+            COMPREPLY=( $( compgen -W 'dh1 dh2 dh5' -- "$cur" ) )
+            return 0
+            ;;
+        --pid-file|--script)
+            _filedir
+            return 0
+            ;;
+        --gateway)
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--version --print-config --help \
+            --long-help --gateway --id --username --udp --domain \
+            --xauth-inter --script --dh --pfs --enable-1des \
+            --application-version --ifname --debug --no-detach \
+            --pid-file --local-port  --udp-port --disable-natt \
+            --non-inter' -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -W '$( command ls /etc/vpnc )' -- "$cur" ) )
+    fi
+} &&
+complete -F _vpnc vpnc
+
+# 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
diff --git a/.bash/bash_completion.d/wireless-tools b/.bash/bash_completion.d/wireless-tools
new file mode 100644 (file)
index 0000000..56ba0db
--- /dev/null
@@ -0,0 +1,180 @@
+# bash completion for Linux wireless-tools
+
+[ $UNAME = Linux ] &&
+{
+
+have iwconfig &&
+_iwconfig()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        mode)
+            COMPREPLY=( $( compgen -W 'managed ad-hoc master \
+                repeater secondary monitor' -- "$cur" ) )
+            return 0
+            ;;
+        essid)
+            COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
+            if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
+                COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
+                    "$( iwlist ${COMP_WORDS[1]} scan | \
+                    awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) )
+            fi
+            return 0
+            ;;
+        nwid)
+            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+            return 0
+            ;;
+        channel)
+            COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
+                awk '/^[ \t]*Channel/ {print $2}' )" -- "$cur" ) )
+            return 0
+            ;;
+
+        freq)
+            COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
+                awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur" ) )
+            return 0
+            ;;
+        ap)
+            COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
+            if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
+                COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
+                    "$( iwlist ${COMP_WORDS[1]} scan | \
+                    awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) )
+            fi
+            return 0
+            ;;
+        rate)
+            COMPREPLY=( $( compgen -W 'auto fixed' -- "$cur" ) )
+            COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
+                "$( iwlist ${COMP_WORDS[1]} rate | \
+                awk '/^[ \t]*[0-9]/ {print $1"M"}' )" -- "$cur" ) )
+            return 0
+            ;;
+        rts|frag)
+            COMPREPLY=( $( compgen -W 'auto fixed off' -- "$cur" ) )
+            return 0
+            ;;
+        key|enc)
+            COMPREPLY=( $( compgen -W 'off on open restricted' -- "$cur" ) )
+            return 0
+            ;;
+        power)
+            COMPREPLY=( $( compgen -W 'period timeout off on' -- "$cur" ) )
+            return 0
+            ;;
+        txpower)
+            COMPREPLY=( $( compgen -W 'off on auto' -- "$cur" ) )
+            return 0
+            ;;
+        retry)
+            COMPREPLY=( $( compgen -W 'limit lifetime' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
+        else
+            _available_interfaces -w
+        fi
+    else
+        COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \
+            ap nick rate rts frag enc key power txpower commit' -- "$cur" ) )
+    fi
+
+} &&
+complete -F _iwconfig iwconfig
+
+
+have iwlist &&
+_iwlist()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
+        else
+            _available_interfaces -w
+        fi
+    else
+        COMPREPLY=( $( compgen -W 'scan scanning freq frequency \
+            channel rate bit bitrate key enc encryption power \
+            txpower retry ap accesspoint peers event' -- "$cur" ) )
+    fi
+} &&
+complete -F _iwlist iwlist
+
+
+have iwspy &&
+_iwspy()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
+        else
+            _available_interfaces -w
+        fi
+    else
+        COMPREPLY=( $( compgen -W 'setthr getthr off' -- "$cur" ) )
+    fi
+} &&
+complete -F _iwspy iwspy
+
+
+have iwpriv &&
+_iwpriv()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        roam)
+            COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
+            return 0
+            ;;
+        port)
+            COMPREPLY=( $( compgen -W 'ad-hoc managed' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [ $COMP_CWORD -eq 1 ]; then
+        if [[ "$cur" == -* ]]; then
+            COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
+        else
+            _available_interfaces -w
+        fi
+    else
+        COMPREPLY=( $( compgen -W '--all roam port' -- "$cur" ) )
+    fi
+} &&
+complete -F _iwpriv iwpriv
+
+}
+
+# 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
diff --git a/.bash/bash_completion.d/wodim b/.bash/bash_completion.d/wodim
new file mode 100644 (file)
index 0000000..abc0ff2
--- /dev/null
@@ -0,0 +1,118 @@
+# bash completion for cdrecord/wodim
+
+# We set -o nospace and turn it off in several places for bash < 4
+# reasons; assuming bash >= 4 we could instead not turn it on
+# initially but only in the few cases where it's actually needed.
+
+have cdrecord || have wodim &&
+_cdrecord()
+{
+    local cur prev i generic_options track_options track_mode
+
+    COMPREPLY=()
+    _get_comp_words_by_ref -n = cur prev
+
+    # foo=bar style option
+    if [[ "$cur" == *=* ]]; then
+        prev=${cur%%=*}
+        cur=${cur#*=}
+        case $prev in
+            textfile|cuefile|msifile)
+                compopt +o nospace &>/dev/null
+                _filedir
+                ;;
+            blank)
+                compopt +o nospace &>/dev/null
+                COMPREPLY=( $( compgen -W 'help all fast track unreserve trtail
+                    unclose session' -- "$cur" ) )
+                ;;
+            driveropts)
+                if [[ $cur == *=* ]]; then
+                    prev=${cur%%=*}
+                    cur=${cur#*=}
+                    case $prev in
+                        varirec)
+                            compopt +o nospace &>/dev/null
+                            COMPREPLY=( $( compgen -W "-2 -1 0 1 2" \
+                                -- "$cur" ) )
+                            ;;
+                        gigarec)
+                            compopt +o nospace &>/dev/null
+                            COMPREPLY=( $( compgen -W "0.6 0.7 0.8 1.0 1.2 1.3
+                                1.4" -- "$cur" ) )
+                            ;;
+                        tattoofile)
+                            compopt +o nospace &>/dev/null
+                            _filedir
+                            ;;
+                    esac
+                else
+                    COMPREPLY=( $( compgen -W 'burnfree noburnfree varirec=
+                        gigarec= audiomaster forcespeed noforcespeed speedread
+                        nospeedread singlesession nosinglesession hidecdr
+                        nohidecdr tattooinfo tattoofile=' -- "$cur" ) )
+                    [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \
+                        compopt +o nospace &>/dev/null
+                fi
+                ;;
+            driver)
+                compopt +o nospace &>/dev/null
+                COMPREPLY=( $( compgen -W "$( $1 driver=help 2>&1 | \
+                    awk 'NR > 1 { print $1 }' ) help" -- "$cur" ) )
+                ;;
+            minbuf)
+                compopt +o nospace &>/dev/null
+                COMPREPLY=( $( compgen -W "$( seq 25 95 2>/dev/null )" \
+                    -- "$cur" ) )
+                ;;
+        esac
+        return 0
+    fi
+
+    generic_options=( -version -v -V -d -silent -force -immed -dummy -clone \
+        -dao -sao -tao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip \
+        -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive \
+        -prcap -inq -scanbus --devices -reset -abort -overburn -ignsize \
+        -useinfo -packet -noclose -text debug= kdebug= minbuf= msifile= \
+        speed= blank= fs= ts= dev= gracetime= timeout= driver= driveropts= \
+        defpregap= pktsize= mcn= textfile= cuefile= )
+    track_options=( -audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
+        -isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp \
+        -copy -nocopy -scms isrc= index= padsize= pregap= tsize= )
+    # look if previous was either a file or a track option
+    track_mode=0
+    if [ $COMP_CWORD -gt 1 ]; then
+        if [ -f "$prev" ]; then
+            track_mode=1
+        else
+            for (( i=0; i < ${#track_options[@]}; i++ )); do
+                if [[ "${track_options[i]}" == "$prev" ]]; then
+                    track_mode=1
+                    break
+                fi
+            done
+        fi
+    fi
+
+    # files are always eligible completion
+    _filedir
+    # track options are always available
+    COMPREPLY=( "${COMPREPLY[@]}" \
+        $( compgen -W '${track_options[@]}' -- "$cur" ) )
+    # general options are no more available after file or track option
+    if [ $track_mode -eq 0 ]; then
+        COMPREPLY=( "${COMPREPLY[@]}" \
+            $( compgen -W '${generic_options[@]}' -- "$cur" ) )
+    fi
+    [[ ${#COMPREPLY[@]} == 1 && ${COMPREPLY[0]} != *= ]] && \
+        compopt +o nospace &>/dev/null
+} &&
+complete -F _cdrecord -o nospace cdrecord wodim
+
+# 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
diff --git a/.bash/bash_completion.d/wol b/.bash/bash_completion.d/wol
new file mode 100644 (file)
index 0000000..89a1a8b
--- /dev/null
@@ -0,0 +1,47 @@
+# wol(1) completion
+
+have wol &&
+_wol()
+{
+    local cur prev split=false
+    COMPREPLY=()
+    _get_comp_words_by_ref -n : cur prev
+    _split_longopt && split=true
+
+    case $prev in
+        -V|--version|--help|-p|--port|--passwd|-w|--wait)
+            return 0
+            ;;
+        -h|--host|-i|--ipaddr)
+            # Broadcast addresses
+            COMPREPLY=( $( PATH=$PATH:/sbin ifconfig -a 2>/dev/null | \
+                sed -ne 's/.*[[:space:]]\{1,\}Bcast:\([^[:space:]]*\).*/\1/p' \
+                    -e 's/.*[[:space:]]\{1,\}broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' ) )
+            _known_hosts_real "$cur"
+            return 0
+            ;;
+        -f|--file)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--help --version --verbose --wait --host
+            --port --file --passwd' -- "$cur" ) )
+        return 0
+    fi
+
+    _mac_addresses
+} &&
+complete -F _wol wol
+
+# 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
diff --git a/.bash/bash_completion.d/wtf b/.bash/bash_completion.d/wtf
new file mode 100644 (file)
index 0000000..a611978
--- /dev/null
@@ -0,0 +1,36 @@
+# wtf completion
+# Raphael Droz, 25/09/2009
+
+have wtf &&
+_wtf()
+{
+    local cur prev db
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    [ "$prev" = -f ] && _filedir && return 0
+    [[ "$cur" == -* ]] && COMPREPLY=( -f ) && return 0
+
+    set -- "${COMP_WORDS[@]}"
+    while [ $# -gt 0 ]; do
+        if [ "$1" = -f ]; then
+            shift ; db=$1 ; break
+        fi
+        shift
+    done
+    [ -z $db ] && db=${ACRONYMDB:-/usr/share/misc/acronyms*}
+
+    [ ${BASH_VERSINFO[0]} -ge 4 ] && cur="${cur^^}"
+
+    COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur}" ) )
+} &&
+complete -F _wtf wtf
+
+# 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
diff --git a/.bash/bash_completion.d/wvdial b/.bash/bash_completion.d/wvdial
new file mode 100644 (file)
index 0000000..3b135f0
--- /dev/null
@@ -0,0 +1,52 @@
+# bash completion for wvdial
+
+have wvdial &&
+_wvdial()
+{
+    local cur prev config i IFS=$'\n'
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --config)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    case $cur in
+        -*)
+            COMPREPLY=( $( compgen -W '--config --chat \
+                --remotename --help --version --no-syslog' \
+                -- "$cur" ) )
+            ;;
+        *)
+            # start with global and personal config files
+            config="/etc/wvdial.conf"$'\n'"$HOME/.wvdialrc"
+            # replace with command line config file if present
+            for (( i=1; i < COMP_CWORD; i++ )); do
+                if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
+                    config=${COMP_WORDS[i+1]}
+                    break
+                fi
+            done
+            # parse config files for sections and
+            # remove default section
+            COMPREPLY=( $( sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \
+                2>/dev/null | command grep -v '^Defaults$'))
+            # escape spaces
+            COMPREPLY=${COMPREPLY// /\\ }
+            ;;
+    esac
+
+} &&
+complete -F _wvdial wvdial
+
+# 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
diff --git a/.bash/bash_completion.d/xhost b/.bash/bash_completion.d/xhost
new file mode 100644 (file)
index 0000000..cec4adc
--- /dev/null
@@ -0,0 +1,25 @@
+# xhost(1) completion
+
+have xhost &&
+_xhost ()
+{
+    local cur
+    _get_comp_words_by_ref cur
+
+    case $cur in
+        +*) _known_hosts_real -p+ "${cur:1}" ;;
+        -*) _known_hosts_real -p- "${cur:1}" ;;
+        *)  _known_hosts_real "$cur" ;;
+    esac
+
+    return 0
+} &&
+complete -F _xhost xhost
+
+# 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
diff --git a/.bash/bash_completion.d/xm b/.bash/bash_completion.d/xm
new file mode 100644 (file)
index 0000000..f9f69a2
--- /dev/null
@@ -0,0 +1,233 @@
+# bash completion for xm
+
+have xm && {
+_xen_domain_names()
+{
+    COMPREPLY=( $(compgen -W "$( xm list 2>/dev/null | \
+        awk '!/Name|Domain-0/ { print $1 }'  )" -- "$cur") )
+}
+
+_xen_domain_ids()
+{
+    COMPREPLY=( $(compgen -W "$( xm list 2>/dev/null | \
+        awk '!/Name|Domain-0/ { print $2 }' )" -- "$cur") )
+}
+
+_xm()
+{
+    # TODO: _split_longopt
+
+    local cur prev command options
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    commands='console vncviewer create new delete destroy domid domname \
+        dump-core list mem-max mem-set migrate pause reboot rename reset \
+        restore resume save shutdown start suspend sysrq trigger top unpause \
+        uptime usb-add usb-del vcpu-list vcpu-pin vcpu-set debug-keys dmesg \
+        info log serve sched-credit sched-sedf block-attach block-detach \
+        block-list block-configure network-attach network-detach network-list \
+        vtpm-list pci-attach pci-detach pci-list pci-list-assignable-devices \
+        scsi-attach scsi-detach scsi-list vnet-list vnet-create vnet-delete \
+        labels addlabel rmlabel getlabel dry-run resources dumppolicy \
+        setpolicy resetpolicy getpolicy shell help'
+
+    if [[ $COMP_CWORD -eq 1 ]] ; then
+        COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
+    else
+        if [[ "$cur" == *=* ]]; then
+            prev=${cur/=*/}
+            cur=${cur/*=/}
+        fi
+
+        command=${COMP_WORDS[1]}
+        if [[ "$cur" == -* ]]; then
+            # possible options for the command
+            case $command in
+                create)
+                    options='-c'
+                    ;;
+                dmesg)
+                    options='--clear'
+                    ;;
+                list)
+                    options='--long'
+                    ;;
+                reboot)
+                    options='-w -a'
+                    ;;
+                shutdown)
+                    options='-w -a -R -H'
+                    ;;
+                sched-credit)
+                    options='-d -w -c'
+                    ;;
+                block-list|network-list|vtpm-list|vnet-list)
+                    options='-l --long'
+                    ;;
+                getpolicy)
+                    options='--dumpxml'
+                    ;;
+                new)
+                    options='-h --help --help_config -q \
+                        --quiet --path= -f= \
+                        --defconfig= -F= --config= \
+                        -b --dryrun -x --xmldryrun \
+                        -s --skipdtd -p --paused -c \
+                        --console_autoconnect'
+                    ;;
+            esac
+            COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
+        else
+            case $command in
+                console|destroy|domname|domid|list|mem-set|mem-max| \
+                pause|reboot|rename|shutdown|unpause|vcpu-list|vcpu-pin| \
+                vcpu-set|block-list|network-list|vtpm-list)
+                    _count_args
+                    case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                    esac
+                    ;;
+                migrate)
+                    _count_args
+                        case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                        3)
+                            _known_hosts_real "$cur"
+                            ;;
+                    esac
+                    ;;
+                restore|dry-run|vnet-create)
+                    _filedir
+                    ;;
+                save)
+                    _count_args
+                    case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                        3)
+                            _filedir
+                            ;;
+                    esac
+                    ;;
+                sysrq)
+                    _count_args
+                    case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                        3)
+                            COMPREPLY=( $(compgen -W "r s e i u b" -- "$cur") )
+                            ;;
+                    esac
+                    ;;
+                block-attach)
+                    _count_args
+                    case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                        3)
+                            COMPREPLY=( $(compgen -W "phy: file:" -- "$cur") )
+                            ;;
+                        5)
+                            COMPREPLY=( $(compgen -W "w r" -- "$cur") )
+                            ;;
+                        6)
+                            _xen_domain_names
+                            ;;
+                    esac
+                    ;;
+                block-detach)
+                    _count_args
+                    case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                        3)
+                            COMPREPLY=( $(compgen -W "$( xm block-list $prev \
+                                2>/dev/null | awk '!/Vdev/ { print $1 }' )" \
+                                -- "$cur") )
+                            ;;
+                    esac
+                    ;;
+                network-attach)
+                    _count_args
+                    case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                        *)
+                            COMPREPLY=( $(compgen -W "script= ip= mac= \
+                                bridge= backend=" -- "$cur") )
+                            ;;
+                    esac
+                    ;;
+                network-detach)
+                    _count_args
+                    case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                        3)
+                            COMPREPLY=( $(compgen -W "$( xm network-list $prev \
+                                2>/dev/null | awk '!/Idx/ { print $1 }' )" \
+                                -- "$cur") )
+                            ;;
+                    esac
+                    ;;
+                sched-credit)
+                    case $prev in
+                        -d)
+                            _xen_domain_names
+                            return 0
+                            ;;
+                    esac
+                    ;;
+                create)
+                    _filedir
+                    COMPREPLY=( ${COMPREPLY[@]:-} \
+                        $( compgen -W '$( command ls /etc/xen 2>/dev/null )' \
+                        -- "$cur" ) )
+                    ;;
+                new)
+                    case $prev in
+                        -f|-F|--defconfig|--config)
+                            _filedir
+                            return 0
+                            ;;
+                        --path)
+                            _filedir -d
+                            return 0
+                            ;;
+                    esac
+
+                    _count_args
+                        case $args in
+                        2)
+                            _xen_domain_names
+                            ;;
+                    esac
+                    ;;
+            esac
+        fi
+    fi
+
+    return 0
+}
+complete -F _xm xm
+}
+
+# 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
diff --git a/.bash/bash_completion.d/xmllint b/.bash/bash_completion.d/xmllint
new file mode 100644 (file)
index 0000000..5b9c301
--- /dev/null
@@ -0,0 +1,55 @@
+# bash completion for xmllint(1)
+
+have xmllint &&
+_xmllint()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -o|--output)
+            _filedir
+            return 0
+            ;;
+        --path|--dtdvalidfpi|--maxmem|--encode|--pattern)
+            # argument required but no completions available
+            return 0
+            ;;
+        --dtdvalid)
+            _filedir 'dtd?(.gz)'
+            return 0
+            ;;
+        --relaxng)
+            _filedir 'rng?(.gz)'
+            return 0
+            ;;
+        --schema)
+            _filedir 'xsd?(.gz)'
+            return 0
+            ;;
+        --schematron)
+            _filedir 'sch?(.gz)'
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$( xmllint --help 2>&1 | \
+            sed -ne "s/^[[:space:]]*\(--[^[:space:]:]*\).*/\1/p" ) \
+            -o' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp)?(.gz)'
+} &&
+complete -F _xmllint xmllint
+
+# 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
diff --git a/.bash/bash_completion.d/xmlwf b/.bash/bash_completion.d/xmlwf
new file mode 100644 (file)
index 0000000..ba02524
--- /dev/null
@@ -0,0 +1,39 @@
+# bash completion for xmlwf(1)
+
+have xmlwf &&
+_xmlwf()
+{
+    local cur prev
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -d)
+            _filedir -d
+            return 0
+            ;;
+        -e)
+            COMPREPLY=( $( compgen -W 'US-ASCII UTF-8 UTF-16 \
+                ISO-8859-1' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-c -d -e -m -n -p -r -s -t -v -w \
+            -x' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp)'
+} &&
+complete -F _xmlwf xmlwf
+
+# 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
diff --git a/.bash/bash_completion.d/xmms b/.bash/bash_completion.d/xmms
new file mode 100644 (file)
index 0000000..662e2fa
--- /dev/null
@@ -0,0 +1,30 @@
+# bash completion for xmms
+
+have xmms &&
+_xmms()
+{
+    local cur
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-h --help -r --rew -p --play \
+            -u --pause -s --stop -t --play-pause -f --fwd -e \
+            --enqueue -m --show-main-window -i --sm-client-id \
+            -v --version' -- "$cur" ) )
+    else
+        _filedir '@(mp[23]|ogg|wav|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
+
+    fi
+
+} &&
+complete -F _xmms xmms
+
+# 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
diff --git a/.bash/bash_completion.d/xmodmap b/.bash/bash_completion.d/xmodmap
new file mode 100644 (file)
index 0000000..cde9e7e
--- /dev/null
@@ -0,0 +1,32 @@
+# xmodmap(1) completion
+
+have xmodmap &&
+_xmodmap()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -display|-e)
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-display -help -grammar -verbose -quiet -n
+            -e -pm -pk -pke -pp' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _xmodmap xmodmap
+
+# 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
diff --git a/.bash/bash_completion.d/xrandr b/.bash/bash_completion.d/xrandr
new file mode 100644 (file)
index 0000000..70de80f
--- /dev/null
@@ -0,0 +1,52 @@
+# bash completion for xrandr
+
+have xrandr &&
+_xrandr()
+{
+    local cur prev output modes
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --output)
+            local outputs=$(xrandr|awk '/connected/ {print $1}')
+            COMPREPLY=( $(compgen -W "$outputs" -- "$cur"))
+            return 0
+            ;;
+        --mode)
+            for(( i = 1; i < COMP_CWORD; i++ )); do
+                if [[ "${COMP_WORDS[i]}" == "--output" ]]; then
+                    output=${COMP_WORDS[i+1]}
+                    break
+                fi
+            done
+            modes=$(xrandr|sed -e "1,/$output/ d" \
+                -e "/connected/,$ d"|awk '{print $1}')
+            COMPREPLY=( $( compgen -W "$modes" -- "$cur"))
+            return 0
+            ;;
+    esac
+
+    case $cur in
+        *)
+            COMPREPLY=( $(compgen -W '-display -help --orientation --query \
+                --size --rate --version -x -y --screen --verbose --dryrun \
+                --prop --fb --fbmm --dpi --output --auto --mode --preferred \
+                --pos --reflect --rotate --left-of --right-of --above --below \
+                --same-as --set --off --crtc --newmode --rmmode --addmode \
+                --delmode' -- "$cur") )
+            return 0
+            ;;
+    esac
+
+    return 0
+} &&
+complete -F _xrandr xrandr
+
+# 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
diff --git a/.bash/bash_completion.d/xrdb b/.bash/bash_completion.d/xrdb
new file mode 100644 (file)
index 0000000..7307f01
--- /dev/null
@@ -0,0 +1,37 @@
+# xrdb(1) completion
+
+have xrdb &&
+_xrdb()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        -backup|-display|-help)
+            return 0
+            ;;
+        -cpp|-edit)
+            _filedir
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-help -display -all -global -screen -screens
+            -n -quiet -cpp -nocpp -symbols -query -load -override -merge
+            -remove -retain -edit -backup' -- "$cur" ) )
+        return 0
+    fi
+
+    _filedir
+} &&
+complete -F _xrdb xrdb
+
+# 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
diff --git a/.bash/bash_completion.d/xsltproc b/.bash/bash_completion.d/xsltproc
new file mode 100644 (file)
index 0000000..2782f80
--- /dev/null
@@ -0,0 +1,56 @@
+# xsltproc(1) completion
+
+have xsltproc &&
+_xsltproc()
+{
+    local cur prev
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+       --output|-o)
+            _filedir
+            return 0
+            ;;
+        # TODO : number only
+        --maxdepth)
+            return 0
+            ;;
+        --encoding)
+            # some aliases removed
+            COMPREPLY=( $( compgen -W "$( iconv -l | sed -e '/^UTF[1378]/d' \
+                -e '/^ISO[0-9_]/d' -e '/^8859/d' -e 's/\/.*//')" -- "$cur" ) )
+            return 0
+            ;;
+        --param|--stringparam)
+            return 0
+            ;;
+        # not really like --writesubtree
+        --path)
+            _filedir -d
+            return 0
+            ;;
+        --writesubtree)
+            _filedir -d
+            return 0
+            ;;
+    esac
+
+    [[ $COMP_CWORD -gt 2 && `_get_cword '' 2` == --?(string)param ]] && \
+        return 0
+
+    if [[ "$cur" == -* ]]; then
+        _longopt xsltproc
+    else
+       _filedir '@(xsl|xslt|xml)'
+    fi
+} &&
+complete -F _xsltproc xsltproc
+
+# 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
diff --git a/.bash/bash_completion.d/xz b/.bash/bash_completion.d/xz
new file mode 100644 (file)
index 0000000..89a8ac9
--- /dev/null
@@ -0,0 +1,102 @@
+# xz(1) completion
+
+have xz &&
+_xz()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--compress --decompress --test --list \
+            --keep --force --stdout --suffix --files --files0 --format --check \
+            -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 --fast --best --extreme --memory \
+            --lzma1 --lzma2 --x86 --powerpc --ia64 --arm --armthumb --sparc \
+            --delta --quiet --verbose --no-warn --help --long-help --version' \
+            -- "$cur" ) )
+        return 0
+    fi
+
+    local split=false
+    _split_longopt && split=true
+
+    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' -- "$cur" ) )
+            return 0
+            ;;
+        -F|--format)
+            COMPREPLY=( $( compgen -W 'auto xz lzma raw' -- "$cur" ) )
+            return 0
+            ;;
+        -M|--memory|-S|--suffix|--delta|--lzma1|--lzma2)
+            # argument required but no completions available
+            return 0
+            ;;
+        -h|--help|-H|--long-help|-V|--version)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    _expand || return 0
+
+    local IFS=$'\n'
+    _compopt_o_filenames
+    COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
+        $( compgen -d -- "$cur" ) )
+} &&
+complete -F _xz xz
+
+# xzdec(1) completion
+#
+have xzdec &&
+_xzdec()
+{
+    COMPREPLY=()
+    local cur prev
+    _get_comp_words_by_ref cur prev
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '--memory --help --version' -- "$cur" ) )
+        return 0
+    fi
+
+    local split=false
+    _split_longopt && split=true
+
+    case $prev in
+        -M|--memory)
+            # argument required but no completions available
+            return 0
+            ;;
+        -h|--help|-V|--version)
+            # all other arguments are noop with these
+            return 0
+            ;;
+    esac
+
+    $split && return 0
+
+    _filedir xz # no lzma support here as of xz 4.999.9beta
+} &&
+complete -F _xzdec xzdec
+
+# 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
diff --git a/.bash/bash_completion.d/yp-tools b/.bash/bash_completion.d/yp-tools
new file mode 100644 (file)
index 0000000..7252a12
--- /dev/null
@@ -0,0 +1,36 @@
+# bash completion for yp-tools
+
+have ypcat &&
+_ypmatch()
+{
+    local cur map cmd
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+    cmd=${1##*/}
+
+    [[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0
+    [[ $cmd == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
+
+    if [[ $cmd == ypmatch && $COMP_CWORD -eq 1 && \
+        ${#COMP_WORDS[@]} -eq 3 ]]; then
+        map=${COMP_WORDS[2]}
+        COMPREPLY=( $( compgen -W '$( ypcat $map | \
+            cut -d':' -f 1 )' -- "$cur") )
+    else
+        [[ $cmd == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
+        COMPREPLY=( $( compgen -W \
+            '$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
+    fi
+
+    return 0
+} &&
+complete -F _ypmatch ypmatch ypcat
+
+# 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
diff --git a/.bash/bash_completion.d/yum-arch b/.bash/bash_completion.d/yum-arch
new file mode 100644 (file)
index 0000000..bb864af
--- /dev/null
@@ -0,0 +1,24 @@
+# yum-arch(8) completion
+
+have yum-arch &&
+_yum_arch()
+{
+    local cur
+    COMPREPLY=()
+    _get_comp_words_by_ref cur
+
+    if [[ "$cur" == -* ]] ; then
+        COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur" ) )
+    else
+        _filedir -d
+    fi
+} &&
+complete -F _yum_arch yum-arch
+
+# 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
diff --git a/.bash/completion b/.bash/completion
new file mode 100644 (file)
index 0000000..1e310f8
--- /dev/null
@@ -0,0 +1,16 @@
+# Add tab completion for many Bash commands
+if [ -f $HOME/.bash/bash_completion ]; then
+       source $HOME/.bash/bash_completion;
+else
+  echo Could not find bash_completion ...
+fi;
+
+# Enable tab completion for `g` by marking it as an alias for `git`
+if type _git &> /dev/null; then
+       complete -o default -o nospace -F _git g;
+fi;
+
+# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
+if [ -e "$HOME/.ssh/config" ]; then
+  complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh;
+fi;
diff --git a/.bash/dircolors b/.bash/dircolors
new file mode 100644 (file)
index 0000000..f32324a
--- /dev/null
@@ -0,0 +1,425 @@
+# Exact Solarized Dark color theme for the color GNU ls utility.
+# Designed for dircolors (GNU coreutils) 5.97
+#
+# This simple theme was simultaneously designed for these terminal color schemes:
+# - Solarized dark  (best)
+# - Solarized light
+# - default dark
+# - default light
+# with a slight optimization for Solarized Dark.
+#
+# How the colors were selected:
+# - Terminal emulators often have an option typically enabled by default that makes
+#   bold a different color.  It is important to leave this option enabled so that
+#   you can access the entire 16-color Solarized palette, and not just 8 colors.
+# - We favor universality over a greater number of colors.  So we limit the number
+#   of colors so that this theme will work out of the box in all terminals,
+#   Solarized or not, dark or light.
+# - We choose to have the following category of files:
+#   NORMAL & FILE, DIR, LINK, EXEC and
+#   editable text including source, unimportant text, binary docs & multimedia source
+#   files, viewable multimedia, archived/compressed, and unimportant non-text
+# - For uniqueness, we stay away from the Solarized foreground colors are -- either
+#   base00 (brightyellow) or base0 (brighblue).  However, they can be used if
+#   you know what the bg/fg colors of your terminal are, in order to optimize the display.
+# - 3 different options are provided: universal, solarized dark, and solarized light.
+#   The only difference between the universal scheme and one that's optimized for
+#   dark/light is the color of "unimportant" files, which should blend more with the
+#   background
+# - We note that blue is the hardest color to see on dark bg and yellow is the hardest
+#   color to see on light bg (with blue being particularly bad).  So we choose yellow
+#   for multimedia files which are usually accessed in a GUI folder browser anyway.
+#   And blue is kept for custom use of this scheme's user.
+# - See table below to see the assignments.
+
+
+# Insatllation instructions:
+# This file goes in the /etc directory, and must be world readable.
+# You can copy this file to .dir_colors in your $HOME directory to override
+# the system defaults.
+
+# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
+# pipes. 'all' adds color characters to all output. 'none' shuts colorization
+# off.
+COLOR tty
+
+# Below, there should be one TERM entry for each termtype that is colorizable
+TERM ansi
+TERM color_xterm
+TERM color-xterm
+TERM con132x25
+TERM con132x30
+TERM con132x43
+TERM con132x60
+TERM con80x25
+TERM con80x28
+TERM con80x30
+TERM con80x43
+TERM con80x50
+TERM con80x60
+TERM cons25
+TERM console
+TERM cygwin
+TERM dtterm
+TERM Eterm
+TERM eterm-color
+TERM gnome
+TERM gnome-256color
+TERM jfbterm
+TERM konsole
+TERM kterm
+TERM linux
+TERM linux-c
+TERM mach-color
+TERM mlterm
+TERM nxterm
+TERM putty
+TERM rxvt
+TERM rxvt-256color
+TERM rxvt-cygwin
+TERM rxvt-cygwin-native
+TERM rxvt-unicode
+TERM rxvt-unicode256
+TERM rxvt-unicode-256color
+TERM screen
+TERM screen-256color
+TERM screen-256color-bce
+TERM screen-bce
+TERM screen.linux
+TERM screen-w
+TERM vt100
+TERM xterm
+TERM xterm-16color
+TERM xterm-256color
+TERM xterm-88color
+TERM xterm-color
+TERM xterm-debian
+
+# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
+EIGHTBIT 1
+
+#############################################################################
+# Below are the color init strings for the basic file types. A color init
+# string consists of one or more of the following numeric codes:
+#
+# Attribute codes: 
+#   00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
+# Text color codes:
+#   30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
+# Background color codes:
+#   40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
+#
+# NOTES:
+# - See http://www.oreilly.com/catalog/wdnut/excerpt/color_names.html
+# - Color combinations
+#   ANSI Color code       Solarized  Notes                Universal             SolDark              SolLight
+#   ~~~~~~~~~~~~~~~       ~~~~~~~~~  ~~~~~                ~~~~~~~~~             ~~~~~~~              ~~~~~~~~
+#   00    none                                            NORMAL, FILE          <SAME>               <SAME>
+#   30    black           base02                                                
+#   01;30 bright black    base03     bg of SolDark                                                                         
+#   31    red             red                             docs & mm src         <SAME>               <SAME>
+#   01;31 bright red      orange                          EXEC                  <SAME>               <SAME>
+#   32    green           green                           editable text         <SAME>               <SAME>
+#   01;32 bright green    base01                          unimportant text      <SAME>
+#   33    yellow          yellow     unclear in light bg  multimedia            <SAME>               <SAME>
+#   01;33 bright yellow   base00     fg of SolLight                             unimportant non-text
+#   34    blue            blue       unclear in dark bg   user customized       <SAME>               <SAME>
+#   01;34 bright blue     base0      fg in SolDark                                                   unimportant text
+#   35    magenta         magenta                         LINK                  <SAME>               <SAME>
+#   01;35 bright magenta  violet                          archive/compressed    <SAME>               <SAME>
+#   36    cyan            cyan                            DIR                   <SAME>               <SAME>
+#   01;36 bright cyan     base1                           unimportant non-text                       <SAME>
+#   37    white           base2                                                                      
+#   01;37 bright white    base3      bg in SolLight                                                                        
+#   05;37;41                         unclear in Putty dark
+
+
+### By file type
+
+# global default
+NORMAL 00
+# normal file
+FILE 00
+# directory
+DIR 36
+# symbolic link
+LINK 35
+
+# pipe, socket, block device, character device (blue bg)
+FIFO 30;44
+SOCK 35;44
+DOOR 35;44 # Solaris 2.5 and later
+BLK  33;44
+CHR  37;44
+
+
+#############################################################################
+### By file attributes
+
+# Orphaned symlinks (blinking white on red)
+# Blink may or may not work (works on iTerm dark or light, and Putty dark)
+ORPHAN  05;37;41
+# ... and the files that orphaned symlinks point to (blinking white on red)
+MISSING 05;37;41
+
+# files with execute permission
+EXEC 01;31  # Unix
+.cmd 01;31  # Win
+.exe 01;31  # Win
+.com 01;31  # Win
+.bat 01;31  # Win
+.reg 01;31  # Win
+.app 01;31  # OSX
+
+#############################################################################
+### By extension
+
+# List any file extensions like '.gz' or '.tar' that you would like ls
+# to colorize below. Put the extension, a space, and the color init string.
+# (and any comments you want to add after a '#')
+
+### Text formats
+
+# Text that we can edit with a regular editor
+.txt 32
+.org 32
+.md 32
+.mkd 32
+
+# Source text
+.h 32
+.c 32
+.C 32
+.cc 32
+.cxx 32
+.objc 32
+.sh 32
+.csh 32
+.zsh 32
+.el 32
+.vim 32
+.java 32
+.pl 32
+.pm 32
+.py 32
+.rb 32
+.hs 32
+.php 32
+.htm 32
+.html 32
+.shtml 32
+.xml 32
+.rdf 32
+.css 32
+.js 32
+.man 32
+.0 32
+.1 32
+.2 32
+.3 32
+.4 32
+.5 32
+.6 32
+.7 32
+.8 32
+.9 32
+.l 32
+.n 32
+.p 32
+.pod 32
+.tex 32
+
+### Multimedia formats
+
+# Image
+.bmp 33
+.cgm 33
+.dl 33
+.dvi 33
+.emf 33
+.eps 33
+.gif 33
+.jpeg 33
+.jpg 33
+.JPG 33
+.mng 33
+.pbm 33
+.pcx 33
+.pdf 33
+.pgm 33
+.png 33
+.ppm 33
+.pps 33
+.ppsx 33
+.ps 33
+.svg 33
+.svgz 33
+.tga 33
+.tif 33
+.tiff 33
+.xbm 33
+.xcf 33
+.xpm 33
+.xwd 33
+.xwd 33
+.yuv 33
+
+# Audio
+.aac 33
+.au  33
+.flac 33
+.mid 33
+.midi 33
+.mka 33
+.mp3 33
+.mpa 33
+.mpeg 33
+.mpg 33
+.ogg  33
+.ra 33
+.wav 33
+
+# Video
+.anx 33
+.asf 33
+.avi 33
+.axv 33
+.flc 33
+.fli 33
+.flv 33
+.gl 33
+.m2v 33
+.m4v 33
+.mkv 33
+.mov 33
+.mp4 33
+.mp4v 33
+.mpeg 33
+.mpg 33
+.nuv 33
+.ogm 33
+.ogv 33
+.ogx 33
+.qt 33
+.rm 33
+.rmvb 33
+.swf 33
+.vob 33
+.wmv 33
+
+### Misc
+
+# Binary document formats and multimedia source
+.doc 31
+.docx 31
+.rtf 31
+.dot 31
+.dotx 31
+.xls 31
+.xlsx 31
+.ppt 31
+.pptx 31
+.fla 31
+.psd 31
+
+# Archives, compressed
+.7z   1;35
+.apk  1;35
+.arj  1;35
+.bin  1;35
+.bz   1;35
+.bz2  1;35
+.cab  1;35  # Win
+.deb  1;35
+.dmg  1;35  # OSX
+.gem  1;35
+.gz   1;35
+.iso  1;35
+.jar  1;35
+.msi  1;35  # Win
+.rar  1;35
+.rpm  1;35
+.tar  1;35
+.tbz  1;35
+.tbz2 1;35
+.tgz  1;35
+.tx   1;35
+.war  1;35
+.xpi  1;35
+.xz   1;35
+.z    1;35
+.Z    1;35
+.zip  1;35
+
+# For testing
+.ANSI-30-black 30
+.ANSI-01;30-brblack 01;30
+.ANSI-31-red 31
+.ANSI-01;31-brred 01;31
+.ANSI-32-green 32
+.ANSI-01;32-brgreen 01;32
+.ANSI-33-yellow 33
+.ANSI-01;33-bryellow 01;33
+.ANSI-34-blue 34
+.ANSI-01;34-brblue 01;34
+.ANSI-35-magenta 35
+.ANSI-01;35-brmagenta 01;35
+.ANSI-36-cyan 36
+.ANSI-01;36-brcyan 01;36
+.ANSI-37-white 37
+.ANSI-01;37-brwhite 01;37
+
+#############################################################################
+# Your customizations
+
+# Unimportant text files
+# For universal scheme, use brightgreen 01;32
+# For optimal on light bg (but too prominent on dark bg), use white 01;34
+.log 01;32
+*~ 01;32
+*# 01;32
+#.log 01;34
+#*~ 01;34
+#*# 01;34
+
+# Unimportant non-text files
+# For universal scheme, use brightcyan 01;36
+# For optimal on dark bg (but too prominent on light bg), change to 01;33
+#.bak 01;36
+#.BAK 01;36
+#.old 01;36
+#.OLD 01;36
+#.org_archive 01;36
+#.off 01;36
+#.OFF 01;36
+#.dist 01;36
+#.DIST 01;36
+#.orig 01;36
+#.ORIG 01;36
+#.swp 01;36
+#.swo 01;36
+#*,v 01;36
+.bak 01;33
+.BAK 01;33
+.old 01;33
+.OLD 01;33
+.org_archive 01;33
+.off 01;33
+.OFF 01;33
+.dist 01;33
+.DIST 01;33
+.orig 01;33
+.ORIG 01;33
+.swp 01;33
+.swo 01;33
+*,v 01;33
+
+# The brightmagenta (Solarized: purple) color is free for you to use for your
+# custom file type
+.gpg 34
+.gpg 34
+.pgp 34
+.asc 34
+.3des 34
+.aes 34
+.enc 34
diff --git a/.bash/exports b/.bash/exports
new file mode 100644 (file)
index 0000000..63bf0e9
--- /dev/null
@@ -0,0 +1,38 @@
+
+# Make vim the default editor
+export EDITOR="vim";
+export VISUAL="vim";
+
+# Larger bash history (allow 32³ entries; default is 500)
+export HISTSIZE=32768;
+export HISTFILESIZE=$HISTSIZE;
+export HISTCONTROL=ignoreboth;
+# Make some commands not show up in history
+export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help";
+#export HISTFILE="$HOME/.bash_history";
+# Whenever displaying the prompt, write the previous line to disk
+export PROMPT_COMMAND="history -a";
+
+# Prefer US English and use UTF-8
+# export LANG=$(locale -uU)
+export LANG="en_US.UTF-8";
+export LC_ALL="en_US.UTF-8";
+
+# Highlight section titles in manual pages
+export LESS_TERMCAP_md="${yellow}";
+
+# Don’t clear the screen after quitting a manual page
+export MANPAGER="less -X";
+
+# Always enable colored `grep` output
+export GREP_OPTIONS="--color=auto";
+
+# Set up syntax highlighting for 'less' (requires source-highlight package)
+# See http://www.gnu.org/software/src-highlite/source-highlight.html
+# export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s"
+export LESS=-eFRX
+
+# Tell lynx where the color settings are that were adjusted for the
+# Solarized color scheme
+export LYNX_LSS=$HOME/.config/lynx.lss
+
diff --git a/.bash/extra b/.bash/extra
new file mode 100644 (file)
index 0000000..636e36e
--- /dev/null
@@ -0,0 +1,34 @@
+# Determine host platform
+
+if [ "$(uname)" == "SunOS" ]; then
+  PLATFORM="SunOS";
+elif [ "$(uname)" == "MINGW32_NT-6.1" ]; then
+  PLATFORM="Msys";
+elif [ "$(uname)" == "Darwin" ]; then
+  PLATFORM="Darwin";
+elif [ "$(uname -o)" == "GNU/Linux" ]; then
+  PLATFORM="Linux";
+elif [ "$(uname -o)" == "Msys" ]; then
+  PLATFORM="Msys";
+elif [ "$(uname -o)" == "Cygwin" ]; then
+  PLATFORM="Cygwin";
+else
+  PLATFORM="Unknown";
+fi
+export PLATFORM
+echo Now running on $PLATFORM platform;
+
+# Platform specific
+if [ "$PLATFORM" == "Msys" ]; then
+  # Mount the portable Documents folder, if it isn't already
+  if [ ! -d Documents ]; then
+    mount "${USBDRV}\Documents" "${HOME}/Documents";
+  fi
+fi
+
+if [ "$PLATFORM" == "Cygwin" ]; then
+  # Mount the portable Documents folder, if it isn't already
+  if [ ! -d Documents ]; then
+    mount -f -o noacl,posix=0 ${USBDRV}/Documents ${HOME}/Documents;
+  fi
+fi
diff --git a/.bash/functions b/.bash/functions
new file mode 100644 (file)
index 0000000..eac18eb
--- /dev/null
@@ -0,0 +1,296 @@
+# Create a new directory and enter it
+function mkd() {
+       mkdir -p "$@" && cd "$@";
+}
+
+# Change working directory to the top-most Finder window location
+function cdf() { # short for `cdfinder`
+       cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
+}
+
+# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
+function targz() {
+       local tmpFile="${@%/}.tar";
+       tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;
+
+       size=$(
+               stat -f"%z" "${tmpFile}" 2> /dev/null; # OS X `stat`
+               stat -c"%s" "${tmpFile}" 2> /dev/null # GNU `stat`
+       );
+
+       local cmd="";
+       if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
+               # the .tar file is smaller than 50 MB and Zopfli is available; use it
+               cmd="zopfli";
+       else
+               if hash pigz 2> /dev/null; then
+                       cmd="pigz";
+               else
+                       cmd="gzip";
+               fi;
+       fi;
+
+       echo "Compressing .tar using \`${cmd}\`\85";
+       "${cmd}" -v "${tmpFile}" || return 1;
+       [ -f "${tmpFile}" ] && rm "${tmpFile}";
+       echo "${tmpFile}.gz created successfully.";
+}
+
+# Determine size of a file or total size of a directory
+function fs() {
+       if du -b /dev/null > /dev/null 2>&1; then
+               local arg=-sbh;
+       else
+               local arg=-sh;
+       fi
+       if [[ -n "$@" ]]; then
+               du $arg -- "$@";
+       else
+               du $arg .[^.]* *;
+       fi;
+}
+
+# Use Git\92s colored diff when available
+hash git &>/dev/null;
+if [ $? -eq 0 ]; then
+       function diff() {
+               git diff --no-index --color-words "$@";
+       }
+fi;
+
+# Create a data URL from a file
+function dataurl() {
+       local mimeType=$(file -b --mime-type "$1");
+       if [[ $mimeType == text/* ]]; then
+               mimeType="${mimeType};charset=utf-8";
+       fi
+       echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
+}
+
+# Create a git.io short URL
+function gitio() {
+       if [ -z "${1}" -o -z "${2}" ]; then
+               echo "Usage: \`gitio slug url\`";
+               return 1;
+       fi;
+       curl -i http://git.io/ -F "url=${2}" -F "code=${1}";
+}
+
+# Start an HTTP server from a directory, optionally specifying the port
+function server() {
+       local port="${1:-8000}";
+       sleep 1 && open "http://localhost:${port}/" &
+       # Set the default Content-Type to `text/plain` instead of `application/octet-stream`
+       # And serve everything as UTF-8 (although not technically correct, this doesn\92t break anything for binary files)
+       python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port";
+}
+
+# Start a PHP server from a directory, optionally specifying the port
+# (Requires PHP 5.4.0+.)
+function phpserver() {
+       local port="${1:-4000}";
+       local ip=$(ipconfig getifaddr en1);
+       sleep 1 && open "http://${ip}:${port}/" &
+       php -S "${ip}:${port}";
+}
+
+# Compare original and gzipped file size
+function gz() {
+       local origsize=$(wc -c < "$1");
+       local gzipsize=$(gzip -c "$1" | wc -c);
+       local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
+       printf "orig: %d bytes\n" "$origsize";
+       printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
+}
+
+# Syntax-highlight JSON strings or files
+# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
+function json() {
+       if [ -t 0 ]; then # argument
+               python -mjson.tool <<< "$*" | pygmentize -l javascript;
+       else # pipe
+               python -mjson.tool | pygmentize -l javascript;
+       fi;
+}
+
+# Run `dig` and display the most useful info
+function digga() {
+       dig +nocmd "$1" any +multiline +noall +answer;
+}
+
+# UTF-8-encode a string of Unicode symbols
+function escape() {
+       printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u);
+       # print a newline unless we\92re piping the output to another program
+       if [ -t 1 ]; then
+               echo ""; # newline
+       fi;
+}
+
+# Decode \x{ABCD}-style Unicode escape sequences
+function unidecode() {
+       perl -e "binmode(STDOUT, ':utf8'); print \"$@\"";
+       # print a newline unless we\92re piping the output to another program
+       if [ -t 1 ]; then
+               echo ""; # newline
+       fi;
+}
+
+# Get a character\92s Unicode code point
+function codepoint() {
+       perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))";
+       # print a newline unless we\92re piping the output to another program
+       if [ -t 1 ]; then
+               echo ""; # newline
+       fi;
+}
+
+# Show all the names (CNs and SANs) listed in the SSL certificate
+# for a given domain
+function getcertnames() {
+       if [ -z "${1}" ]; then
+               echo "ERROR: No domain specified.";
+               return 1;
+       fi;
+
+       local domain="${1}";
+       echo "Testing ${domain}\85";
+       echo ""; # newline
+
+       local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
+               | openssl s_client -connect "${domain}:443" 2>&1);
+
+       if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
+               local certText=$(echo "${tmp}" \
+                       | openssl x509 -text -certopt "no_header, no_serial, no_version, \
+                       no_signame, no_validity, no_issuer, no_pubkey, no_sigdump, no_aux");
+                       echo "Common Name:";
+                       echo ""; # newline
+                       echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//";
+                       echo ""; # newline
+                       echo "Subject Alternative Name(s):";
+                       echo ""; # newline
+                       echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
+                               | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
+                       return 0;
+       else
+               echo "ERROR: Certificate not found.";
+               return 1;
+       fi;
+}
+
+# `s` with no arguments opens the current directory in Sublime Text, otherwise
+# opens the given location
+function s() {
+       if [ $# -eq 0 ]; then
+               subl .;
+       else
+               subl "$@";
+       fi;
+}
+
+# `a` with no arguments opens the current directory in Atom Editor, otherwise
+# opens the given location
+function a() {
+       if [ $# -eq 0 ]; then
+               atom .;
+       else
+               atom "$@";
+       fi;
+}
+
+# `v` with no arguments opens the current directory in Vim, otherwise opens the
+# given location
+function v() {
+       if [ $# -eq 0 ]; then
+               vim .;
+       else
+               vim "$@";
+       fi;
+}
+
+# `o` with no arguments opens the current directory, otherwise opens the given
+# location
+function o() {
+       if [ $# -eq 0 ]; then
+               open .;
+       else
+               open "$@";
+       fi;
+}
+
+# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
+# the `.git` directory, listing directories first. The output gets piped into
+# `less` with options to preserve color and line numbers, unless the output is
+# small enough for one screen.
+function tre() {
+       tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
+}
+
+repo_co ()
+{
+  repo forall -c 'pwd; git checkout '$1
+}
+
+git_getproj ()
+{
+  git remote -v | head -n1 | awk '{print $2}' | sed 's/.*29418\///'
+}
+
+# This function defines a 'cd' replacement function capable of keeping,
+# displaying and accessing history of visited directories, up to 10 entries.
+# To use it, uncomment it, source this file and try 'cd --'.
+# acd_func 1.0.5, 10-nov-2004
+# Petar Marinov, http:/geocities.com/h2428, this is public domain
+
+cd_func()
+{
+  local x2 the_new_dir adir index
+  local -i cnt
+
+  if [[ $1 ==  "--" ]]; then
+    dirs -v
+    return 0
+  fi
+
+  the_new_dir=$1
+  [[ -z $1 ]] && the_new_dir=$HOME
+
+  if [[ ${the_new_dir:0:1} == '-' ]]; then
+    #
+    # Extract dir N from dirs
+    index=${the_new_dir:1}
+    [[ -z $index ]] && index=1
+    adir=$(dirs +$index)
+    [[ -z $adir ]] && return 1
+    the_new_dir=$adir
+  fi
+
+  #
+  # '~' has to be substituted by ${HOME}
+  [[ ${the_new_dir:0:1} == '~' ]] && the_new_dir="${HOME}${the_new_dir:1}"
+
+  #
+  # Now change to the new dir and add to the top of the stack
+  pushd "${the_new_dir}" > /dev/null
+  [[ $? -ne 0 ]] && return 1
+  the_new_dir=$(pwd)
+
+  #
+  # Trim down everything beyond 11th entry
+  popd -n +11 2>/dev/null 1>/dev/null
+
+  #
+  # Remove any other occurence of this dir, skipping the top of the stack
+  for ((cnt=1; cnt <= 10; cnt++)); do
+    x2=$(dirs +${cnt} 2>/dev/null)
+    [[ $? -ne 0 ]] && return 0
+    [[ ${x2:0:1} == '~' ]] && x2="${HOME}${x2:1}"
+    if [[ "${x2}" == "${the_new_dir}" ]]; then
+      popd -n +$cnt 2>/dev/null 1>/dev/null
+      cnt=cnt-1
+    fi
+  done
+
+  return 0
+}
diff --git a/.bash/options b/.bash/options
new file mode 100644 (file)
index 0000000..22beba3
--- /dev/null
@@ -0,0 +1,23 @@
+# Case-insensitive globbing (used in pathname expansion)
+shopt -s nocaseglob;
+
+# Append to the Bash history file, rather than overwriting it
+shopt -s histappend;
+
+# Autocorrect typos in path names when using `cd`
+shopt -s cdspell;
+
+# Enable some Bash 4 features when possible:
+# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
+# * Recursive globbing, e.g. `echo **/*.txt`
+for option in autocd globstar; do
+       shopt -s "$option" 2> /dev/null;
+done;
+
+# File creation
+umask 022
+
+# Don't use ^D to exit
+set -o ignoreeof
+set -o vi
+
diff --git a/.bash/paths b/.bash/paths
new file mode 100644 (file)
index 0000000..eec134f
--- /dev/null
@@ -0,0 +1,32 @@
+
+# Set PATH so it includes user's private bin if it exists
+# if [ -d "${HOME}/bin" ] ; then
+#  PATH="${HOME}/bin:${PATH}"
+# fi
+
+# Set MANPATH so it includes users' private man if it exists
+# if [ -d "${HOME}/man" ]; then
+#   MANPATH="${HOME}/man:${MANPATH}"
+# fi
+
+# Set INFOPATH so it includes users' private info if it exists
+# if [ -d "${HOME}/info" ]; then
+#   INFOPATH="${HOME}/info:${INFOPATH}"
+# fi
+
+# Set PATH to temporary folders
+export TEMPDIR="${HOME}/tmp"
+export TMPDIR="${HOME}/tmp"
+
+# Set PATH to dotfiles git folder
+export DOTFILES="${HOME}/.dotfiles"
+
+# Set PATH to PREFIX folders
+export PREFIX="${HOME}"
+
+PATH="${PREFIX}/bin:${PATH}"
+MANPATH="${PREFIX}/share/man:${MANPATH}"
+INFOPATH="${PREFIX}/share/info:${INFOPATH}"
+
+# Add local libraries to libpath
+# LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH}"
diff --git a/.bash/prompt b/.bash/prompt
new file mode 100644 (file)
index 0000000..bbce626
--- /dev/null
@@ -0,0 +1,77 @@
+# Bash git prompt solarized
+
+if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
+        export TERM='gnome-256color';
+elif infocmp xterm-256color >/dev/null 2>&1; then
+        export TERM='xterm-256color';
+fi;
+
+if tput setaf 1 &> /dev/null; then
+       tput sgr0; # reset colors
+       bold=$(tput bold);
+       reset=$(tput sgr0);
+       black=$(tput setaf 0);
+       blue=$(tput setaf 33);
+       cyan=$(tput setaf 37);
+       green=$(tput setaf 64);
+       orange=$(tput setaf 166);
+       purple=$(tput setaf 125);
+       red=$(tput setaf 124);
+       violet=$(tput setaf 61);
+       white=$(tput setaf 15);
+       yellow=$(tput setaf 136);
+else
+       bold='';
+       reset="\e[0m";
+       black="\e[1;30m";
+       blue="\e[1;34m";
+       cyan="\e[1;36m";
+       green="\e[1;32m";
+       orange="\e[1;33m";
+       purple="\e[1;35m";
+       red="\e[1;31m";
+       violet="\e[1;35m";
+       white="\e[1;37m";
+       yellow="\e[1;33m";
+fi;
+
+# Highlight the user name when logged in as root.
+if [[ "${USER}" == "root" ]]; then
+       userStyle="${red}";
+else
+       userStyle="${orange}";
+fi;
+
+# Highlight the hostname when connected via SSH.
+if [[ "${SSH_TTY}" ]]; then
+       hostStyle="${bold}${red}";
+else
+       hostStyle="${yellow}";
+fi;
+
+# Enabling any of these options will slow down the prompt
+export GIT_PS1_SHOWDIRTYSTATE=
+export GIT_PS1_SHOWSTASHSTATE=
+export GIT_PS1_SHOWUNTRACKEDFILES=
+export GIT_PS1_SHOWUPSTREAM=    #"auto"
+
+# Set git prompt
+# Set the terminal title to the current working directory.
+PS1='';
+#PS1+='\[\033]0;\w\007\]';
+PS1+='\[${bold}\]';
+#PS1+='\n'; # newline
+PS1+='\[${userStyle}\]\u '; # username
+PS1+='\[${white}\]at ';
+PS1+='\[${hostStyle}\]\h '; # at host
+PS1+='\[${white}\]in ';
+PS1+='\[${green}\]\w '; # in working directory
+PS1+='$(__git_ps1 "\[${white}\]on \[${violet}\]%s\[${blue}\]")';  # on branch
+PS1+='\n'; # newline
+PS1+='\[${white}\]\$ '; # `$`
+PS1+='\[${reset}\]'; # reset color
+export PS1;
+
+PS2='\[${yellow}\]→ '; # `→`
+PS2+='\[${reset}\]'; # reset color
+export PS2;
diff --git a/.bash_profile b/.bash_profile
new file mode 100644 (file)
index 0000000..b9cb38a
--- /dev/null
@@ -0,0 +1,6 @@
+# User dependent .bash_profile file
+
+# source the users bashrc if it exists
+if [ -f "${HOME}/.bashrc" ] ; then
+  source "${HOME}/.bashrc"
+fi
diff --git a/.bashrc b/.bashrc
new file mode 100644 (file)
index 0000000..2b416bb
--- /dev/null
+++ b/.bashrc
@@ -0,0 +1,14 @@
+# User dependent .bashrc file
+
+# If not running interactively, don't do anything
+[[ "$-" != *i* ]] && return
+#[ -n "$PS1" ] && source ~/.bash_profile;
+
+# Load the shell dotfiles
+for file in ~/.bash/{options,completion,exports,aliases,functions,prompt,extra,paths}; do
+       [ -r "$file" ] && [ -f "$file" ] && source "$file";
+done;
+
+if [ -f ~/.bashrc_local ]; then
+       source ~/.bashrc_local
+fi
diff --git a/.profile b/.profile
new file mode 100644 (file)
index 0000000..4483987
--- /dev/null
+++ b/.profile
@@ -0,0 +1,12 @@
+# User dependent .profile file
+
+# This file is not read by bash(1) if ~/.bash_profile or ~/.bash_login
+# exists.
+#
+# if running bash
+if [ -n "${BASH_VERSION}" ]; then
+  if [ -f "${HOME}/.bashrc" ]; then
+    source "${HOME}/.bashrc"
+  fi
+fi
+