--- a/.bashrc Sun Dec 04 18:43:51 2011 +0200
+++ b/.bashrc Sun Dec 04 18:45:24 2011 +0200
@@ -1,8 +1,9 @@
+
+# set -x
+# set -u
# XXX
-# [ -f /etc/bashrc ] && . /etc/bashrc
-
-[ -d ~/usr/bin ] && export PATH="$PATH":~/usr/bin || :
+# [[ -f /etc/bashrc ]] && . /etc/bashrc
# XXX for mc, cvs, svn, ...
export EDITOR=vim
@@ -14,11 +15,13 @@
PS1='bash# '
# Set magenta bold font.
case "$TERM" in
- xterm*) PS1='\[\033[31m\033[1m\]\h\033[35m\]+bash# \[\033[0m\]'
+ xterm*)
+ PS1='\[\033[31m\033[1m\]\h\[\033[35m\]+bash# \[\033[0m\]'
+ PS2='\[\033[32m\]> \[\033[0m\]'
;;
esac
-# if [ -f ~/.dircolors ]; then
+# if [[ -f ~/.dircolors ]]; then
# eval `dircolors -b ~/.dircolors`
# fi
@@ -84,6 +87,10 @@
alias l.='ls -d .*' #list hidden files
alias ll='ls -lhrt' #extra info compared to "l"
alias lld='ls -lUd */' #list directories
+# I prefer EN man pages.
+alias man='LANG=C man'
+
+alias j='jobs '
# make and change to a directory
md () { mkdir -p "$1" && cd "$1"; }
@@ -116,44 +123,30 @@
# canonicalize path (including resolving symlinks)
# alias realpath='readlink -f'
-# Use bash-completion, if available.
-if [ -f /etc/bash_completion ]; then
- # Under Cygwin bash completition start a long time.
- if [ ! "$OSTYPE" = cygwin ]; then
- . /etc/bash_completion
- else
- # But load local completion anyway.
- if [ -f ~/.bash_completion ]; then
- . ~/.bash_completion
- fi
- fi
-fi
-if [ -f $HOME/usr/etc/bash_completion ]; then
- . $HOME/usr/etc/bash_completion
-fi
-
# Special case for CYGWIN to properly display russian letters in rxvt.
# Don't forget set in Windows SHELL=/bin/bash. If default SHELL is sh then .bashrc will not be read.
-if [ -n "$COMSPEC" ]; then
- if [ x$OSTYPE = xcygwin ]; then
- export LANG=ru_RU.CP1251
- fi
+if [[ x$OSTYPE = xcygwin ]]; then
+ export LANG=ru_RU.CP1251
+ # Avoid permission problem in Cygwin.
+ umask 0000
fi
export PATH=$PATH:~/usr/bin
-if [ -z "$MANPATH" ]; then
+if [[ -z "$MANPATH" ]]; then
export MANPATH=~/usr/share/man:
else
export MANPATH=$MANPATH:~/usr/share/man:
fi
-if [ -z "$INFOPATH" ]; then
+if [[ -z "$INFOPATH" ]]; then
export INFOPATH=~/usr/share/info:
else
export INFOPATH=$INFOPATH:~/usr/share/info:
fi
+export PYTHONSTARTUP=~/.pystartup
+
################################################################
# Key binding.
@@ -198,3 +191,140 @@
# builtin completes on builtins
complete -b builtin
+_hgsyncew() {
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ COMPREPLY=( $(compgen -W "--push" -- $cur) )
+ return 0
+}
+complete -F _hgsyncew -o nospace hgsyncew
+
+_pathsearch() {
+ local prev cur=${COMP_WORDS[COMP_CWORD]}
+ [[ $COMP_CWORD > 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
+ if [[ $prev = -d ]]; then
+ COMPREPLY=()
+ return 0
+ fi
+ case "$cur" in
+ -*) COMPREPLY=( $(compgen -W "-d --delimiter= -h --help" -- $cur ) ) ;;
+ *) COMPREPLY=() ;;
+ esac
+ return 0
+}
+complete -F _pathsearch -o nospace pathsearch
+
+_mycd() {
+ local cur
+ cur=${COMP_WORDS[COMP_CWORD]}
+ if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then
+ COMPREPLY=( $(compgen -d -- "$cur") )
+ return 0
+ fi
+ local i j k
+ for i in ${CDPATH//:/$'\n'}; do
+ k="${#COMPREPLY[@]}"
+ for j in $( compgen -d -- $i/$cur ); do
+ COMPREPLY[k++]=${j#$i/}
+ done
+ done
+ return 0
+}
+complete -F _mycd -o nospace cd
+
+_man() {
+ local p
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ if [[ $cur = /* || $cur = ./* ]]; then
+ COMPREPLY=( $(compgen -f -- $cur) )
+ fi
+ local IFS=':
+'
+ for p in /usr/share/man $MANPATH; do
+ [[ -n $p ]] || continue
+ p=( $p/man*/* )
+ p=( ${p[@]##*/} )
+ p=( ${p[@]%.gz} )
+ p=( ${p[@]%.*} )
+ p=( $(compgen -W '${p[@]}' -- $cur ) )
+ COMPREPLY=( ${COMPREPLY[@]} ${p[@]} )
+ done
+}
+complete -F _man man
+
+_make() {
+ local i mk
+ local dir=.
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ if [[ $cur = -* ]]; then
+ COMPREPLY=( $(compgen -W "-C -f" -- "$cur") )
+ return 0
+ fi
+ [[ $COMP_CWORD > 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
+ for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
+ case ${COMP_WORDS[i]} in
+ -f) mk=${COMP_WORDS[i+1]} ;;
+ -C) dir=${COMP_WORDS[i+1]} ;;
+ esac
+ done
+ if [[ $prev = -C ]]; then
+ COMPREPLY=( $(compgen -d -- "$cur") )
+ return 0
+ fi
+ if [[ $prev = -f ]]; then
+ COMPREPLY=( $(cd $dir >/dev/null 2>&1; compgen -f -- "$cur") )
+ return 0
+ fi
+ mk=$dir/$mk
+ [[ -f $mk ]] || mk=$(eval echo $dir/[Mm]akefile)
+ [[ -f $mk ]] || return 1
+ COMPREPLY=( $(compgen -W "$(sed -n -e '/^[[:alnum:]_-]*:/{s=^\([^:]*\):.*=\1=;p;}' $mk)" -- $cur) )
+ return 0
+}
+complete -F _make make gmake pmake
+
+_cygcheck() {
+ local opt
+ local cur=${COMP_WORDS[COMP_CWORD]}
+ case $COMP_CWORD in
+ 1)
+ case $cur in
+ -*)
+ COMPREPLY=( $(compgen -W "-v --verbose -h --help -V --version -c --check-setup -s --sysinfo
+ -k --keycheck -f --find-package -l --list-package -p --package-query" -- "$cur") )
+ return 0 ;;
+ *)
+ COMPREPLY=( $(compgen -c -- "$cur") )
+ return 0 ;;
+ esac
+ ;;
+ 2)
+ opt=${COMP_WORDS[1]}
+ case $opt in
+ -c|--check-setup|-l|--list-package)
+ pkgs=( /etc/setup/*.lst.gz )
+ pkgs=( ${pkgs[@]##*/} )
+ pkgs=( ${pkgs[@]%.lst.gz} )
+ COMPREPLY=( $(compgen -W '${pkgs[@]}' -- $cur ) )
+ return 0;;
+ esac
+ return 0;;
+ esac
+ return 0
+}
+complete -F _cygcheck cygcheck.exe cygcheck
+
+# Use bash-completion, if available.
+if [ -f /etc/bash_completion ]; then
+ # Under Cygwin bash completition start a long time.
+ if [ ! "$OSTYPE" = cygwin ]; then
+ . /etc/bash_completion
+ else
+ # But load local completion anyway.
+ if [ -f ~/.bash_completion ]; then
+ . ~/.bash_completion
+ fi
+ fi
+fi
+if [ -f $HOME/usr/etc/bash_completion ]; then
+ . $HOME/usr/etc/bash_completion
+fi