Cleaning out a bunch of stuff I don't use
This commit is contained in:
parent
c2f040565b
commit
1cb6c73d4b
@ -1,71 +0,0 @@
|
||||
#!/bin/bash
|
||||
# This file is meant to be *sourced*, not executed.
|
||||
|
||||
USAGE="Usage: source $HOME/.activate_proj <proj>"
|
||||
|
||||
function __run_activate(){
|
||||
if [[ ! -n "${1}" ]] ; then
|
||||
echo $USAGE
|
||||
return 1
|
||||
fi
|
||||
|
||||
PROJ=${1}
|
||||
local PROJDIR="${HOME}/src/${PROJ}"
|
||||
|
||||
if [[ ! -d "$PROJDIR" ]] ; then
|
||||
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
|
||||
return 2
|
||||
fi
|
||||
|
||||
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=""
|
||||
}
|
||||
|
||||
__run_activate "$@"
|
||||
unset __run_activate
|
||||
|
||||
# vim:ft=sh
|
31
bash_aliases
31
bash_aliases
@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
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 rbi='rbenv_init'
|
||||
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"
|
||||
alias tmux='TERM=xterm-256color tmux -2'
|
||||
|
||||
case "$(uname | tr '[:upper:]' '[:lower:]')" in
|
||||
darwin)
|
||||
alias l='ls -GF'
|
||||
;;
|
||||
*)
|
||||
alias l='ls -F --color=auto'
|
||||
;;
|
||||
esac
|
||||
|
||||
# vim:filetype=sh
|
@ -1,36 +0,0 @@
|
||||
LOCAL_BASH_COMPLETION_DIR=$HOME/.bash_completion.d
|
||||
|
||||
_debug()
|
||||
{
|
||||
test -n "$DEBUG" && echo "$1"
|
||||
}
|
||||
|
||||
|
||||
_source_local_bash_completion()
|
||||
{
|
||||
# source completion directory definitions
|
||||
if [ -n "$(complete | grep "__proj_activate")" ]
|
||||
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
|
@ -1,9 +0,0 @@
|
||||
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
@ -1,49 +0,0 @@
|
||||
# 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
|
@ -1,53 +0,0 @@
|
||||
# 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
|
@ -1,25 +0,0 @@
|
||||
# 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
|
@ -1,127 +0,0 @@
|
||||
# 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
|
@ -1,100 +0,0 @@
|
||||
# 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
|
@ -1,510 +0,0 @@
|
||||
# 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
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
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
|
@ -1,11 +0,0 @@
|
||||
|
||||
# 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
|
||||
|
@ -1,13 +0,0 @@
|
||||
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
|
@ -1,17 +0,0 @@
|
||||
_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
|
@ -1,983 +0,0 @@
|
||||
# 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
|
||||
svnProps="svn:keywords svn:executable svn:needs-lock svn:externals
|
||||
svn:ignore svn:eol-style svn:mime-type $SVN_BASH_FILE_PROPS"
|
||||
|
||||
# svn and user configured revision properties
|
||||
revProps="svn:author svn:log svn:date $SVN_BASH_REV_PROPS"
|
||||
|
||||
# all properties as an array variable
|
||||
allProps=( $svnProps $revProps )
|
||||
|
||||
# subcommands that expect property names
|
||||
psCmds='propset|pset|ps'
|
||||
propCmds="$psCmds|propget|pget|pg|propedit|pedit|pe|propdel|pdel|pd"
|
||||
|
||||
# Parse arguments and set various variables about what was found.
|
||||
#
|
||||
# cmd: the current command if available
|
||||
# isPropCmd: whether it expects a property name argument
|
||||
# isPsCmd: whether it also expects a property value argument
|
||||
# isHelpCmd: whether it is about help
|
||||
# nExpectArgs: how many arguments are expected by the command
|
||||
# help: help requested about this command (if cmd=='help')
|
||||
# prop: property name (if appropriate)
|
||||
# isRevProp: is it a special revision property
|
||||
# val: property value (if appropriate, under pset)
|
||||
# options: all options encountered
|
||||
# hasRevPropOpt: is --revprop set
|
||||
# hasRevisionOpt: is --revision set
|
||||
# hasRelocateOpt: is --relocate set
|
||||
# acceptOpt: the value of --accept
|
||||
# nargs: how many arguments were found
|
||||
# stat: status of parsing at the 'current' word
|
||||
#
|
||||
# prev: previous command in the loop
|
||||
# last: status of last parameter analyzed
|
||||
# i: index
|
||||
local cmd= isPropCmd= isPsCmd= isHelpCmd= nExpectArgs= isCur= i=0
|
||||
local prev= help= prop= val= isRevProp= last='none' nargs=0 stat=
|
||||
local options= hasRevPropOpt= hasRevisionOpt= hasRelocateOpt=
|
||||
local acceptOpt=
|
||||
|
||||
for opt in "${COMP_WORDS[@]}"
|
||||
do
|
||||
# get status of current word (from previous iteration)
|
||||
[[ $isCur ]] && stat=$last
|
||||
|
||||
# are we processing the current word
|
||||
isCur=
|
||||
[[ $i -eq $COMP_CWORD ]] && isCur=1
|
||||
let i++
|
||||
|
||||
# FIRST must be the "svn" command
|
||||
[ $last = 'none' ] && { last='first'; continue ; }
|
||||
|
||||
# SKIP option arguments
|
||||
if [[ $prev == @($optsParam) ]] ; then
|
||||
|
||||
# record accept value
|
||||
[[ $prev = '--accept' ]] && acceptOpt=$opt
|
||||
|
||||
prev=''
|
||||
last='skip'
|
||||
continue ;
|
||||
fi
|
||||
|
||||
# Argh... This looks like a bashbug...
|
||||
# Redirections are passed to the completion function
|
||||
# although it is managed by the shell directly...
|
||||
# It matters because we want to tell the user when no more
|
||||
# completion is available, so it does not necessary
|
||||
# fallback to the default case.
|
||||
if [[ $prev == @(<|>|>>|[12]>|[12]>>) ]] ; then
|
||||
prev=''
|
||||
last='skip'
|
||||
continue ;
|
||||
fi
|
||||
prev=$opt
|
||||
|
||||
# get the subCoMmanD
|
||||
if [[ ! $cmd && $opt \
|
||||
&& ( $opt != -* || $opt == @(${specOpts// /|}) ) ]]
|
||||
then
|
||||
cmd=$opt
|
||||
[[ $cmd == @($propCmds) ]] && isPropCmd=1
|
||||
[[ $cmd == @($psCmds) ]] && isPsCmd=1
|
||||
[[ $cmd == @(${helpOpts// /|}) ]] && cmd='help'
|
||||
[[ $cmd = 'help' ]] && isHelpCmd=1
|
||||
# HELP about a command asked with an option
|
||||
if [[ $isHelpCmd && $cmd && $cmd != 'help' && ! $help ]]
|
||||
then
|
||||
help=$cmd
|
||||
cmd='help'
|
||||
fi
|
||||
last='cmd'
|
||||
continue
|
||||
fi
|
||||
|
||||
# HELP about a command
|
||||
if [[ $isHelpCmd && ! $help && $opt && $opt != -* ]]
|
||||
then
|
||||
help=$opt
|
||||
last='help'
|
||||
continue
|
||||
fi
|
||||
|
||||
# PROPerty name
|
||||
if [[ $isPropCmd && ! $prop && $opt && $opt != -* ]]
|
||||
then
|
||||
prop=$opt
|
||||
[[ $prop == @(${revProps// /|}) ]] && isRevProp=1
|
||||
last='prop'
|
||||
continue
|
||||
fi
|
||||
|
||||
# property VALue
|
||||
if [[ $isPsCmd && $prop && ! $val && $opt != -* ]] ;
|
||||
then
|
||||
val=$opt
|
||||
last='val'
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ $last != 'onlyarg' ]]
|
||||
then
|
||||
# more OPTions
|
||||
case $opt in
|
||||
-r|--revision|--revision=*)
|
||||
hasRevisionOpt=1
|
||||
;;
|
||||
--revprop)
|
||||
hasRevPropOpt=1
|
||||
# restrict to revision properties!
|
||||
allProps=( $revProps )
|
||||
# on revprops, only one URL is expected
|
||||
nExpectArgs=1
|
||||
;;
|
||||
-h|--help)
|
||||
isHelpCmd=1
|
||||
;;
|
||||
-F|--file)
|
||||
val='-F'
|
||||
;;
|
||||
--relocate)
|
||||
hasRelocateOpt=1
|
||||
;;
|
||||
esac
|
||||
|
||||
# no more options, only arguments, whatever they look like.
|
||||
if [[ $opt = '--' && ! $isCur ]] ; then
|
||||
last='onlyarg'
|
||||
continue
|
||||
fi
|
||||
|
||||
# options are recorded...
|
||||
if [[ $opt == -* ]] ; then
|
||||
# but not the current one!
|
||||
[[ ! $isCur ]] && options="$options $opt "
|
||||
last='opt'
|
||||
continue
|
||||
fi
|
||||
else
|
||||
# onlyarg
|
||||
let nargs++
|
||||
continue
|
||||
fi
|
||||
|
||||
# then we have an argument
|
||||
last='arg'
|
||||
let nargs++
|
||||
done
|
||||
[[ $stat ]] || stat=$last
|
||||
|
||||
# suggest all subcommands, including special help
|
||||
if [[ ! $cmd || $stat = 'cmd' ]]
|
||||
then
|
||||
COMPREPLY=( $( compgen -W "$cmds $specOpts" -- $cur ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# suggest all subcommands
|
||||
if [[ $stat = 'help' || ( $isHelpCmd && ! $help ) ]]
|
||||
then
|
||||
COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# help about option arguments
|
||||
if [[ $stat = 'skip' ]]
|
||||
then
|
||||
local previous=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local values= dirs= beep=
|
||||
|
||||
[[ $previous = '--config-dir' ]] && dirs=1
|
||||
|
||||
[[ $previous = '--native-eol' ]] && values='LF CR CRLF'
|
||||
|
||||
# just to suggest that a number is expected. hummm.
|
||||
[[ $previous = '--limit' ]] && values='0 1 2 3 4 5 6 7 8 9'
|
||||
|
||||
# some special partial help about --revision option.
|
||||
[[ $previous = '--revision' || $previous = '-r' ]] && \
|
||||
values='HEAD BASE PREV COMMITTED 0 {'
|
||||
|
||||
[[ $previous = '--encoding' ]] && \
|
||||
values="latin1 utf8 $SVN_BASH_ENCODINGS"
|
||||
|
||||
[[ $previous = '--extensions' || $previous = '-x' ]] && \
|
||||
values="--unified --ignore-space-change \
|
||||
--ignore-all-space --ignore-eol-style"
|
||||
|
||||
[[ $previous = '--depth' ]] && \
|
||||
values='empty files immediates infinity'
|
||||
|
||||
[[ $previous = '--accept' ]] && \
|
||||
{
|
||||
# the list is different for 'resolve'
|
||||
if [[ $cmd = 'resolve' ]] ; then
|
||||
# from svn help resolve
|
||||
values='base working mine-full theirs-full'
|
||||
else # checkout merge switch update
|
||||
# not implemented yet: mine-conflict theirs-conflict
|
||||
values='postpone base mine-full theirs-full edit launch'
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $previous = '--username' ]] ; then
|
||||
values="$SVN_BASH_USERNAME"
|
||||
if [[ $SVN_BASH_COMPL_EXT == *username* ]] ; then
|
||||
local file=
|
||||
# digest? others?
|
||||
for file in ~/.subversion/auth/svn.simple/* ; do
|
||||
if [ -r $file ] ; then
|
||||
values="$values $(_svn_read_hashfile username < $file)"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
[[ ! "$values" ]] && beep=1
|
||||
fi
|
||||
|
||||
# could look at ~/.subversion/ ?
|
||||
# hmmm... this option should not exist
|
||||
[[ $previous = '--password' ]] && beep=1
|
||||
|
||||
# TODO: provide help about other options such as:
|
||||
# --old --new --with-revprop
|
||||
|
||||
# if the previous option required a parameter, do something
|
||||
# or fallback on ordinary filename expansion
|
||||
[[ $values ]] && COMPREPLY=( $( compgen -W "$values" -- $cur ) )
|
||||
[[ $dirs ]] && COMPREPLY=( $( compgen -o dirnames -- $cur ) )
|
||||
[[ $beep ]] &&
|
||||
{
|
||||
# 'no known completion'. hummm.
|
||||
echo -en "\a"
|
||||
COMPREPLY=( '' )
|
||||
}
|
||||
return 0
|
||||
fi
|
||||
|
||||
# provide allowed property names after property commands
|
||||
if [[ $isPropCmd && ( ! $prop || $stat = 'prop' ) && $cur != -* ]]
|
||||
then
|
||||
#
|
||||
# Ok, this part is pretty ugly.
|
||||
#
|
||||
# The issue is that ":" is a completion word separator,
|
||||
# which is a good idea for file:// urls but not within
|
||||
# property names...
|
||||
#
|
||||
# The first idea was to remove locally ":" from COMP_WORDBREAKS
|
||||
# and then put it back in all cases but in property name
|
||||
# completion. It does not always work. There is a strange bug
|
||||
# where one may get "svn:svn:xxx" in some unclear cases.
|
||||
#
|
||||
# Thus the handling is reprogrammed here...
|
||||
# The code assumes that property names look like *:*,
|
||||
# but it also works reasonably well with simple names.
|
||||
local choices=
|
||||
|
||||
if [[ $cur == *:* ]]
|
||||
then
|
||||
# only suggest/show possible suffixes
|
||||
local prefix=${cur%:*} suffix=${cur#*:} c=
|
||||
for c in ${allProps[@]} ; do
|
||||
[[ $c == $prefix:* ]] && choices="$choices ${c#*:}"
|
||||
done
|
||||
# everything will be appended to the prefix because ':' is
|
||||
# a separator, so cur is restricted to the suffix part.
|
||||
cur=$suffix
|
||||
else
|
||||
# only one choice is fine
|
||||
COMPREPLY=( $( compgen -W "${allProps[*]}" -- $cur ) )
|
||||
[ ${#COMPREPLY[@]} -eq 1 ] && return 0
|
||||
|
||||
# no ':' so only suggest prefixes?
|
||||
local seen= n=0 last= c=
|
||||
for c in ${allProps[@]%:*} ; do
|
||||
# do not put the same prefix twice...
|
||||
if [[ $c == $cur* && ( ! $seen || $c != @($seen) ) ]]
|
||||
then
|
||||
let n++
|
||||
last=$c
|
||||
choices="$choices $c:"
|
||||
if [[ $seen ]]
|
||||
then
|
||||
seen="$seen|$c*"
|
||||
else
|
||||
seen="$c*"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# supply two choices to force a partial completion and a beep
|
||||
[[ $n -eq 1 ]] && choices="$last:1 $last:2"
|
||||
fi
|
||||
|
||||
COMPREPLY=( $( compgen -W "$choices" -- $cur ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# force mandatory --revprop option on revision properties
|
||||
if [[ $isRevProp && ! $hasRevPropOpt ]]
|
||||
then
|
||||
COMPREPLY=( $( compgen -W '--revprop' -- $cur ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# force mandatory --revision option on revision properties
|
||||
if [[ $isRevProp && $hasRevPropOpt && ! $hasRevisionOpt ]]
|
||||
then
|
||||
COMPREPLY=( $( compgen -W '--revision' -- $cur ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# possible completion when setting property values
|
||||
if [[ $isPsCmd && $prop && ( ! $val || $stat = 'val' ) ]]
|
||||
then
|
||||
# ' is a reminder for an arbitrary value
|
||||
local values="\' --file"
|
||||
case $prop in
|
||||
svn:keywords)
|
||||
# just a subset?
|
||||
values="Id Rev URL Date Author \' $SVN_BASH_KEYWORDS"
|
||||
;;
|
||||
svn:executable|svn:needs-lock)
|
||||
# hmmm... canonical value * is special to the shell.
|
||||
values='\\*'
|
||||
;;
|
||||
svn:eol-style)
|
||||
values='native LF CR CRLF'
|
||||
;;
|
||||
svn:mime-type)
|
||||
# could read /etc/mime.types if available. overkill.
|
||||
values="text/ text/plain text/html text/xml text/rtf
|
||||
image/ image/png image/gif image/jpeg image/tiff
|
||||
audio/ audio/midi audio/mpeg
|
||||
video/ video/mpeg video/mp4
|
||||
application/ application/octet-stream
|
||||
$SVN_BASH_MIME_TYPE"
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $( compgen -W "$values" -- $cur ) )
|
||||
# special case for --file... return even if within an option
|
||||
[[ ${COMPREPLY} ]] && return 0
|
||||
fi
|
||||
|
||||
# force mandatory --accept option for 'resolve' command
|
||||
if [[ $cmd = 'resolve' && ! $acceptOpt ]]
|
||||
then
|
||||
COMPREPLY=( $( compgen -W '--accept' -- $cur ) )
|
||||
# force option now! others will be available on later completions
|
||||
return 0
|
||||
fi
|
||||
|
||||
# maximum number of additional arguments expected in various forms
|
||||
case $cmd in
|
||||
merge)
|
||||
nExpectArgs=3
|
||||
;;
|
||||
mergeinfo)
|
||||
nExpectArgs=1
|
||||
;;
|
||||
copy|cp|move|mv|rename|ren|export|import)
|
||||
nExpectArgs=2
|
||||
;;
|
||||
switch|sw)
|
||||
[[ ! $hasRelocateOpt ]] && nExpectArgs=2
|
||||
;;
|
||||
help|h)
|
||||
nExpectArgs=0
|
||||
;;
|
||||
--version)
|
||||
nExpectArgs=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# the maximum number of arguments is reached for a command
|
||||
if [[ $nExpectArgs && $nargs -gt $nExpectArgs ]]
|
||||
then
|
||||
# some way to tell 'no completion at all'... is there a better one?
|
||||
# Do not say 'file completion' here.
|
||||
echo -en "\a"
|
||||
COMPREPLY=( '' )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if not typing an option,
|
||||
# then fallback on filename expansion...
|
||||
if [[ $cur != -* || $stat = 'onlyarg' ]] ; then
|
||||
|
||||
# do we allow possible expensive completion here?
|
||||
if [[ $SVN_BASH_COMPL_EXT == *svnstatus* ]] ; then
|
||||
|
||||
# build status command and options
|
||||
# "--quiet" removes 'unknown' files
|
||||
local status='svn status --non-interactive'
|
||||
|
||||
[[ $SVN_BASH_COMPL_EXT == *recurse* ]] || \
|
||||
status="$status --non-recursive"
|
||||
|
||||
# I'm not sure that it can work with externals in call cases
|
||||
# the output contains translatable sentences (even with quiet)
|
||||
[[ $SVN_BASH_COMPL_EXT == *externals* ]] || \
|
||||
status="$status --ignore-externals"
|
||||
|
||||
local cs= files=
|
||||
# subtlety: must not set $cur* if $cur is empty in some cases
|
||||
[[ $cur ]] && cs=$cur*
|
||||
|
||||
# 'files' is set according to the current subcommand
|
||||
case $cmd in
|
||||
st*) # status completion must include all files
|
||||
files=$cur*
|
||||
;;
|
||||
ci|commit|revert|di*) # anything edited
|
||||
files=$($status $cs| _svn_grcut '@([MADR!]*| M*|_M*)')
|
||||
;;
|
||||
add) # unknown files
|
||||
files=$($status $cs| _svn_grcut '\?*')
|
||||
;;
|
||||
unlock) # unlock locked files
|
||||
files=$($status $cs| _svn_grcut '@(??L*|?????[KOTB]*)')
|
||||
;;
|
||||
resolve*) # files in conflict
|
||||
files=$($status $cs| _svn_grcut '@(?C*|C*)')
|
||||
;;
|
||||
praise|blame|ann*) # any svn file but added
|
||||
files=$( _svn_lls all $cur* )
|
||||
;;
|
||||
p*) # prop commands
|
||||
if [[ $cmd == @($propCmds) && \
|
||||
$prop == @(svn:ignore|svn:externals) ]] ; then
|
||||
# directory specific props
|
||||
files=$( _svn_lls dir . $cur* )
|
||||
else
|
||||
# ??? added directories appear twice: foo foo/
|
||||
files="$( _svn_lls all $cur* )
|
||||
$($status $cs | _svn_grcut 'A*' )"
|
||||
fi
|
||||
;;
|
||||
info) # information on any file
|
||||
files="$( _svn_lls all $cur* )
|
||||
$($status $cs | _svn_grcut 'A*' )"
|
||||
;;
|
||||
remove|rm|del*|move|mv|rename) # changing existing files
|
||||
files=$( _svn_lls all $cur* )
|
||||
;;
|
||||
mkdir) # completion in mkdir can only be for subdirs?
|
||||
files=$( _svn_lls dir $cur* )
|
||||
;;
|
||||
log|lock|up*|cl*|switch) # misc, all but added files
|
||||
files=$( _svn_lls all $cur* )
|
||||
;;
|
||||
merge) # may do a better job? URL/WCPATH
|
||||
files=$( _svn_lls all $cur* )
|
||||
;;
|
||||
ls|list) # better job? what about URLs?
|
||||
files=$( _svn_lls all $cur* )
|
||||
;;
|
||||
*) # other commands: changelist export import cat mergeinfo
|
||||
local fallback=1
|
||||
;;
|
||||
esac
|
||||
|
||||
# when not recursive, some relevant files may exist
|
||||
# within subdirectories, so they are added here.
|
||||
# should it be restricted to svn-managed subdirs? no??
|
||||
if [[ $SVN_BASH_COMPL_EXT != *recurse* ]] ; then
|
||||
files="$files $( _svn_lls dir $cur* )"
|
||||
fi
|
||||
|
||||
# set completion depending on computed 'files'
|
||||
if [[ $files ]] ; then
|
||||
COMPREPLY=( $( compgen -W "$files" -- $cur ) )
|
||||
# if empty, set to nope?
|
||||
[[ "${COMPREPLY[*]}" ]] || COMPREPLY=( '' )
|
||||
elif [[ ! $fallback ]] ; then
|
||||
# this suggests no completion...
|
||||
echo -en "\a"
|
||||
COMPREPLY=( '' )
|
||||
fi
|
||||
fi
|
||||
# else fallback to ordinary filename completion...
|
||||
return 0
|
||||
fi
|
||||
|
||||
# otherwise build possible options for the command
|
||||
pOpts="--username --password --no-auth-cache --non-interactive"
|
||||
mOpts="-m --message -F --file --encoding --force-log --with-revprop"
|
||||
rOpts="-r --revision"
|
||||
qOpts="-q --quiet"
|
||||
nOpts="-N --non-recursive --depth"
|
||||
gOpts="-g --use-merge-history"
|
||||
|
||||
cmdOpts=
|
||||
case $cmd in
|
||||
--version)
|
||||
cmdOpts="$qOpts"
|
||||
;;
|
||||
add)
|
||||
cmdOpts="--auto-props --no-auto-props --force --targets \
|
||||
--no-ignore --parents $nOpts $qOpts $pOpts"
|
||||
;;
|
||||
blame|annotate|ann|praise)
|
||||
cmdOpts="$rOpts $pOpts -v --verbose --incremental --xml \
|
||||
-x --extensions --force $gOpts"
|
||||
;;
|
||||
cat)
|
||||
cmdOpts="$rOpts $pOpts"
|
||||
;;
|
||||
changelist|cl)
|
||||
cmdOpts="--targets $pOpts $qOpts --changelist \
|
||||
-R --recursive --depth --remove"
|
||||
;;
|
||||
checkout|co)
|
||||
cmdOpts="$rOpts $qOpts $nOpts $pOpts --ignore-externals \
|
||||
--force --accept"
|
||||
;;
|
||||
cleanup)
|
||||
cmdOpts="--diff3-cmd $pOpts"
|
||||
;;
|
||||
commit|ci)
|
||||
cmdOpts="$mOpts $qOpts $nOpts --targets --editor-cmd $pOpts \
|
||||
--no-unlock --changelist --keep-changelists"
|
||||
;;
|
||||
copy|cp)
|
||||
cmdOpts="$mOpts $rOpts $qOpts --editor-cmd $pOpts --parents"
|
||||
;;
|
||||
delete|del|remove|rm)
|
||||
cmdOpts="--force $mOpts $qOpts --targets --editor-cmd $pOpts \
|
||||
--keep-local"
|
||||
;;
|
||||
diff|di)
|
||||
cmdOpts="$rOpts -x --extensions --diff-cmd --no-diff-deleted \
|
||||
$nOpts $pOpts --force --old --new --notice-ancestry \
|
||||
-c --change --summarize --changelist --xml"
|
||||
;;
|
||||
export)
|
||||
cmdOpts="$rOpts $qOpts $pOpts $nOpts --force --native-eol \
|
||||
--ignore-externals"
|
||||
;;
|
||||
help|h|\?)
|
||||
cmdOpts=
|
||||
;;
|
||||
import)
|
||||
cmdOpts="--auto-props --no-auto-props $mOpts $qOpts $nOpts \
|
||||
--no-ignore --editor-cmd $pOpts --force"
|
||||
;;
|
||||
info)
|
||||
cmdOpts="$pOpts $rOpts --targets -R --recursive --depth \
|
||||
--incremental --xml --changelist"
|
||||
;;
|
||||
list|ls)
|
||||
cmdOpts="$rOpts -v --verbose -R --recursive $pOpts \
|
||||
--incremental --xml --depth"
|
||||
;;
|
||||
lock)
|
||||
cmdOpts="-m --message -F --file --encoding --force-log \
|
||||
--targets --force $pOpts"
|
||||
;;
|
||||
log)
|
||||
cmdOpts="$rOpts -v --verbose --targets $pOpts --stop-on-copy \
|
||||
--incremental --xml $qOpts -l --limit -c --change \
|
||||
$gOpts --with-all-revprops --with-revprop"
|
||||
;;
|
||||
merge)
|
||||
cmdOpts="$rOpts $nOpts $qOpts --force --dry-run --diff3-cmd \
|
||||
$pOpts --ignore-ancestry -c --change -x --extensions \
|
||||
--record-only --accept --reintegrate"
|
||||
;;
|
||||
mergeinfo)
|
||||
cmdOpts="$rOpts $pOpts --show-revs"
|
||||
;;
|
||||
mkdir)
|
||||
cmdOpts="$mOpts $qOpts --editor-cmd $pOpts --parents"
|
||||
;;
|
||||
move|mv|rename|ren)
|
||||
cmdOpts="$mOpts $rOpts $qOpts --force --editor-cmd $pOpts \
|
||||
--parents"
|
||||
;;
|
||||
propdel|pdel|pd)
|
||||
cmdOpts="$qOpts -R --recursive $rOpts $pOpts --changelist \
|
||||
--depth"
|
||||
[[ $isRevProp || ! $prop ]] && cmdOpts="$cmdOpts --revprop"
|
||||
;;
|
||||
propedit|pedit|pe)
|
||||
cmdOpts="--editor-cmd $pOpts $mOpts --force"
|
||||
[[ $isRevProp || ! $prop ]] && \
|
||||
cmdOpts="$cmdOpts --revprop $rOpts"
|
||||
;;
|
||||
propget|pget|pg)
|
||||
cmdOpts="-R --recursive $rOpts --strict $pOpts --changelist \
|
||||
--depth --xml"
|
||||
[[ $isRevProp || ! $prop ]] && cmdOpts="$cmdOpts --revprop"
|
||||
;;
|
||||
proplist|plist|pl)
|
||||
cmdOpts="-v --verbose -R --recursive $rOpts --revprop $qOpts \
|
||||
$pOpts --changelist --depth --xml"
|
||||
;;
|
||||
propset|pset|ps)
|
||||
cmdOpts="$qOpts --targets -R --recursive \
|
||||
--encoding $pOpts --force --changelist --depth"
|
||||
[[ $isRevProp || ! $prop ]] && \
|
||||
cmdOpts="$cmdOpts --revprop $rOpts"
|
||||
[[ $val ]] || cmdOpts="$cmdOpts -F --file"
|
||||
;;
|
||||
resolve)
|
||||
cmdOpts="--targets -R --recursive $qOpts $pOpts --accept \
|
||||
--depth"
|
||||
;;
|
||||
resolved)
|
||||
cmdOpts="--targets -R --recursive $qOpts $pOpts --depth"
|
||||
;;
|
||||
revert)
|
||||
cmdOpts="--targets -R --recursive $qOpts --changelist \
|
||||
--depth $pOpts"
|
||||
;;
|
||||
status|stat|st)
|
||||
cmdOpts="-u --show-updates -v --verbose $nOpts $qOpts $pOpts \
|
||||
--no-ignore --ignore-externals --incremental --xml \
|
||||
--changelist"
|
||||
;;
|
||||
switch|sw)
|
||||
cmdOpts="--relocate $rOpts $nOpts $qOpts $pOpts --diff3-cmd \
|
||||
--force --accept --ignore-externals --set-depth"
|
||||
;;
|
||||
unlock)
|
||||
cmdOpts="--targets --force $pOpts"
|
||||
;;
|
||||
update|up)
|
||||
cmdOpts="$rOpts $nOpts $qOpts $pOpts --diff3-cmd \
|
||||
--ignore-externals --force --accept --changelist \
|
||||
--editor-cmd --set-depth"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# add options that are nearly always available
|
||||
[[ "$cmd" != "--version" ]] && cmdOpts="$cmdOpts $helpOpts"
|
||||
cmdOpts="$cmdOpts --config-dir"
|
||||
|
||||
# --accept (edit|launch) incompatible with --non-interactive
|
||||
if [[ $acceptOpt == @(edit|launch) ]] ;
|
||||
then
|
||||
cmdOpts=${cmdOpts/ --non-interactive / }
|
||||
fi
|
||||
|
||||
# take out options already given
|
||||
for opt in $options
|
||||
do
|
||||
local optBase
|
||||
|
||||
# remove leading dashes and arguments
|
||||
case $opt in
|
||||
--*) optBase=${opt/=*/} ;;
|
||||
-*) optBase=${opt:0:2} ;;
|
||||
esac
|
||||
|
||||
cmdOpts=" $cmdOpts "
|
||||
cmdOpts=${cmdOpts/ ${optBase} / }
|
||||
|
||||
# take out alternatives and mutually exclusives
|
||||
case $optBase in
|
||||
-v) cmdOpts=${cmdOpts/ --verbose / } ;;
|
||||
--verbose) cmdOpts=${cmdOpts/ -v / } ;;
|
||||
-N) cmdOpts=${cmdOpts/ --non-recursive / } ;;
|
||||
--non-recursive) cmdOpts=${cmdOpts/ -N / } ;;
|
||||
-R) cmdOpts=${cmdOpts/ --recursive / } ;;
|
||||
--recursive) cmdOpts=${cmdOpts/ -R / } ;;
|
||||
-x) cmdOpts=${cmdOpts/ --extensions / } ;;
|
||||
--extensions) cmdOpts=${cmdOpts/ -x / } ;;
|
||||
-q) cmdOpts=${cmdOpts/ --quiet / } ;;
|
||||
--quiet) cmdOpts=${cmdOpts/ -q / } ;;
|
||||
-h) cmdOpts=${cmdOpts/ --help / } ;;
|
||||
--help) cmdOpts=${cmdOpts/ -h / } ;;
|
||||
-l) cmdOpts=${cmdOpts/ --limit / } ;;
|
||||
--limit) cmdOpts=${cmdOpts/ -l / } ;;
|
||||
-r) cmdOpts=${cmdOpts/ --revision / } ;;
|
||||
--revision) cmdOpts=${cmdOpts/ -r / } ;;
|
||||
-c) cmdOpts=${cmdOpts/ --change / } ;;
|
||||
--change) cmdOpts=${cmdOpts/ -c / } ;;
|
||||
--auto-props) cmdOpts=${cmdOpts/ --no-auto-props / } ;;
|
||||
--no-auto-props) cmdOpts=${cmdOpts/ --auto-props / } ;;
|
||||
-g) cmdOpts=${cmdOpts/ --use-merge-history / } ;;
|
||||
--use-merge-history)
|
||||
cmdOpts=${cmdOpts/ -g / } ;;
|
||||
-m|--message|-F|--file)
|
||||
cmdOpts=${cmdOpts/ --message / }
|
||||
cmdOpts=${cmdOpts/ -m / }
|
||||
cmdOpts=${cmdOpts/ --file / }
|
||||
cmdOpts=${cmdOpts/ -F / }
|
||||
;;
|
||||
esac
|
||||
|
||||
# remove help options within help subcommand
|
||||
if [ $isHelpCmd ] ; then
|
||||
cmdOpts=${cmdOpts/ -h / }
|
||||
cmdOpts=${cmdOpts/ --help / }
|
||||
fi
|
||||
done
|
||||
|
||||
# provide help about available options
|
||||
COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) )
|
||||
return 0
|
||||
}
|
||||
complete -F _svn -o default -X '@(*/.svn|*/.svn/|.svn|.svn/)' svn
|
||||
|
||||
_svnadmin ()
|
||||
{
|
||||
local cur cmds cmdOpts optsParam opt helpCmds optBase i
|
||||
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
# Possible expansions, without pure-prefix abbreviations such as "h".
|
||||
cmds='crashtest create deltify dump help hotcopy list-dblogs \
|
||||
list-unused-dblogs load lslocks lstxns recover rmlocks \
|
||||
rmtxns setlog setrevprop setuuid upgrade verify --version'
|
||||
|
||||
if [[ $COMP_CWORD -eq 1 ]] ; then
|
||||
COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
|
||||
return 0
|
||||
fi
|
||||
|
||||
# options that require a parameter
|
||||
# note: continued lines must end '|' continuing lines must start '|'
|
||||
optsParam="-r|--revision|--parent-dir|--fs-type"
|
||||
|
||||
# if not typing an option, or if the previous option required a
|
||||
# parameter, then fallback on ordinary filename expansion
|
||||
helpCmds='help|--help|h|\?'
|
||||
if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \
|
||||
[[ "$cur" != -* ]] || \
|
||||
[[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
cmdOpts=
|
||||
case ${COMP_WORDS[1]} in
|
||||
create)
|
||||
cmdOpts="--bdb-txn-nosync --bdb-log-keep --config-dir \
|
||||
--fs-type --pre-1.4-compatible --pre-1.5-compatible"
|
||||
;;
|
||||
deltify)
|
||||
cmdOpts="-r --revision -q --quiet"
|
||||
;;
|
||||
dump)
|
||||
cmdOpts="-r --revision --incremental -q --quiet --deltas"
|
||||
;;
|
||||
help|h|\?)
|
||||
cmdOpts="$cmds -q --quiet"
|
||||
;;
|
||||
hotcopy)
|
||||
cmdOpts="--clean-logs"
|
||||
;;
|
||||
load)
|
||||
cmdOpts="--ignore-uuid --force-uuid --parent-dir -q --quiet \
|
||||
--use-pre-commit-hook --use-post-commit-hook"
|
||||
;;
|
||||
recover)
|
||||
cmdOpts="--wait"
|
||||
;;
|
||||
rmtxns)
|
||||
cmdOpts="-q --quiet"
|
||||
;;
|
||||
setlog)
|
||||
cmdOpts="-r --revision --bypass-hooks"
|
||||
;;
|
||||
setrevprop)
|
||||
cmdOpts="-r --revision --use-pre-revprop-change-hook \
|
||||
--use-post-revprop-change-hook"
|
||||
;;
|
||||
verify)
|
||||
cmdOpts="-r --revision -q --quiet"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
cmdOpts="$cmdOpts --help -h"
|
||||
|
||||
# take out options already given
|
||||
for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do
|
||||
opt=${COMP_WORDS[$i]}
|
||||
|
||||
case $opt in
|
||||
--*) optBase=${opt/=*/} ;;
|
||||
-*) optBase=${opt:0:2} ;;
|
||||
esac
|
||||
|
||||
cmdOpts=" $cmdOpts "
|
||||
cmdOpts=${cmdOpts/ ${optBase} / }
|
||||
|
||||
# take out alternatives
|
||||
case $optBase in
|
||||
-q) cmdOpts=${cmdOpts/ --quiet / } ;;
|
||||
--quiet) cmdOpts=${cmdOpts/ -q / } ;;
|
||||
-h) cmdOpts=${cmdOpts/ --help / } ;;
|
||||
--help) cmdOpts=${cmdOpts/ -h / } ;;
|
||||
-r) cmdOpts=${cmdOpts/ --revision / } ;;
|
||||
--revision) cmdOpts=${cmdOpts/ -r / } ;;
|
||||
esac
|
||||
|
||||
# skip next option if this one requires a parameter
|
||||
if [[ $opt == @($optsParam) ]] ; then
|
||||
((++i))
|
||||
fi
|
||||
done
|
||||
|
||||
COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) )
|
||||
|
||||
return 0
|
||||
}
|
||||
complete -F _svnadmin -o default svnadmin
|
@ -1,3 +0,0 @@
|
||||
complete -W "$(cat $HOME/.xinitrc | awk '/^ *exec/ { print $2 }' | sed 's/\$.*//g')" -o default xinit
|
||||
|
||||
# vim:filetype=sh
|
170
bash_functions
170
bash_functions
@ -1,170 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function __available_projects(){
|
||||
/bin/ls $HOME/src | tr " " "\n"
|
||||
}
|
||||
|
||||
|
||||
function __proj_activate_comp(){
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
if [ $COMP_CWORD -eq 1 ]
|
||||
then
|
||||
COMPREPLY=( $( compgen -W "$(__available_projects)" $cur ) )
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function __proj_deactivate_reactivate_comp(){
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
if [ -n "$VIRTUAL_ENV" ]
|
||||
then
|
||||
COMPREPLY=( $(basename "$VIRTUAL_ENV") )
|
||||
return 0
|
||||
elif [ -n "$PROJ" ]
|
||||
then
|
||||
COMPREPLY=( $(basename "$PROJ") )
|
||||
return 0
|
||||
else
|
||||
COMPREPLY=( $cur )
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function a(){
|
||||
source $HOME/.activate_proj "$@"
|
||||
}
|
||||
|
||||
|
||||
function d(){
|
||||
source $HOME/.deactivate_proj "$@"
|
||||
}
|
||||
|
||||
|
||||
function r(){
|
||||
d "$1"
|
||||
a "$1"
|
||||
}
|
||||
|
||||
|
||||
complete -F __proj_activate_comp -o default a
|
||||
complete -F __proj_deactivate_reactivate_comp -o default d r
|
||||
|
||||
|
||||
# if the command-not-found package is installed, use it
|
||||
if [ -x /usr/lib/command-not-found ]; then
|
||||
command_not_found_handle(){
|
||||
# check because c-n-f could've been removed in the meantime
|
||||
if [ -x /usr/lib/command-not-found ]; then
|
||||
/usr/bin/python /usr/lib/command-not-found -- $1
|
||||
return $?
|
||||
else
|
||||
return 127
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
function add_ssh_keys()
|
||||
{
|
||||
if [[ "$1" == "all" ]]
|
||||
then
|
||||
for key in $__SSH_KEYS__
|
||||
do
|
||||
ssh-add $key
|
||||
done
|
||||
else
|
||||
ssh-add
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function get_ssh_agent(){
|
||||
ssh-add -l
|
||||
test $? -eq 2 || return
|
||||
|
||||
agent_out="$HOME/.ssh/agent.out"
|
||||
source $agent_out
|
||||
ssh-add -l
|
||||
test $? -eq 2 || return
|
||||
|
||||
ssh-agent > $agent_out
|
||||
source $agent_out
|
||||
ssh-add
|
||||
}
|
||||
|
||||
|
||||
function get_gpg_agent(){
|
||||
readlink -f "$HOME/.gnupg" >/dev/null || return 0
|
||||
agent_out="$HOME/.gnupg/agent.out"
|
||||
tmp=$(mktemp /tmp/gnupgXXXX)
|
||||
gpg-agent $* > $tmp && mv $tmp $agent_out
|
||||
|
||||
grep GPG_TTY $agent_out >/dev/null || \
|
||||
cat >> $agent_out <<EOF
|
||||
export GPG_TTY="$(tty)"
|
||||
EOF
|
||||
source $agent_out
|
||||
}
|
||||
|
||||
|
||||
function retag(){
|
||||
langs="python"
|
||||
if [ -n "$1" ] ; then
|
||||
langs="$langs,$1"
|
||||
fi
|
||||
rm -f $PWD/tags
|
||||
ctags --recurse=yes --languages=$langs $PWD
|
||||
}
|
||||
|
||||
|
||||
function top_commands(){
|
||||
history | awk '{ print $2 }' | sort | uniq -c | sort -k1 -rn | head
|
||||
}
|
||||
|
||||
|
||||
function rss_pid_command(){
|
||||
cmd="ps -o rss,pid,command U $USER"
|
||||
if [ -n "$1" ] ; then
|
||||
grep_filter="grep $1"
|
||||
$cmd | $grep_filter | grep -v "$grep_filter"
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function exit_status() {
|
||||
if [[ $1 -eq 0 ]]; then
|
||||
echo "\[\033[1;32m\]✓\[\033[00m\]"
|
||||
else
|
||||
echo "\[\033[1;31m\]✗\[\033[00m\]:\[\033[31m\]$1\[\033[00m\]"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function precmd(){
|
||||
last_status=$?
|
||||
|
||||
PS1="\[\033[1;32m\]\u@\h\[\033[00m\]:\[\033[1;32m\]"
|
||||
PS1="$PS1$(truncpwd)\[\033[00m\] -$(print-color-loadavg)- "
|
||||
PS1="$PS1$(__git_ps1 "(%s)")\n$(exit_status $last_status) "
|
||||
|
||||
export PS1
|
||||
}
|
||||
|
||||
|
||||
function unhyphenate() {
|
||||
ruby -e "puts '$1'.gsub(/[\-_]/, ' ')"
|
||||
}
|
||||
|
||||
|
||||
function rbenv_init() {
|
||||
if [ -n "$DEBUG" ] ; then
|
||||
export RBENV_DEBUG=1
|
||||
time eval "$(rbenv init -)"
|
||||
unset RBENV_DEBUG
|
||||
else
|
||||
eval "$(rbenv init -)"
|
||||
fi
|
||||
}
|
89
bash_profile
89
bash_profile
@ -1,89 +0,0 @@
|
||||
_debug(){
|
||||
if [ -n "$DEBUG" ] ; then
|
||||
echo $*
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_get_hostname() {
|
||||
local hn="$(hostname -a 2>/dev/null || hostname)"
|
||||
local ha=""
|
||||
for host in $hn ; do
|
||||
if [[ "$(echo $host | grep "\." | grep -v "localhost")" != "" ]] ; then
|
||||
ha="$host"
|
||||
fi
|
||||
done
|
||||
if [ -n "$ha" ] ; then
|
||||
echo "$ha"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_source_host_specific_rcfile() {
|
||||
local _host_alias="`_get_hostname`"
|
||||
if [[ ! -n "$_host_alias" ]] ; then
|
||||
_host_alias="`hostname`"
|
||||
fi
|
||||
|
||||
local _host_specific_rcfile="$HOME/.bash_vars.$_host_alias"
|
||||
if [[ -e "$_host_specific_rcfile" ]] ; then
|
||||
debug "sourcing $_host_specific_rcfile"
|
||||
source $_host_specific_rcfile
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_source_if_exists() {
|
||||
if [ -e "$1" ] ; then
|
||||
_debug "sourcing $1"
|
||||
if [ -n "$DEBUG" ] ; then
|
||||
time source "$1"
|
||||
else
|
||||
source "$1"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_source_bash_extras() {
|
||||
local _bash_extras="
|
||||
$HOME/.bashrc_local
|
||||
$HOME/.bash_aliases
|
||||
$HOME/.bash_functions
|
||||
/etc/bash_completion
|
||||
$HOME/.bash_completion
|
||||
$HOME/.autoenv/activate.sh
|
||||
"
|
||||
for ext in $_bash_extras ; do
|
||||
_source_if_exists "$ext"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
_bash_profile_main() {
|
||||
source "$HOME/.bash_vars_common"
|
||||
_source_host_specific_rcfile
|
||||
_source_bash_extras
|
||||
|
||||
get_ssh_agent
|
||||
which gpg-agent && test -d ~/.gnupg && get_gpg_agent
|
||||
|
||||
#_source_if_exists "$HOME/.gvm/scripts/gvm"
|
||||
#_source_if_exists "$HOME/.gvmrc"
|
||||
#_source_if_exists "$HOME/src/gocode/src/.env"
|
||||
|
||||
unset _get_hostname
|
||||
unset _source_host_specific_rcfile
|
||||
unset _source_bash_extras
|
||||
unset _bash_profile_main
|
||||
}
|
||||
|
||||
|
||||
_bash_profile_main
|
||||
|
||||
# added by travis gem
|
||||
[[ -f ~/.travis/travis.sh ]] && source ~/.travis/travis.sh
|
||||
|
||||
# vim:filetype=sh
|
108
bash_vars_common
108
bash_vars_common
@ -1,108 +0,0 @@
|
||||
if [ "$TERM" != "dumb" ] && $(dircolors -b >/dev/null 2>&1)
|
||||
then
|
||||
eval "`dircolors -b`"
|
||||
fi
|
||||
|
||||
export EDITOR=vim
|
||||
export VISUAL=vim
|
||||
export FLASHPLAYER_HOME=$HOME/.local/share/flashplayer
|
||||
export FLEX_HOME=$HOME/opt/flex-sdk
|
||||
|
||||
export _LOC_ACLOCAL="$HOME/share/aclocal"
|
||||
|
||||
if [ -d "$HOME/share/aclocal" ]
|
||||
then
|
||||
ACLOCAL_PATH="$_LOC_ACLOCAL:$ACLOCAL_PATH"
|
||||
ACLOCAL_FLAGS="-I $_LOC_ACLOCAL"
|
||||
for d in $(find $HOME/share/aclocal -type d)
|
||||
do
|
||||
ACLOCAL_PATH="$ACLOCAL_PATH:$d"
|
||||
ACLOCAL_FLAGS="-I $d $ACLOCAL_FLAGS"
|
||||
done
|
||||
export ACLOCAL_PATH
|
||||
export ACLOCAL_FLAGS
|
||||
unset d
|
||||
fi
|
||||
|
||||
|
||||
function __addjars(){
|
||||
if [ -d "$1" ] ; then
|
||||
for j in $(find $1 -name \*.jar) ; do
|
||||
CLASSPATH="$CLASSPATH:$j"
|
||||
done
|
||||
unset j
|
||||
fi
|
||||
export CLASSPATH
|
||||
}
|
||||
|
||||
function __normclasspath(){
|
||||
tmp=/tmp/$RANDOM.$RANDOM.$RANDOM.cp
|
||||
echo $CLASSPATH | tr ":" "\n" > $tmp
|
||||
|
||||
cat $tmp | sed -e "s/^://" | sort | uniq | tr "\n" ":"
|
||||
}
|
||||
|
||||
CLASSPATH="$PWD"
|
||||
|
||||
JYTHON_HOME="/opt/jython"
|
||||
PRIVATE_JARS_HOME="$HOME/.local/private-jars"
|
||||
FLEX_JARS="$FLEX_HOME/lib"
|
||||
|
||||
__addjars "$JYTHON_HOME/extlibs"
|
||||
__addjars "$PRIVATE_JARS_HOME"
|
||||
__addjars "$FLEX_JARS"
|
||||
__addjars "/usr/share/java"
|
||||
|
||||
CLASSPATH="$(__normclasspath)"
|
||||
|
||||
export CLASSPATH
|
||||
export HISTCONTROL=ignoreboth
|
||||
|
||||
LD_LIBRARY_PATH="/usr/include:/usr/include/python2.5:$HOME/lib"
|
||||
for d in mysql python2.6 pkgconfig engines ; do
|
||||
LD_LIBRARY_PATH="$HOME/lib/$d:$LD_LIBRARY_PATH"
|
||||
done
|
||||
unset d
|
||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/include:$HOME/include/python2.6"
|
||||
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/include/wx-2.8"
|
||||
export LD_LIBRARY_PATH
|
||||
export INCLUDE_PATH="$LD_LIBRARY_PATH:$HOME/include/python2.5:/usr/include"
|
||||
|
||||
LIB_PATH=$LD_LIBRARY_PATH:$LIB_PATH
|
||||
export LIB_PATH
|
||||
|
||||
PATH="$HOME/bin:$HOME/.local/bin:$HOME/opt/bin:/usr/local/bin:/usr/local/sbin:$PATH"
|
||||
PATH="$PATH:$FLEX_HOME/bin:$FLASHPLAYER_HOME/bin"
|
||||
PATH="$PATH:/opt/java/bin"
|
||||
PATH="$HOME/.rbenv/bin:$PATH"
|
||||
export PATH
|
||||
export PROMPT_COMMAND='precmd'
|
||||
|
||||
export PS2=">>> "
|
||||
PYTHONPATH="$HOME/lib/python2.6/site-packages:$PYTHONPATH"
|
||||
PYTHONPATH="/usr/lib/python2.6/site-packages:$PYTHONPATH"
|
||||
PYTHONPATH="$PYTHONPATH:/var/lib/python-support/python2.5"
|
||||
PYTHONPATH="$PYTHONPATH:$HOME/lib/svn-python"
|
||||
PYTHONPATH="$PYTHONPATH:/var/lib/python-support/python2.6"
|
||||
export PYTHONPATH
|
||||
|
||||
export LUA_PATH="$HOME/share/lua/5.1/?.lua;;"
|
||||
|
||||
export __SSH_KEYS__="$(/bin/ls $HOME/.ssh/*_*sa)"
|
||||
export PKG_CONFIG_PATH="$HOME/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export CMAKE_ROOT="$HOME/share/cmake-2.8"
|
||||
export OSYNC_TRACE="$HOME/var/tmp/opensync"
|
||||
export OSYNC_NOPRIVACY=1
|
||||
|
||||
export WINEPREFIX="$HOME/.wine"
|
||||
export GREP_COLOR=auto
|
||||
|
||||
export GIT_PS1_SHOWDIRTYSTATE="1"
|
||||
export GIT_PS1_SHOWSTASHSTATE="1"
|
||||
export GIT_PS1_SHOWUNTRACKEDFILES="1"
|
||||
export GIT_PS1_SHOWUPSTREAM="auto"
|
||||
export GIT_PS1_DESCRIBE_STYLE="default"
|
||||
# ^--- could also be "contains", "branch", or "describe"
|
||||
|
||||
|
||||
# vim:filetype=sh
|
@ -1,30 +0,0 @@
|
||||
export MAGICK_HOME="/opt/ImageMagick-6.6.7"
|
||||
export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/"
|
||||
export VIMRUNTIME="/usr/local/MacVim.app/Contents/Resources/vim/vim73"
|
||||
export EDITOR='mvim --remote-wait-silent'
|
||||
export VISUAL='mvim --remote-wait-silent'
|
||||
export TF_DIFF_COMMAND='colordiff -u --label "%6 / %7" "%1" "%2"'
|
||||
|
||||
_PF_VERSIONS="/Library/Frameworks/Python.framework/Versions"
|
||||
if [[ -d $_PF_VERSIONS ]]
|
||||
then
|
||||
for _version in $(/bin/ls $_PF_VERSIONS | grep -v Current)
|
||||
do
|
||||
PATH="$_PF_VERSIONS/$_version/bin:$PATH"
|
||||
if [[ "$_version" == "2.7" ]]
|
||||
then
|
||||
PYTHONPATH="$_PF_VERSIONS/$_version/lib/python${_version}:$PYTHONPATH"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
unset _PF_VERSIONS
|
||||
unset _version
|
||||
|
||||
PATH="$PATH:/opt/TEE-CLC-10.0.0:$MAGICK_HOME/bin"
|
||||
export PATH
|
||||
|
||||
export PYTHONPATH
|
||||
|
||||
|
||||
# vim:filetype=sh
|
20
bashrc
20
bashrc
@ -1,20 +0,0 @@
|
||||
test -n "$PROMPT_COMMAND" && unset PROMPT_COMMAND
|
||||
|
||||
PATH="$HOME/bin:$PATH"
|
||||
export PATH
|
||||
|
||||
export PS1="\u@\h:\w\$ "
|
||||
|
||||
if test -t 0
|
||||
then
|
||||
source ~/.bash_aliases
|
||||
source ~/.bash_functions
|
||||
fi
|
||||
|
||||
# vim:filetype=sh
|
||||
|
||||
### Added by the Heroku Toolbelt
|
||||
export PATH="/usr/local/heroku/bin:$PATH"
|
||||
|
||||
# added by travis gem
|
||||
[ -f /Users/me/.travis/travis.sh ] && source /Users/me/.travis/travis.sh
|
@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
__run_deactivate()
|
||||
{
|
||||
if [ -n "$1" ] ; then
|
||||
project=${1}
|
||||
PROJDIR=${HOME}/src/${project}
|
||||
if [[ -d $PROJDIR ]] ; then
|
||||
export PROJSRC=${PROJDIR}/src/${project}
|
||||
export PROJBIN=${PROJDIR}/bin
|
||||
if [[ -e deactivate ]] ; then
|
||||
deactivate ${PROJBIN}/activate
|
||||
fi
|
||||
echo "${project} deactivated"
|
||||
unset _HAS_GIT _HAS_HG _HG_BRANCH PROJ
|
||||
cd "${HOME}"
|
||||
source ${HOME}/.bash_profile
|
||||
elif [[ -e deactivate ]] ; then
|
||||
deactivate
|
||||
else
|
||||
echo "You are not in project ${project}."
|
||||
echo "Furthermore, the 'deactivate' function does not exist right now."
|
||||
fi
|
||||
else
|
||||
echo "Usage: $HOME/.deactivate_proj <projname>"
|
||||
fi
|
||||
}
|
||||
|
||||
__run_deactivate "$@"
|
||||
unset __run_deactivate
|
||||
|
||||
# vim:ft=sh
|
@ -1,4 +0,0 @@
|
||||
" this file is sourced by Janus stuff
|
||||
|
||||
set guifont=Mensch\ 8
|
||||
colo inkpot
|
10
janus.rake
10
janus.rake
@ -1,10 +0,0 @@
|
||||
# TODO: make this crap work with the new Janus method via pathogen
|
||||
|
||||
vim_plugin_task "valgrind", "git://github.com/vim-scripts/valgrind.vim.git"
|
||||
vim_plugin_task "guicolorscheme", "git://github.com/vim-scripts/guicolorscheme.vim.git"
|
||||
vim_plugin_task "gardener.vim" do
|
||||
sh "curl 'http://www.vim.org/scripts/download_script.php?src_id=4682' > colors/gardener.vim"
|
||||
end
|
||||
vim_plugin_task "pgsql.vim" do
|
||||
sh "curl 'http://www.gunduz.org/postgresql/pgsql.vim' > plugin/pgsql.vim"
|
||||
end
|
81
todo.cfg
81
todo.cfg
@ -1,81 +0,0 @@
|
||||
# === EDIT FILE LOCATIONS BELOW ===
|
||||
|
||||
# Your todo.txt directory
|
||||
export TODO_DIR="$HOME/Dropbox/dan/todo"
|
||||
|
||||
# Your todo/done/report.txt locations
|
||||
export TODO_FILE="$TODO_DIR/todo.txt"
|
||||
export DONE_FILE="$TODO_DIR/done.txt"
|
||||
export REPORT_FILE="$TODO_DIR/report.txt"
|
||||
export TMP_FILE="$TODO_DIR/todo.tmp"
|
||||
|
||||
# You can customize your actions directory location
|
||||
#export TODO_ACTIONS_DIR="$HOME/.todo.actions.d"
|
||||
|
||||
# == EDIT FILE LOCATIONS ABOVE ===
|
||||
|
||||
# === COLOR MAP ===
|
||||
|
||||
## Text coloring and formatting is done by inserting ANSI escape codes.
|
||||
## If you have re-mapped your color codes, or use the todo.txt
|
||||
## output in another output system (like Conky), you may need to
|
||||
## over-ride by uncommenting and editing these defaults.
|
||||
## If you change any of these here, you also need to uncomment
|
||||
## the defaults in the COLORS section below. Otherwise, todo.txt
|
||||
## will still use the defaults!
|
||||
|
||||
# export BLACK='\\033[0;30m'
|
||||
# export RED='\\033[0;31m'
|
||||
# export GREEN='\\033[0;32m'
|
||||
# export BROWN='\\033[0;33m'
|
||||
# export BLUE='\\033[0;34m'
|
||||
# export PURPLE='\\033[0;35m'
|
||||
# export CYAN='\\033[0;36m'
|
||||
# export LIGHT_GREY='\\033[0;37m'
|
||||
# export DARK_GREY='\\033[1;30m'
|
||||
# export LIGHT_RED='\\033[1;31m'
|
||||
# export LIGHT_GREEN='\\033[1;32m'
|
||||
# export YELLOW='\\033[1;33m'
|
||||
# export LIGHT_BLUE='\\033[1;34m'
|
||||
# export LIGHT_PURPLE='\\033[1;35m'
|
||||
# export LIGHT_CYAN='\\033[1;36m'
|
||||
# export WHITE='\\033[1;37m'
|
||||
# export DEFAULT='\\033[0m'
|
||||
|
||||
# === COLORS ===
|
||||
|
||||
## Uncomment and edit to override these defaults.
|
||||
## Reference the constants from the color map above,
|
||||
## or use $NONE to disable highlighting.
|
||||
#
|
||||
# Priorities can be any upper-case letter.
|
||||
# A,B,C are highlighted; you can add coloring for more.
|
||||
#
|
||||
# export PRI_A=$YELLOW # color for A priority
|
||||
# export PRI_B=$GREEN # color for B priority
|
||||
# export PRI_C=$LIGHT_BLUE # color for C priority
|
||||
# export PRI_D=... # define your own
|
||||
# export PRI_X=$WHITE # color unless explicitly defined
|
||||
|
||||
# There is highlighting for tasks that have been done,
|
||||
# but haven't been archived yet.
|
||||
#
|
||||
# export COLOR_DONE=$LIGHT_GREY
|
||||
|
||||
# === BEHAVIOR ===
|
||||
|
||||
## customize list output
|
||||
#
|
||||
# TODOTXT_SORT_COMMAND will filter after line numbers are
|
||||
# inserted, but before colorization, and before hiding of
|
||||
# priority, context, and project.
|
||||
#
|
||||
# export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2'
|
||||
|
||||
# TODOTXT_FINAL_FILTER will filter list output after colorization,
|
||||
# priority hiding, context hiding, and project hiding. That is,
|
||||
# just before the list output is displayed.
|
||||
#
|
||||
# export TODOTXT_FINAL_FILTER='cat'
|
||||
|
||||
# vim:filetype=sh
|
148
vimrc.after
148
vimrc.after
@ -1,148 +0,0 @@
|
||||
" sourced by Janus
|
||||
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
|
||||
autocmd FileType * map ,t :w<CR>
|
||||
map ,m :w\|:make<CR><CR>
|
||||
map ,- :nohl<CR>
|
||||
|
||||
" Set the indent to 2 when working with ruby and markup stuff
|
||||
autocmd BufNew,BufRead *.feature,*.rb,*.ru,*.xml,*.html,*.htm,Gemfile,Rakefile,Procfile set shiftwidth=2
|
||||
\| set tabstop=2
|
||||
\| set softtabstop=2
|
||||
|
||||
autocmd FileType ruby set shiftwidth=2
|
||||
\| set tabstop=2
|
||||
\| set softtabstop=2
|
||||
\| map ,t :RuboCop<CR>:w<CR>
|
||||
|
||||
autocmd FileType ruby map ,r :RuboCop<CR>
|
||||
|
||||
autocmd BufNew,BufRead *.ino,*.pde setf arduino
|
||||
|
||||
autocmd FileType arduino set tabstop=4
|
||||
\| set softtabstop=4
|
||||
\| let g:syntastic_cpp_check_header=0
|
||||
\| map ,t :w<CR>:execute '!astyle' shellescape(expand('%'), 1)<CR>:e<CR>:make<CR><CR><CR>
|
||||
|
||||
" Set up some sane java compilation bits
|
||||
autocmd BufNew,BufRead *.java set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
|
||||
\| set makeprg=ant\ -find\ build.xml
|
||||
|
||||
" never expand tabs (multiline-strings) and remap ',t' to do :Fmt first in Go
|
||||
autocmd FileType go set noexpandtab
|
||||
\| map ,t :Fmt<CR>:w<CR>
|
||||
|
||||
" add color column for a few file types
|
||||
autocmd FileType go,python,ruby set colorcolumn=80
|
||||
|
||||
" highlighting sbt as scala, too
|
||||
autocmd BufNew,BufRead *.sbt set syn=scala
|
||||
|
||||
" (en|dis)able crosshairs!
|
||||
function! EnableCrosshairs()
|
||||
set cursorline
|
||||
set cursorcolumn
|
||||
|
||||
highlight CursorLine ctermbg=blue
|
||||
highlight CursorColumn ctermbg=blue
|
||||
endfunction
|
||||
|
||||
function! DisableCrosshairs()
|
||||
set nocursorline
|
||||
set nocursorcolumn
|
||||
endfunction
|
||||
|
||||
" MyNext() and MyPrev(): Movement between tabs OR buffers
|
||||
function! MyNext()
|
||||
if exists('*tabpagenr') && tabpagenr('$') != 1
|
||||
" Tab support && tabs open
|
||||
normal gt
|
||||
else
|
||||
" No tab support, or no tabs open
|
||||
execute ":bnext"
|
||||
endif
|
||||
endfunction
|
||||
function! MyPrev()
|
||||
if exists('*tabpagenr') && tabpagenr('$') != '1'
|
||||
" Tab support && tabs open
|
||||
normal gT
|
||||
else
|
||||
" No tab support, or no tabs open
|
||||
execute ":bprev"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" moving between tabs OR buffers
|
||||
nnoremap L :call MyNext()<CR>
|
||||
nnoremap H :call MyPrev()<CR>
|
||||
|
||||
" astyle the whole thing
|
||||
map ,a :execute '!astyle' shellescape(expand('%'), 1)<CR>:e<CR>
|
||||
|
||||
" easy indentation in visual mode
|
||||
" This keeps the visual selection active after indenting.
|
||||
" Usually the visual selection is lost after you indent it.
|
||||
vmap > >gv
|
||||
vmap < <gv
|
||||
|
||||
" run make
|
||||
" <F3> or \m
|
||||
map <silent><F3> :make<CR>
|
||||
map <silent><leader>m :make<CR>
|
||||
|
||||
" Highlight over 80 chars wide for python files
|
||||
" (to call manually, use the mapping '\py80'
|
||||
map <silent><leader>py80 :call LambastOver80Wide()<CR>
|
||||
function! LambastOver80Wide()
|
||||
highlight NearLength ctermbg=yellow ctermfg=black
|
||||
match NearLength /\%76v.*/
|
||||
|
||||
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
|
||||
match OverLength /\%81v.*/
|
||||
endfun
|
||||
|
||||
|
||||
" disable mapping (to call manually use mapping '\nopy80'
|
||||
map <silent><leader>nopy80 :call DisableLambastOver80Wide()<CR>
|
||||
function! DisableLambastOver80Wide()
|
||||
highlight OverLength ctermbg=Black ctermfg=white guibg=#000000
|
||||
endfun
|
||||
" call it right away for certain files
|
||||
autocmd FileType python call LambastOver80Wide()
|
||||
autocmd FileType moin call LambastOver80Wide()
|
||||
" autocmd FileType go call LambastOver80Wide()
|
||||
" autocmd FileType javascript call LambastOver80Wide()
|
||||
" autocmd FileType actionscript call LambastOver80Wide()
|
||||
autocmd FileType mail call LambastOver80Wide()
|
||||
autocmd FileType scons call LambastOver80Wide()
|
||||
" autocmd FileType cs call LambastOver80Wide()
|
||||
|
||||
" strip trailing whitespace
|
||||
map <silent><leader>SW :call StripTrailingWhitespace()<CR>
|
||||
function! StripTrailingWhitespace()
|
||||
:%s/\s\+$//e
|
||||
endfun
|
||||
|
||||
" remove all ^M chars
|
||||
map <silent><leader>SM :call StripCtrlMs()<CR>
|
||||
function! StripCtrlMs()
|
||||
:%s/[ \t\r]\+$//e
|
||||
endfun
|
||||
|
||||
" insert date
|
||||
map <silent><leader>D :call InsertDate()<CR>
|
||||
function! InsertDate()
|
||||
:read !date
|
||||
endfun
|
||||
|
||||
if !has('gui_running')
|
||||
set t_Co=256
|
||||
"colorscheme gardener
|
||||
"colorscheme inkpot
|
||||
colorscheme molokai
|
||||
endif
|
||||
|
||||
let g:valgrind_arguments='--leak-check=yes --num-callers=50'
|
14
zshrc
14
zshrc
@ -1,5 +1,5 @@
|
||||
ZSH=$HOME/.oh-my-zsh
|
||||
ZSH_THEME=meatballhat
|
||||
ZSH_THEME=robbyrussell
|
||||
|
||||
CASE_SENSITIVE="true"
|
||||
|
||||
@ -87,17 +87,19 @@ path=(
|
||||
/usr/local/games
|
||||
)
|
||||
|
||||
if which pyenv > /dev/null ; then
|
||||
eval "$(pyenv init -)"
|
||||
if which pyenv >/dev/null; then
|
||||
eval "$(pyenv init - 2>/dev/null)"
|
||||
fi
|
||||
export PYENV_ROOT='/usr/local/var/pyenv'
|
||||
|
||||
eval "$(phpenv init -)"
|
||||
if which phpenv >/dev/null; then
|
||||
eval "$(phpenv init - 2>/dev/null)"
|
||||
fi
|
||||
|
||||
eval "$(gimme 1.4.2)" 2>/dev/null
|
||||
eval "$(gimme 1.8.1)" 2>/dev/null
|
||||
export GOPATH="$HOME/gopath"
|
||||
|
||||
CDPATH="$HOME/workspace:$HOME/src:$HOME/Development/src:$HOME/repos"
|
||||
CDPATH="$HOME/code:$HOME/src:$HOME/Development/src:$HOME/repos"
|
||||
for prefix in github.com github.com/travis-ci github.com/meatballhat code.google.com/p ; do
|
||||
CDPATH="$HOME/gopath/src/$prefix:$CDPATH"
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user