Sure hope I didn't miss any super secret crap :-Pmain
commit
a8cd5a2fe9
@ -0,0 +1,10 @@
|
||||
TARGETS = $(patsubst %,$(HOME)/.%,$(shell ls -d * | grep -v '.d'))
|
||||
|
||||
$(HOME)/.%: %
|
||||
rsync -avz $^ $@
|
||||
|
||||
all: $(TARGETS)
|
||||
mkdir -p $(HOME)/.bash_completion.d
|
||||
rsync -avz bash_completion.d/ $(HOME)/.bash_completion.d
|
||||
|
||||
.PHONY: all
|
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
USAGE="Usage: $HOME/.activate_proj <proj>"
|
||||
|
||||
function __run_activate(){
|
||||
if [ -n "${1}" ] ; then
|
||||
PROJ=${1}
|
||||
local PROJDIR="${HOME}/src/${PROJ}"
|
||||
if [[ -d "$PROJDIR" ]] ; then
|
||||
export PROJ
|
||||
export PROJSRC="$PROJDIR/src"
|
||||
export PROJBIN="${PROJDIR}/bin"
|
||||
cd "${PROJSRC}"
|
||||
|
||||
_HAS_GIT=""
|
||||
if [[ -d "$PWD/.git" ]]
|
||||
then
|
||||
_HAS_GIT="yup"
|
||||
fi
|
||||
|
||||
_HG_BRANCH=""
|
||||
_HAS_HG=""
|
||||
if [[ -d "$PWD/.hg" ]]
|
||||
then
|
||||
_HG_BRANCH="$PWD/.hg/branch"
|
||||
_HAS_HG="yup"
|
||||
fi
|
||||
|
||||
echo "Changed to ${PROJSRC}"
|
||||
if [[ -e "${PROJBIN}/activate" ]]
|
||||
then
|
||||
source "${PROJBIN}/activate"
|
||||
fi
|
||||
echo "${PROJ} activated"
|
||||
|
||||
PROMPT_COMMAND='precmd; PS1="(\[\033[33m\]\${PROJ}\[\033[00m\]) _VCS_BRANCH_$PS1"'
|
||||
export PROMPT_COMMAND
|
||||
|
||||
if [[ -n "$_HAS_HG" ]]
|
||||
then
|
||||
if [[ -n "$(/bin/ls $(hg root)/.hg/branches 2>/dev/null)" ]]
|
||||
then
|
||||
PROMPT_COMMAND=$(echo $PROMPT_COMMAND | sed "s@_VCS_BRANCH_@(lb:\`hg lbranch 2>/dev/null\`) @")
|
||||
else
|
||||
PROMPT_COMMAND=$(echo $PROMPT_COMMAND | sed "s@_VCS_BRANCH_@(b:\`cat ${PROJSRC}/.hg/branch 2>/dev/null\`) @")
|
||||
fi
|
||||
else
|
||||
PROMPT_COMMAND=$(echo $PROMPT_COMMAND | sed "s/_VCS_BRANCH_//" )
|
||||
fi
|
||||
export PS2=""
|
||||
else
|
||||
echo "Hey! '${1}' is not a valid project."
|
||||
echo "Pick from these:"
|
||||
echo
|
||||
for p in $( ls -1 -I "*.egg" "${HOME}/src" ) ; do
|
||||
echo " $p"
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo ${USAGE}
|
||||
fi
|
||||
}
|
||||
|
||||
__run_activate "$@"
|
||||
unset __run_activate
|
||||
|
||||
# vim:ft=sh
|
@ -0,0 +1,26 @@
|
||||
alias .bp="source $HOME/.bash_profile"
|
||||
alias .sa="source $HOME/.ssh/agent.out"
|
||||
alias be='bundle exec'
|
||||
alias h='cat /etc/hosts'
|
||||
alias hn='hostname -f'
|
||||
alias i='ip addr'
|
||||
alias k1='kill -9 %1'
|
||||
alias la='l -a'
|
||||
alias ll='l -l'
|
||||
alias lla='l -la'
|
||||
alias p=ipython
|
||||
alias psg='pgrep -fl'
|
||||
alias s="cat $HOME/.ssh/config | grep '^Host ' | sed \"s/Host //\" | sort | uniq"
|
||||
alias sS='TERM=xterm screen -Rd -S '
|
||||
alias scr='TERM=xterm screen -Rd'
|
||||
alias sl="screen -ls"
|
||||
|
||||
if [[ "$(uname)" -eq "Linux" ]]
|
||||
then
|
||||
alias l='ls -F --color=auto'
|
||||
else
|
||||
# for darwin in particular
|
||||
alias l='ls -GF'
|
||||
fi
|
||||
|
||||
# vim:filetype=sh
|
@ -0,0 +1,514 @@
|
||||
# bash_completion - programmable completion functions for bash 3.x
|
||||
# (backwards compatible with bash 2.05b)
|
||||
#
|
||||
# Copyright ยฉ 2006-2008, Ian Macdonald <ian@caliban.org>
|
||||
# ยฉ 2008, David Paleino <d.paleino@gmail.com>
|
||||
# ยฉ 2008, Luk Claes <luk@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: 20080617.5
|
||||
|
||||
LOCAL_BASH_COMPLETION_DIR=$HOME/.bash_completion.d
|
||||
|
||||
_debug()
|
||||
{
|
||||
test -n "$DEBUG" && echo "$1"
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
# 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}
|
||||
RELEASE=$( uname -r )
|
||||
|
||||
# features supported by bash 2.05 and higher
|
||||
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
|
||||
[ ${BASH_VERSINFO[0]} -gt 2 ]; then
|
||||
declare -r bash205=$BASH_VERSION 2>/dev/null || :
|
||||
default="-o default"
|
||||
dirnames="-o dirnames"
|
||||
filenames="-o filenames"
|
||||
fi
|
||||
# features supported by bash 2.05b and higher
|
||||
if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
|
||||
[ ${BASH_VERSINFO[0]} -gt 2 ]; then
|
||||
declare -r bash205b=$BASH_VERSION 2>/dev/null || :
|
||||
nospace="-o nospace"
|
||||
fi
|
||||
# features supported by bash 3.0 and higher
|
||||
if [ ${BASH_VERSINFO[0]} -gt 2 ]; then
|
||||
declare -r bash3=$BASH_VERSION 2>/dev/null || :
|
||||
bashdefault="-o bashdefault"
|
||||
plusdirs="-o plusdirs"
|
||||
fi
|
||||
|
||||
# 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
|
||||
complete -f -X '!*.?(t)bz?(2)' bunzip2
|
||||
# TODO: see #455510
|
||||
#complete -f -X '!*.?(t)bz?(2)' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
|
||||
complete -f -X '!*.*' bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
|
||||
complete -f -X '!*.@(zip|ZIP|jar|JAR|egg|EGG|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|swc|ott|od[fgpst])' unzip zipinfo
|
||||
complete -f -X '*.Z' compress znew
|
||||
complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip
|
||||
# TODO: see #455510
|
||||
#complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
|
||||
complete -f -X '!*.*' zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
|
||||
complete -f -X '!*.Z' uncompress
|
||||
complete -f -X '!*.@(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)' ee
|
||||
complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|svg|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX|SVG)' display
|
||||
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|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
|
||||
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' kdvi
|
||||
complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
|
||||
complete -f -X '!*.@(pdf|PDF)' acroread gpdf xpdf
|
||||
complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' kpdf
|
||||
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2)|cb(r|z)|CB(R|Z)|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)' evince
|
||||
complete -f -X '!*.@(?(e)ps|?(E)PS)' ps2pdf
|
||||
complete -f -X '!*.texi*' makeinfo texi2html
|
||||
complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
|
||||
complete -f -X '!*.@(mp3|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|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|m4[pv]|M4[PV]|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|srt)' xine aaxine fbxine kaffeine
|
||||
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|OGG|m3u|flac|spx)' ogg123
|
||||
complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
|
||||
complete -f -X '!*.fig' xfig
|
||||
complete -f -X '!*.@(mid?(i)|MID?(I)|cmf|CMF)' playmidi
|
||||
complete -f -X '!*.@(mid?(i)|MID?(I)|rmi|RMI|rcp|RCP|[gr]36|[GR]36|g18|G18|mod|MOD|xm|XM|it|IT|x3m|X3M)' timidity
|
||||
complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' vi vim gvim rvim view rview rgvim rgview gview
|
||||
complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' emacs
|
||||
complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR|exe.so)' wine
|
||||
complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
|
||||
complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon curl dillo elinks amaya
|
||||
complete -f -X '!*.@(sxw|stw|sxg|sgl|doc|dot|rtf|txt|htm|html|odt|ott|odm)' oowriter
|
||||
complete -f -X '!*.@(sxi|sti|pps|ppt|pot|odp|otp)' ooimpress
|
||||
complete -f -X '!*.@(sxc|stc|xls|xlw|xlt|csv|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 '!*.rpm' rpm2cpio
|
||||
# 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 usermod userdel passwd chage write chfn groups slay w sux
|
||||
|
||||
# group commands see only groups
|
||||
[ -n "$bash205" ] && complete -g groupmod groupdel newgrp 2>/dev/null
|
||||
|
||||
# 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
|
||||
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
|
||||
have="yes"
|
||||
}
|
||||
|
||||
# use GNU sed if we have it, since its extensions are still used in our code
|
||||
#
|
||||
[ $UNAME != Linux ] && have gsed && alias sed=gsed
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# This function quotes the argument in a way so that readline dequoting
|
||||
# results in the original argument
|
||||
quote_readline()
|
||||
{
|
||||
local t="${1//\\/\\\\}"
|
||||
echo \'${t//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
|
||||
}
|
||||
|
||||
# This function shell-dequotes the argument
|
||||
dequote()
|
||||
{
|
||||
eval echo "$1"
|
||||
}
|
||||
|
||||
# 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 --------> ^
|
||||
# it will complete just "foo", not "foobar", which is what the user wants.)
|
||||
#
|
||||
#
|
||||
# Accepts an optional parameter indicating which characters out of
|
||||
# $COMP_WORDBREAKS should NOT be considered word breaks. This is useful
|
||||
# for things like scp where we want to return host:path and not only path.
|
||||
_get_cword()
|
||||
{
|
||||
if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
|
||||
echo "${COMP_WORDS[COMP_CWORD]}"
|
||||
else
|
||||
local i
|
||||
local cur="$COMP_LINE"
|
||||
local index="$COMP_POINT"
|
||||
for (( i = 0; i <= COMP_CWORD; ++i )); do
|
||||
while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
|
||||
cur="${cur:1}"
|
||||
index="$(( index - 1 ))"
|
||||
done
|
||||
if [[ "$i" -lt "$COMP_CWORD" ]]; then
|
||||
local old_size="${#cur}"
|
||||
cur="${cur#${COMP_WORDS[i]}}"
|
||||
local new_size="${#cur}"
|
||||
index="$(( index - old_size + new_size ))"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
|
||||
# We messed up! At least return the whole word so things
|
||||
# keep working
|
||||
echo "${COMP_WORDS[COMP_CWORD]}"
|
||||
else
|
||||
echo "${cur:0:$index}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# This function performs file and directory completion. It's better than
|
||||
# simply using 'compgen -f', because it honours spaces in filenames.
|
||||
# If passed -d, it completes only on directories. If passed anything else,
|
||||
# it's assumed to be a file glob to complete on.
|
||||
#
|
||||
_filedir()
|
||||
{
|
||||
local IFS=$'\t\n' xspec
|
||||
|
||||
_expand || return 0
|
||||
|
||||
local toks=( ) tmp
|
||||
while read -r tmp; do
|
||||
[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
|
||||
done < <( compgen -d -- "$(quote_readline "$cur")" )
|
||||
|
||||
if [[ "$1" != -d ]]; then
|
||||
xspec=${1:+"!*.$1"}
|
||||
while read -r tmp; do
|
||||
[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
|
||||
done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" )
|
||||
fi
|
||||
|
||||
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
|
||||
}
|
||||
|
||||
# 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 configured network interfaces
|
||||
#
|
||||
_configured_interfaces()
|
||||
{
|
||||
if [ -f /etc/debian_version ]; then
|
||||
# Debian system
|
||||
COMPREPLY=( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
|
||||
/etc/network/interfaces ) )
|
||||
elif [ -f /etc/SuSE-release ]; then
|
||||
# SuSE system
|
||||
COMPREPLY=( $( command ls \
|
||||
/etc/sysconfig/network/ifcfg-* | \
|
||||
sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
|
||||
elif [ -f /etc/pld-release ]; then
|
||||
# PLD Linux
|
||||
COMPREPLY=( $( command ls -B \
|
||||
/etc/sysconfig/interfaces | \
|
||||
sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
|
||||
else
|
||||
# Assume Red Hat
|
||||
COMPREPLY=( $( command ls \
|
||||
/etc/sysconfig/network-scripts/ifcfg-* | \
|
||||
sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
|
||||
fi
|
||||
}
|
||||
|
||||
# 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 $cmd 2>/dev/null | \
|
||||
sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p') )
|
||||
}
|
||||
|
||||
# This function expands tildes in pathnames
|
||||
#
|
||||
_expand()
|
||||
{
|
||||
# FIXME: Why was this here?
|
||||
#[ "$cur" != "${cur%\\}" ] && cur="$cur\\"
|
||||
|
||||
# expand ~username type directory specifications
|
||||
if [[ "$cur" == \~*/* ]]; then
|
||||
eval cur=$cur
|
||||
elif [[ "$cur" == \~* ]]; then
|
||||
cur=${cur#\~}
|
||||
COMPREPLY=( $( compgen -P '~' -u $cur ) )
|
||||
return ${#COMPREPLY[@]}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function completes on process IDs.
|
||||
# AIX and Solaris ps prefers X/Open syntax.
|
||||
[ $UNAME = SunOS -o $UNAME = AIX ] &&
|
||||
_pids()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- $cur ))
|
||||
} ||
|
||||
_pids()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
|
||||
}
|
||||
|
||||
# This function completes on process group IDs.
|
||||
# AIX and SunOS prefer X/Open, all else should be BSD.
|
||||
[ $UNAME = SunOS -o $UNAME = AIX ] &&
|
||||
_pgids()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- $cur ))
|
||||
} ||
|
||||
_pgids()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ))
|
||||
}
|
||||
|
||||
# This function completes on user IDs
|
||||
#
|
||||
_uids()
|
||||
{
|
||||
if type getent &>/dev/null; then
|
||||
COMPREPLY=( $( getent passwd | \
|
||||
awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
|
||||
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=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
|
||||
/etc/passwd ) )
|
||||
fi
|
||||
}
|
||||
|
||||
# This function completes on group IDs
|
||||
#
|
||||
_gids()
|
||||
{
|
||||
if type getent &>/dev/null; then
|
||||
COMPREPLY=( $( getent group | \
|
||||
awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
|
||||
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=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
|
||||
/etc/group ) )
|
||||
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=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) )
|
||||
|
||||
if [ -d $famdir ]; then
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
|
||||
fi
|
||||
|
||||
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
|
||||
}
|
||||
|
||||
# This function complete on modules
|
||||
#
|
||||
_modules()
|
||||
{
|
||||
local modpath
|
||||
modpath=/lib/modules/$1
|
||||
COMPREPLY=( $( command ls -R $modpath | \
|
||||
sed -ne 's/^\('$cur'.*\)\.k\?o\(\|.gz\)$/\1/p') )
|
||||
}
|
||||
|
||||
# This function completes on installed modules
|
||||
#
|
||||
_installed_modules()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W "$( /sbin/lsmod | \
|
||||
awk '{if (NR != 1) print $1}' )" -- $1 ) )
|
||||
}
|
||||
|
||||
# this function complete on user:group format
|
||||
#
|
||||
_usergroup()
|
||||
{
|
||||
local IFS=$'\n'
|
||||
cur=${cur//\\\\ / }
|
||||
if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then
|
||||
user=${cur%%*([^:.])}
|
||||
COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) )
|
||||
elif [[ $cur = *:* ]] && [ -n "$bash205" ]; then
|
||||
COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) )
|
||||
else
|
||||
COMPREPLY=( $( compgen -S : -u -- $cur ) )
|
||||
fi
|
||||
}
|
||||
|
||||
# this function count the number of mandatory args
|
||||
#
|
||||
_count_args()
|
||||
{
|
||||
args=1
|
||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||
if [[ "${COMP_WORDS[i]}" != -* ]]; then
|
||||
args=$(($args+1))
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
_source_local_bash_completion()
|
||||
{
|
||||
# source completion directory definitions
|
||||
if [ -n "$(complete | grep "post-review")" ]
|
||||
then
|
||||
return 2
|
||||
fi
|
||||
|
||||
if [ -x $LOCAL_BASH_COMPLETION_DIR ]
|
||||
then
|
||||
for i in $LOCAL_BASH_COMPLETION_DIR/*
|
||||
do
|
||||
local invalid="`echo $i | grep -E '.*(~|\.bak|\.swp|\.dpkg.*|\.rpm.*)'`"
|
||||
if [[ ! -n "$invalid" ]] && [[ -e "$i" ]]
|
||||
then
|
||||
_debug "sourcing $i"
|
||||
source $i
|
||||
fi
|
||||
done
|
||||
fi
|
||||
unset i
|
||||
}
|
||||
|
||||
|
||||
_source_local_bash_completion
|
||||
unset _source_local_bash_completion
|
||||
|
||||
|
||||
# vim:filetype=sh
|
@ -0,0 +1,9 @@
|
||||
if [ which mxmlc 2>/dev/null ]
|
||||
then
|
||||
__WORDS="$(mxmlc -help list | awk '/^-/ { print $1 }')"
|
||||
|
||||
complete -W "$__WORDS" -f -o default mxmlc
|
||||
complete -W "$__WORDS" -f -o default compc
|
||||
fi
|
||||
|
||||
# vim:filetype=sh
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,49 @@
|
||||
# bash completion for gpg
|
||||
|
||||
have gpg &&
|
||||
_gpg()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
case "$prev" in
|
||||
-@(s|-sign|-clearsign|-decrypt-files|-load-extension))
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
--@(export|@(?(l|nr|nrl)sign|edit)-key))
|
||||
# return list of public keys
|
||||
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
|
||||
sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p;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 '-s -b -e -f -c -d -a -r -u -Z -o -v\
|
||||
-q -n -N $(gpg --dump-options)' -- "$cur" ) )
|
||||
fi
|
||||
|
||||
} &&
|
||||
complete -F _gpg $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
|
@ -0,0 +1,53 @@
|
||||
# gpg2(1) completion
|
||||
|
||||
have gpg2 && {
|
||||
_gpg2 ()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
case "$prev" in
|
||||
--homedir)
|
||||
_filedir -d
|
||||
return 0
|
||||
;;
|
||||
-@(s|-sign|-clearsign|-options|-decrypt))
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
--@(export|@(?(l|nr|nrl)sign|edit)-key))
|
||||
# return list of public keys
|
||||
COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \
|
||||
sed -ne 's@^pub.*/\([^ ]*\).*$@\1@p;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 '-s -b -e -c -d -k -K -a -r -u -z -o -v \
|
||||
-n -N -i -h -R -t $(gpg2 --dump-options)' -- "$cur" ) )
|
||||
fi
|
||||
} &&
|
||||
complete -F _gpg2 $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
|
@ -0,0 +1,25 @@
|
||||
# inkscape(1) completion
|
||||
# put this file in /etc/bash_completion.d/
|
||||
# allali@univ-mlv.fr
|
||||
|
||||
have inkscape &&
|
||||
_inkscape()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-? --help --usage -V --version \
|
||||
-z --without-gui -g --with-gui -f --file= -p --print= \
|
||||
-e --export-png= -d --export-dpi= -a --export-area= \
|
||||
-w --export-width= -h --export-height= -i --export-id= \
|
||||
-j --export-id-only -t --export-use-hints -b --export-background= \
|
||||
-y --export-background-opacity= -l --export-plain-svg= -s --slideshow' -- $cur ) )
|
||||
else
|
||||
_filedir '@(svg|svgz|ai|dia|eps|ani|bmp|cur|gif|ico|jpe|jpg|pbm|pcx|pgm|png|ppm|pnm|ras|targa|tga|tif|tiff|wbmp|xbm|xpm|ggr|ps|sk|txt|wmf)'
|
||||
fi
|
||||
|
||||
}
|
||||
[ "${have:-}" ] && complete -F _inkscape $filenames inkscape
|
@ -0,0 +1,127 @@
|
||||
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
|
||||
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
|
||||
|
||||
# We need to specify GNU sed for OS X, BSDs, etc.
|
||||
if [[ "$(uname -s)" == "Darwin" ]]; then
|
||||
SED=gsed
|
||||
else
|
||||
SED=sed
|
||||
fi
|
||||
|
||||
# first argument set the command level
|
||||
_get_knife_completions() {
|
||||
n=$1
|
||||
shift
|
||||
# first argument is knife, so shift it
|
||||
#[ "$1" == "knife" ] && shift
|
||||
local opts
|
||||
opts="$($@ --help | grep -E '^knife' | cut -f$n -d" " | grep -v -E '[][[:upper:].]+' |grep -v '(options)')"
|
||||
_upvar opts "$opts"
|
||||
}
|
||||
|
||||
_flatten_knife_command() {
|
||||
echo ${words[*]} |${SED} -r -e "s/\ *${words[$cword]}\$//" -e 's/\W/_/g'
|
||||
}
|
||||
# Check cache file for category ( passed as $1 ) and run command if cache is empty
|
||||
# Designed to be used with _get_knife_completions() and use the opts variables for options
|
||||
_completion_cache() {
|
||||
local CACHE_DIR=${CHEF_HOME:-"$HOME/.chef"}/.completion_cache
|
||||
local flag COMMAND
|
||||
local OPTIND=1
|
||||
while getopts "c" flag "$@"; do
|
||||
case $flag in
|
||||
c)
|
||||
COMMAND=yes
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
local CACHE_FILE="$CACHE_DIR/$1"
|
||||
shift
|
||||
if [ ! -f "$CACHE_FILE" ]; then
|
||||
if [[ "$COMMAND" == "yes" ]]; then
|
||||
opts=$( eval $@ )
|
||||
else
|
||||
$@
|
||||
fi
|
||||
[ -d "$CACHE_DIR" ] && echo $opts >"$CACHE_FILE"
|
||||
else
|
||||
opts=$(cat "$CACHE_FILE")
|
||||
fi
|
||||
_upvar opts "$opts"
|
||||
}
|
||||
|
||||
_knife() {
|
||||
local opts cur prev cword words flattened_knife_command
|
||||
_completion_cache knife_commands _get_knife_completions 2 knife
|
||||
_get_comp_words_by_ref cur prev cword words
|
||||
flattened_knife_command=$(_flatten_knife_command)
|
||||
COMPREPLY=()
|
||||
case $flattened_knife_command in
|
||||
*knife_cookbook_upload|*knife_cookbook_test)
|
||||
local chef_repos
|
||||
if [[ -z $CHEF_REPOS ]]; then
|
||||
chef_repos=( $(${SED} -rn '/cookbook_path/ {s/.*\[(.*)\]/\1/g; s/[,'\'']//g; p}' ${CHEF_HOME:-"$HOME/.chef"}/knife.rb) )
|
||||
else
|
||||
chef_repos=( ${CHEF_REPOS[@]} )
|
||||
fi
|
||||
if [[ -n "$chef_repos" ]]; then
|
||||
opts=$( ls -1p ${chef_repos[@]} | sort -u | ${SED} -n 's/\/$//p' )
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
fi
|
||||
;;
|
||||
*knife_data)
|
||||
opts="bag"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*knife_node_show|*knife_node_edit|*knife_node_delete|*knife_tag_*)
|
||||
_completion_cache -c knife_nodes "${words[0]} node list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*knife_role_edit|*knife_role_show|*knife_role_delete)
|
||||
_completion_cache -c knife_roles "${words[0]} role list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*knife_data_bag_delete|*knife_data_bag_show|*knife_data_bag_edit)
|
||||
_completion_cache -c knife_data_bags "${words[0]} data bag list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*knife_data_bag_delete_*|*knife_data_bag_show_*|*knife_data_bag_edit_*)
|
||||
_completion_cache -c knife_data_bag_$prev "${words[0]} data bag show $prev 2>/dev/null|${SED} -r -e 's/[\"\ ,]//g' -e '/^[^0-9A-Za-z._-]+/d'"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*knife_client_list|*knife_client_show|*knife_client_edit)
|
||||
_completion_cache -c knife_clients "${words[0]} client list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*knife_environment_show|*knife_environment_edit|*knife_environment_delete)
|
||||
_completion_cache -c knife_environments "${words[0]} environment list|${SED} -r -e 's/[\"\ ,]//g' -e '/[^0-9A-Za-z._-]+/d'"
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
case $cword in
|
||||
1)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
_completion_cache $flattened_knife_command _get_knife_completions $(( $cword + 1 )) ${words[*]}
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
[[ ${#COMPREPLY[@]} -ge 1 ]] && return 0
|
||||
}
|
||||
complete -F _knife knife
|
@ -0,0 +1,100 @@
|
||||
# GNU make(1) completion
|
||||
# have make || have gmake || have gnumake || have pmake &&
|
||||
_make()
|
||||
{
|
||||
local file makef makef_dir="." makef_inc cur prev i
|
||||
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
# --name value style option
|
||||
case $prev in
|
||||
-@(f|o|W))
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
-@(I|C))
|
||||
_filedir -d
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# --name=value style option
|
||||
if [[ "$cur" == *=* ]]; then
|
||||
prev=${cur/=*/}
|
||||
cur=${cur/*=/}
|
||||
case "$prev" in
|
||||
--@(file|makefile))
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
--@(directory|include-dir))
|
||||
_filedir -d
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
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
|
||||
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
|
||||
if [[ ${COMP_WORDS[i]} == -C ]]; then
|
||||
# eval for tilde expansion
|
||||
eval makef_dir=${COMP_WORDS[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# make reads `GNUmakefile', then `makefile', then `Makefile'
|
||||
if [ -f ${makef_dir}/GNUmakefile ]; then
|
||||
makef=${makef_dir}/GNUmakefile
|
||||
elif [ -f ${makef_dir}/makefile ]; then
|
||||
makef=${makef_dir}/makefile
|
||||
elif [ -f ${makef_dir}/Makefile ]; then
|
||||
makef=${makef_dir}/Makefile
|
||||
else
|
||||
makef=${makef_dir}/*.mk # local convention
|
||||
fi
|
||||
|
||||
# before we scan for targets, see if a Makefile name was
|
||||
# specified with -f
|
||||
for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
|
||||
if [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
# eval for tilde expansion
|
||||
eval makef=${COMP_WORDS[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[ ! -f $makef ] && return 0
|
||||
|
||||
# deal with included Makefiles
|
||||
makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," )
|
||||
|
||||
for file in $makef_inc; do
|
||||
[ -f $file ] && makef="$makef $file"
|
||||
done
|
||||
|
||||
COMPREPLY=( $( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
|
||||
{split($1,A,/ /);for(i in A)print A[i]}' \
|
||||
$makef 2>/dev/null | command grep "^$cur" ))
|
||||
fi
|
||||
} &&
|
||||
complete -f -F _make $filenames make gmake gnumake pmake
|
||||
|
||||
# vim:filetype=sh
|
@ -0,0 +1,510 @@
|
||||
# bash completion for the Mercurial distributed SCM
|
||||
|
||||
# Docs:
|
||||
#
|
||||
# If you source this file from your .bashrc, bash should be able to
|
||||
# complete a command line that uses hg with all the available commands
|
||||
# and options and sometimes even arguments.
|
||||
#
|
||||
# Mercurial allows you to define additional commands through extensions.
|
||||
# Bash should be able to automatically figure out the name of these new
|
||||
# commands and their options. See below for how to define _hg_opt_foo
|
||||
# and _hg_cmd_foo functions to fine-tune the completion for option and
|
||||
# non-option arguments, respectively.
|
||||
#
|
||||
#
|
||||
# Notes about completion for specific commands:
|
||||
#
|
||||
# - the completion function for the email command from the patchbomb
|
||||
# extension will try to call _hg_emails to get a list of e-mail
|
||||
# addresses. It's up to the user to define this function. For
|
||||
# example, put the addresses of the lists that you usually patchbomb
|
||||
# in ~/.patchbomb-to and the addresses that you usually use to send
|
||||
# the patchbombs in ~/.patchbomb-from and use something like this:
|
||||
#
|
||||
# _hg_emails()
|
||||
# {
|
||||
# if [ -r ~/.patchbomb-$1 ]; then
|
||||
# cat ~/.patchbomb-$1
|
||||
# fi
|
||||
# }
|
||||
#
|
||||
#
|
||||
# Writing completion functions for additional commands:
|
||||
#
|
||||
# If it exists, the function _hg_cmd_foo will be called without
|
||||
# arguments to generate the completion candidates for the hg command
|
||||
# "foo". If the command receives some arguments that aren't options
|
||||
# even though they start with a "-", you can define a function called
|
||||
# _hg_opt_foo to generate the completion candidates. If _hg_opt_foo
|
||||
# doesn't return 0, regular completion for options is attempted.
|
||||
#
|
||||
# In addition to the regular completion variables provided by bash,
|
||||
# the following variables are also set:
|
||||
# - $hg - the hg program being used (e.g. /usr/bin/hg)
|
||||
# - $cmd - the name of the hg command being completed
|
||||
# - $cmd_index - the index of $cmd in $COMP_WORDS
|
||||
# - $cur - the current argument being completed
|
||||
# - $prev - the argument before $cur
|
||||
# - $global_args - "|"-separated list of global options that accept
|
||||
# an argument (e.g. '--cwd|-R|--repository')
|
||||
# - $canonical - 1 if we canonicalized $cmd before calling the function
|
||||
# 0 otherwise
|
||||
#
|
||||
|
||||
_hg_commands()
|
||||
{
|
||||
local commands
|
||||
commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands=""
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur"))
|
||||
}
|
||||
|
||||
_hg_paths()
|
||||
{
|
||||
local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')"
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur"))
|
||||
}
|
||||
|
||||
_hg_repos()
|
||||
{
|
||||
local i
|
||||
for i in $(compgen -d -- "$cur"); do
|
||||
test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i")
|
||||
done
|
||||
}
|
||||
|
||||
_hg_status()
|
||||
{
|
||||
local files="$("$hg" status -n$1 . 2>/dev/null)"
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
|
||||
}
|
||||
|
||||
_hg_tags()
|
||||
{
|
||||
local tags="$("$hg" tags -q 2>/dev/null)"
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
|
||||
}
|
||||
|
||||
# this is "kind of" ugly...
|
||||
_hg_count_non_option()
|
||||
{
|
||||
local i count=0
|
||||
local filters="$1"
|
||||
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ "${COMP_WORDS[i]}" != -* ]]; then
|
||||
if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then
|
||||
continue
|
||||
fi
|
||||
count=$(($count + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo $(($count - 1))
|
||||
}
|
||||
|
||||
_hg()
|
||||
{
|
||||
local cur prev cmd cmd_index opts i
|
||||
# global options that receive an argument
|
||||
local global_args='--cwd|-R|--repository'
|
||||
local hg="$1"
|
||||
local canonical=0
|
||||
|
||||
COMPREPLY=()
|
||||
cur="$2"
|
||||
prev="$3"
|
||||
|
||||
# searching for the command
|
||||
# (first non-option argument that doesn't follow a global option that
|
||||
# receives an argument)
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
|
||||
cmd="${COMP_WORDS[i]}"
|
||||
cmd_index=$i
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then
|
||||
return
|
||||
fi
|
||||
|
||||
opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null)
|
||||
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
|
||||
return
|
||||
fi
|
||||
|
||||
# global options
|
||||
case "$prev" in
|
||||
-R|--repository)
|
||||
_hg_paths
|
||||
_hg_repos
|
||||
return
|
||||
;;
|
||||
--cwd)
|
||||
# Stick with default bash completion
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
|
||||
_hg_commands
|
||||
return
|
||||
fi
|
||||
|
||||
# try to generate completion candidates for whatever command the user typed
|
||||
local help
|
||||
if _hg_command_specific; then
|
||||
return
|
||||
fi
|
||||
|
||||
# canonicalize the command name and try again
|
||||
help=$("$hg" help "$cmd" 2>/dev/null)
|
||||
if [ $? -ne 0 ]; then
|
||||
# Probably either the command doesn't exist or it's ambiguous
|
||||
return
|
||||
fi
|
||||
cmd=${help#hg }
|
||||
cmd=${cmd%%[$' \n']*}
|
||||
canonical=1
|
||||
_hg_command_specific
|
||||
}
|
||||
|
||||
_hg_command_specific()
|
||||
{
|
||||
if [ "$(type -t "_hg_cmd_$cmd")" = function ]; then
|
||||
"_hg_cmd_$cmd"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
|
||||
if [ $canonical = 1 ]; then
|
||||
_hg_tags
|
||||
return 0
|
||||
elif [[ status != "$cmd"* ]]; then
|
||||
_hg_tags
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$cmd" in
|
||||
help)
|
||||
_hg_commands
|
||||
;;
|
||||
export)
|
||||
if _hg_ext_mq_patchlist qapplied && [ "${COMPREPLY[*]}" ]; then
|
||||
return 0
|
||||
fi
|
||||
_hg_tags
|
||||
;;
|
||||
manifest|update)
|
||||
_hg_tags
|
||||
;;
|
||||
pull|push|outgoing|incoming)
|
||||
_hg_paths
|
||||
_hg_repos
|
||||
;;
|
||||
paths)
|
||||
_hg_paths
|
||||
;;
|
||||
add)
|
||||
_hg_status "u"
|
||||
;;
|
||||
commit)
|
||||
_hg_status "mar"
|
||||
;;
|
||||
remove)
|
||||
_hg_status "d"
|
||||
;;
|
||||
forget)
|
||||
_hg_status "a"
|
||||
;;
|
||||
diff)
|
||||
_hg_status "mar"
|
||||
;;
|
||||
revert)
|
||||
_hg_status "mard"
|
||||
;;
|
||||
clone)
|
||||
local count=$(_hg_count_non_option)
|
||||
if [ $count = 1 ]; then
|
||||
_hg_paths
|
||||
fi
|
||||
_hg_repos
|
||||
;;
|
||||
debugindex|debugindexdot)
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur"))
|
||||
;;
|
||||
debugdata)
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
|
||||
;;
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o bashdefault -o default -F _hg hg 2>/dev/null \
|
||||
|| complete -o default -F _hg hg
|
||||
|
||||
|
||||
# Completion for commands provided by extensions
|
||||
|
||||
# mq
|
||||
_hg_ext_mq_patchlist()
|
||||
{
|
||||
local patches
|
||||
patches=$("$hg" $1 2>/dev/null)
|
||||
if [ $? -eq 0 ] && [ "$patches" ]; then
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur"))
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
_hg_ext_mq_queues()
|
||||
{
|
||||
local root=$("$hg" root 2>/dev/null)
|
||||
local n
|
||||
for n in $(cd "$root"/.hg && compgen -d -- "$cur"); do
|
||||
# I think we're usually not interested in the regular "patches" queue
|
||||
# so just filter it.
|
||||
if [ "$n" != patches ] && [ -e "$root/.hg/$n/series" ]; then
|
||||
COMPREPLY=(${COMPREPLY[@]:-} "$n")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_hg_cmd_qpop()
|
||||
{
|
||||
if [[ "$prev" = @(-n|--name) ]]; then
|
||||
_hg_ext_mq_queues
|
||||
return
|
||||
fi
|
||||
_hg_ext_mq_patchlist qapplied
|
||||
}
|
||||
|
||||
_hg_cmd_qpush()
|
||||
{
|
||||
if [[ "$prev" = @(-n|--name) ]]; then
|
||||
_hg_ext_mq_queues
|
||||
return
|
||||
fi
|
||||
_hg_ext_mq_patchlist qunapplied
|
||||
}
|
||||
|
||||
_hg_cmd_qgoto()
|
||||
{
|
||||
if [[ "$prev" = @(-n|--name) ]]; then
|
||||
_hg_ext_mq_queues
|
||||
return
|
||||
fi
|
||||
_hg_ext_mq_patchlist qseries
|
||||
}
|
||||
|
||||
_hg_cmd_qdelete()
|
||||
{
|
||||
local qcmd=qunapplied
|
||||
if [[ "$prev" = @(-r|--rev) ]]; then
|
||||
qcmd=qapplied
|
||||
fi
|
||||
_hg_ext_mq_patchlist $qcmd
|
||||
}
|
||||
|
||||
_hg_cmd_qsave()
|
||||
{
|
||||
if [[ "$prev" = @(-n|--name) ]]; then
|
||||
_hg_ext_mq_queues
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
_hg_cmd_strip()
|
||||
{
|
||||
_hg_tags
|
||||
}
|
||||
|
||||
_hg_cmd_qcommit()
|
||||
{
|
||||
local root=$("$hg" root 2>/dev/null)
|
||||
# this is run in a sub-shell, so we can't use _hg_status
|
||||
local files=$(cd "$root/.hg/patches" 2>/dev/null &&
|
||||
"$hg" status -nmar 2>/dev/null)
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
|
||||
}
|
||||
|
||||
_hg_cmd_qfold()
|
||||
{
|
||||
_hg_ext_mq_patchlist qunapplied
|
||||
}
|
||||
|
||||
_hg_cmd_qrename()
|
||||
{
|
||||
_hg_ext_mq_patchlist qseries
|
||||
}
|
||||
|
||||
_hg_cmd_qheader()
|
||||
{
|
||||
_hg_ext_mq_patchlist qseries
|
||||
}
|
||||
|
||||
_hg_cmd_qclone()
|
||||
{
|
||||
local count=$(_hg_count_non_option)
|
||||
if [ $count = 1 ]; then
|
||||
_hg_paths
|
||||
fi
|
||||
_hg_repos
|
||||
}
|
||||
|
||||
_hg_ext_mq_guards()
|
||||
{
|
||||
"$hg" qselect --series 2>/dev/null | sed -e 's/^.//'
|
||||
}
|
||||
|
||||
_hg_cmd_qselect()
|
||||
{
|
||||
local guards=$(_hg_ext_mq_guards)
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$guards' -- "$cur"))
|
||||
}
|
||||
|
||||
_hg_cmd_qguard()
|
||||
{
|
||||
local prefix=''
|
||||
|
||||
if [[ "$cur" == +* ]]; then
|
||||
prefix=+
|
||||
elif [[ "$cur" == -* ]]; then
|
||||
prefix=-
|
||||
fi
|
||||
local ncur=${cur#[-+]}
|
||||
|
||||
if ! [ "$prefix" ]; then
|
||||
_hg_ext_mq_patchlist qseries
|
||||
return
|
||||
fi
|
||||
|
||||
local guards=$(_hg_ext_mq_guards)
|
||||
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -P $prefix -W '$guards' -- "$ncur"))
|
||||
}
|
||||
|
||||
_hg_opt_qguard()
|
||||
{
|
||||
local i
|
||||
for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do
|
||||
if [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
|
||||
_hg_cmd_qguard
|
||||
return 0
|
||||
fi
|
||||
elif [ "${COMP_WORDS[i]}" = -- ]; then
|
||||
_hg_cmd_qguard
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
# hbisect
|
||||
_hg_cmd_bisect()
|
||||
{
|
||||
local i subcmd
|
||||
|
||||
# find the sub-command
|
||||
for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do
|
||||
if [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
|
||||
subcmd="${COMP_WORDS[i]}"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$subcmd" ] || [ $COMP_CWORD -eq $i ] || [ "$subcmd" = help ]; then
|
||||
COMPREPLY=(${COMPREPLY[@]:-}
|
||||
$(compgen -W 'bad good help init next reset' -- "$cur"))
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcmd" in
|
||||
good|bad)
|
||||
_hg_tags
|
||||
;;
|
||||
esac
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
# patchbomb
|
||||
_hg_cmd_email()
|
||||
{
|
||||
case "$prev" in
|
||||
-c|--cc|-t|--to|-f|--from|--bcc)
|
||||
# we need an e-mail address. let the user provide a function
|
||||
# to get them
|
||||
if [ "$(type -t _hg_emails)" = function ]; then
|
||||
local arg=to
|
||||
if [[ "$prev" == @(-f|--from) ]]; then
|
||||
arg=from
|
||||
fi
|
||||
local addresses=$(_hg_emails $arg)
|
||||
COMPREPLY=(${COMPREPLY[@]:-}
|
||||
$(compgen -W '$addresses' -- "$cur"))
|
||||
fi
|
||||
return
|
||||
;;
|
||||
-m|--mbox)
|
||||
# fallback to standard filename completion
|
||||
return
|
||||
;;
|
||||
-s|--subject)
|
||||
# free form string
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
_hg_tags
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
# gpg
|
||||
_hg_cmd_sign()
|
||||
{
|
||||
_hg_tags
|
||||
}
|
||||
|
||||
|
||||
# transplant
|
||||
_hg_cmd_transplant()
|
||||
{
|
||||
case "$prev" in
|
||||
-s|--source)
|
||||
_hg_paths
|
||||
_hg_repos
|
||||
return
|
||||
;;
|
||||
--filter)
|
||||
# standard filename completion
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
# all other transplant options values and command parameters are revisions
|
||||
_hg_tags
|
||||
return
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
function __nosetests_opts(){
|
||||
echo $(
|
||||
nosetests --help 2>/dev/null | \
|
||||
sed "s/, */@@@/g" | \
|
||||
grep -E "^ *-" | \
|
||||
awk '{ print $1 }' | \
|
||||
sed -e "s/@@@/ /" -e "s/,//g" -e "s/=.*//"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
complete -W "$(__nosetests_opts)" -f -o default nosetests
|
||||
|
||||
# vim:filetype=sh
|
@ -0,0 +1,11 @@
|
||||
|
||||
# pip bash completion start
|
||||
_pip_completion()
|
||||
{
|
||||
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
|
||||
COMP_CWORD=$COMP_CWORD \
|
||||
PIP_AUTO_COMPLETE=1 $1 ) )
|
||||
}
|
||||
complete -o default -F _pip_completion pip
|
||||
# pip bash completion end
|
||||
|
@ -0,0 +1,13 @@
|
||||
function __post_review_opts(){
|
||||
post-review --help | grep -E "^ *-" | \
|
||||
awk '/^ *--/ { gsub(/=.*/, "") ; print $1 }
|
||||
/^ *-[^-]/ {
|
||||
gsub(/=.*/, "") ;
|
||||
gsub(/,/, "") ;
|
||||
print $1 "\n" $2
|
||||
}' | grep -v ID
|
||||
}
|
||||
|
||||
which post-review >/dev/null 2>&1 && complete -W "$(__post_review_opts)" -o default post-review
|
||||
|
||||
# vim:filetype=sh
|
@ -0,0 +1,17 @@
|
||||
_get_ssh_hosts(){
|
||||
cat $HOME/.ssh/config | grep '^Host ' | sed "s/Host //"
|
||||
}
|
||||
|
||||
_ssh(){
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
if [ $COMP_CWORD -eq 1 ]; then
|
||||
COMPREPLY=( $( compgen -W "$(_get_ssh_hosts)" $cur ) )
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _ssh -o default ssh
|
||||
complete -F _ssh -o default scp
|
||||
|
||||
|
||||
# vim:filetype=sh
|
@ -0,0 +1,983 @@
|
||||
# Programmable completion for the Subversion svn command under bash. Source
|
||||
# this file (or on some systems add it to ~/.bash_completion and start a new
|
||||
# shell) and bash's completion mechanism will know all about svn's options!
|
||||
# Provides completion for the svnadmin command as well. Who wants to read
|
||||
# man pages/help text...
|
||||
|
||||
# Known to work with bash 2.05a with programmable completion and extended
|
||||
# pattern matching enabled (use 'shopt -s extglob progcomp' to enable
|
||||
# these if they are not already enabled).
|
||||
|
||||
shopt -s extglob
|
||||
|
||||
# Tree helper functions which only use bash, to ease readability.
|
||||
|
||||
# look for value associated to key from stdin in K/V hash file format
|
||||
# val=$(_svn_read_hashfile svn:realmstring < some/file)
|
||||
function _svn_read_hashfile()
|
||||
{
|
||||
local tkey=$1 key= val=
|
||||
while true; do
|
||||
read tag len
|
||||
[ $tag = 'END' ] && break
|
||||
[ $tag != 'K' ] && {
|
||||
#echo "unexpected tag '$tag' instead of 'K'" >&2
|
||||
return
|
||||
}
|
||||
read -r -n $len key ; read
|
||||
read tag len
|
||||
[ $tag != 'V' ] && {
|
||||
#echo "unexpected tag '$tag' instead of 'V'" >&2
|
||||
return
|
||||
}
|
||||
read -r -n $len val ; read
|
||||
if [[ $key = $tkey ]] ; then
|
||||
echo "$val"
|
||||
return
|
||||
fi
|
||||
done
|
||||
#echo "target key '$tkey' not found" >&2
|
||||
}
|
||||
|
||||
# _svn_grcut shell-regular-expression
|
||||
# extract filenames from 'svn status' output
|
||||
function _svn_grcut()
|
||||
{
|
||||
local re=$1 line=
|
||||
while read -r line ; do
|
||||
[[ ! $re || $line == $re ]] && echo ${line/???????/}
|
||||
done
|
||||
}
|
||||
|
||||
# _svn_lls (dir|file|all) files...
|
||||
# list svn-managed files from list
|
||||
# some 'svn status --all-files' would be welcome here?
|
||||
function _svn_lls()
|
||||
{
|
||||
local opt=$1 f=
|
||||
shift
|
||||
for f in "$@" ; do
|
||||
# could try to check in .svn/entries? hmmm...
|
||||
if [[ $opt == @(dir|all) && -d "$f" ]] ; then
|
||||
echo "$f/"
|
||||
elif [[ $opt == @(file|all) ]] ; then
|
||||
# split f in directory/file names
|
||||
local dn= fn="$f"
|
||||
[[ "$f" == */* ]] && dn=${f%\/*}/ fn=${f##*\/}
|
||||
# ??? this does not work for just added files, because they
|
||||
# do not have a content reference yet...
|
||||
[ -f "${dn}.svn/text-base/${fn}.svn-base" ] && echo "$f"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# This completion guides the command/option order along the one suggested
|
||||
# by "svn help", although other syntaxes are allowed.
|
||||
#
|
||||
# - there is a "real" parser to check for what is available and deduce what
|
||||
# can be suggested further.
|
||||
# - the syntax should be coherent with subversion/svn/{cl.h,main.c}
|
||||
# - although it is not a good practice, mixed options and arguments
|
||||
# is supported by the completion as it is by the svn command.
|
||||
# - the completion works in the middle of a line,
|
||||
# but not really in the middle of an argument or option.
|
||||
# - property names are completed: see comments about issues related to handling
|
||||
# ":" within property names although it is a word completion separator.
|
||||
# - unknown properties are assumed to be simple file properties.
|
||||
# - --revprop and --revision options are forced to revision properties
|
||||
# as they are mandatory in this case.
|
||||
# - argument values are suggested to some other options, eg directory names
|
||||
# for --config-dir.
|
||||
# - values for some options can be extended with environment variables:
|
||||
# SVN_BASH_FILE_PROPS: other properties on files/directories
|
||||
# SVN_BASH_REV_PROPS: other properties on revisions
|
||||
# SVN_BASH_ENCODINGS: encodings to be suggested
|
||||
# SVN_BASH_MIME_TYPE: mime types to be suggested
|
||||
# SVN_BASH_KEYWORDS: "svn:keywords" substitutions to be suggested
|
||||
# SVN_BASH_USERNAME: usernames suggested for --username
|
||||
# SVN_BASH_COMPL_EXT: completion extensions for file arguments, based on the
|
||||
# current subcommand, so that for instance only modified files are
|
||||
# suggested for 'revert', only not svn-managed files for 'add', and so on.
|
||||
# Possible values are:
|
||||
# - username: guess usernames from ~/.subversion/auth/...
|
||||
# - svnstatus: use 'svn status' for completion
|
||||
# - recurse: allow recursion (expensive)
|
||||
# - externals: recurse into externals (very expensive)
|
||||
# Both former options are reasonable, but beware that both later options
|
||||
# may be unadvisable if used on large working copies.
|
||||
# None of these costly completions are activated by default.
|
||||
# Argument completion outside a working copy results in an error message.
|
||||
# Filenames with spaces are not completed properly.
|
||||
#
|
||||
# TODO
|
||||
# - other options?
|
||||
# - obsolete options could be removed from auto-comp? (e.g. -N)
|
||||
# - obsolete commands could be removed? (e.g. resolved)
|
||||
_svn()
|
||||
{
|
||||
local cur cmds cmdOpts pOpts mOpts rOpts qOpts nOpts optsParam opt
|
||||
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
# Possible expansions, without pure-prefix abbreviations such as "up".
|
||||
cmds='add blame annotate praise cat changelist cl \
|
||||
checkout co cleanup commit ci \
|
||||
copy cp delete remove rm diff export help import info \
|
||||
list ls lock log merge mergeinfo mkdir move mv rename \
|
||||
propdel pdel propedit pedit propget pget \
|
||||
proplist plist propset pset resolve resolved revert \
|
||||
status switch unlock update'
|
||||
|
||||
# help options have a strange command status...
|
||||
local helpOpts='--help -h'
|
||||
# all special options that have a command status
|
||||
local specOpts="--version $helpOpts"
|
||||
|
||||
# options that require a parameter
|
||||
# note: continued lines must end '|' continuing lines must start '|'
|
||||
optsParam="-r|--revision|--username|--password|--targets|
|
||||
|-x|--extensions|-m|--message|-F|--file|--encoding|
|
||||
|--diff-cmd|--diff3-cmd|--editor-cmd|--old|--new|
|
||||
|--config-dir|--native-eol|-l|--limit|-c|--change|--depth|
|
||||
|--with-revprop|--changelist|--accept"
|
||||
|
||||
# svn:* and other (env SVN_BASH_*_PROPS) properties
|
||||
local svnProps revProps allProps psCmds propCmds
|
||||
|
||||
# svn and user configured file properties
|
||||