KBWDEBUG=${KBWDEBUG:-no}
function dprint {
if [[ $KBWDEBUG == yes && $- == *i* ]]; then
echo $SECONDS $*
fi
}
dprint alive
if [ -r "${HOME}/.bashrc.local.preload" ]; then
dprint "Loading bashrc preload"
source "${HOME}/.bashrc.local.preload"
fi
function have { type "$1" &>/dev/null ; }
function readlink_func \
{
if have readlink ; then
readlink "$1"
else
\ls -l "$1" | sed 's/[^>]*-> //'
fi
}
function realpath_func \
{
local input="${1}"
local output="/"
if [ -d "$input" -a -x "$input" ] ; then
output=`( cd "$input"; \pwd -P )`
else
input="${input%%/}"
local fname="${input##*/}"
input="${input%/*}"
if [ ! -d "$input" -o ! -x "$input" ] ; then
echo "$input is not an accessible directory" >&2
return
fi
output="`( cd "$input" ; \pwd -P )`/"
input="$fname"
if [ ! -L "$output$input" ] ; then
output="$output$input"
else
input="`readlink_func "$output$input"`"
while [ "$input" ] ; do
if [[ $input == /* ]] ; then
output="$input"
input=""
elif [[ $input == ../* ]] ; then
output="${output%/*/}/"
input="${input#../}"
elif [[ $input == ./* ]] ; then
input="${input#./}"
elif [[ $input == */* ]] ; then
output="$output${input%${input#*/}}"
input="${input#*/}"
else
output="$output$input"
input=""
fi
if [ -L "${output%%/}" ] ; then
if [ "$input" ] ; then
input="`readlink_func "${output%%/}"`/$input"
else
input="`readlink_func "${output%%/}"`"
fi
output="${output%%/}"
output="${output%/*}/"
fi
done
fi
fi
echo "${output%%/}"
}
function add_to_path_force \
{
if eval '[[' -z "\$$1" ']]'; then
eval "export $1='$2'"
elif ! eval '[[' \
-z "\"\${$1##*:\$2:*}\"" '||' \
-z "\"\${$1%%*:\$2}\"" '||' \
-z "\"\${$1##\$2:*}\"" '||' \
"\"\${$1}\"" '==' "\"$2\"" ']]'; then
eval "export $1=\"\$$1:$2\""
fi
}
function add_to_path \
{
local folder="${2%%/}"
[ -d "$folder" -a -x "$folder" ] || return
folder=`( cd "$folder" ; \pwd -P )`
add_to_path_force "$1" "$folder"
}
function add_to_path_file \
{
local file="${2}"
[ -f "$file" -a -r "$file" ] || return
file=`realpath_func "$file"`
add_to_path_force "$1" "$file"
}
function add_to_path_first \
{
local folder="${2%%/}"
[ -d "$folder" -a -x "$folder" ] || return
folder=`( cd "$folder" ; \pwd -P )`
if eval '[[' -z "\${$1##*:$folder:*}" ']]'; then
eval "$1=\"$folder:\${$1//:\$folder:/:}\""
elif eval '[[' -z "\${$1%%*:\$folder}" ']]'; then
eval "$1=\"$folder:\${$1%%:\$folder}\""
elif eval '[[' -z "\$$1" ']]'; then
eval "$1=\"$folder\""
elif ! eval '[[' -z "\${$1##\$folder:*}" '||' "\$$1" '==' "\"$folder\"" ']]'; then
eval "export $1=\"$folder:\$$1\""
fi
}
function verify_path \
{
local cmd="echo \$$1"
local arg="`eval $cmd`"
eval "$1=\"\""
while [[ $arg == *:* ]] ; do
dir="${arg%:${arg#*:}}"
arg="${arg#*:}"
if [ "$dir" != "." -a -d "$dir" -a -x "$dir" -a -r "$dir" ] ; then
dir=`( \cd "$dir" ; \pwd -P )`
add_to_path "$1" "$dir"
fi
done
if [ "$arg" != "." -a -d "$arg" -a -x "$arg" -a -r "$arg" ] ; then
arg=`( cd "$arg" ; \pwd -P )`
add_to_path "$1" "$arg"
fi
}
dprint Setting up conf funcs ...
function updatesetup {
(
if [ "$HOSTNAME" == "atakapa.local" ] ; then
if ssh-add -l | grep -q -v '75:50:80:4a:5d:dc:34:e1:fb:61:aa:91:9e:75:d9:30' ; then
echo Add key to keychain...
ssh-add
fi
fi
if [ -d ~/.conf_secure/ ] ; then
cd ~/.conf_secure
[ "$1" ] && echo .conf_secure...
cvs -q update
fi
if [ -d ~/.conf/ ] ; then
cd ~/.conf/
[ "$1" ] && echo .conf...
cvs -q update
bash ./setup.sh
else
echo CONFIG IS NOT BEING MANAGED!
fi
)
}
function sendsetup {
(
if [ -d ~/.conf_secure/ ] ; then
cd ~/.conf_secure
cvs -q commit
fi
if [ -d ~/.conf/ ] ; then
cd ~/.conf/
cvs -q commit
else
echo CONFIG IS NOT BEING MANAGED!
fi
)
}
dprint Loading system settings ...
if [[ -r /etc/bashrc && -z $KBW_SYSTEM_BASHRC ]]; then
dprint " - loading /etc/bashrc"
export KBW_SYSTEM_BASHRC=1
. /etc/bashrc
fi
shopt -s extglob
if [[ $- == *i* ]]; then
dprint setting the really spiffy stuff
shopt -s checkwinsize
shopt -s checkhash
shopt -s cdspell
fi
dprint PATH = $PATH
if [[ $TERM == *:* && ( $SSH_CLIENT || $SSH_TTY || $SSH_CLIENT2 ) ]] ; then
dprint "Smuggled information through the TERM variable!"
term_smuggling=( ${TERM//:/ } )
export SSH_LANG=${term_smuggling[1]}
TERM=${term_smuggling[0]}
unset term_smuggling
fi
if [[ -z $USER || -z $GROUPNAME ]] ; then
idout=(`id`)
if [[ -z $USER ]] ; then
USER="${idout[0]%%\)*}"
USER="${USER##*\(}"
dprint corrected missing USER to be $USER
fi
if [[ -z $GROUPNAME ]] ; then
if [[ ${idout[i]%%\(*} != $GROUPNAME ]] ; then
GROUPNAME="${idout[1]%%\)*}"
GROUPNAME="${GROUPNAME##*\(}"
else
GROUPNAME="UnknownGroup"
fi
dprint corrected missing GROUPNAME to be $GROUPNAME
fi
unset idout
fi
dprint term == $TERM
[ -d ~/.terminfo ] && export TERMINFO=~/.terminfo/
[ "$TERM_PROGRAM" == "Apple_Terminal" ] && export TERM=nsterm-16color
MAILPATH=""
MAILCHECK=30
add_to_path_file MAILPATH /var/spool/mail/$USER
add_to_path MAILPATH $HOME/Maildir/
[[ -z $MAILPATH ]] && unset MAILCHECK
[[ -z $HOSTNAME ]] && export HOSTNAME=`/bin/hostname` && echo 'Fake Bash!'
HISTSIZE=10000
HOST=${OSTYPE%%[[:digit:]]*}
OS_VER=${OSTYPE#$HOST}
[ -z "$OS_VER" ] && OS_VER=$( uname -r )
OS_VER=(${OS_VER//./ })
TTY=`tty`
PARINIT="rTbgq B=.,?_A_a P=_s Q=>|}+"
GDBHISTFILE="~/.gdb_history"
export USER GROUPNAME MAILPATH HISTSIZE OS_VER HOST TTY PARINIT GDBHISTFILE
dprint ' - umask (started `umask`)'
if [[ $UID -gt 99 ]]; then
umask 007
else
umask 077
fi
if [[ $USER == root ]] ; then
[[ $SSH_CLIENT || $SSH_TTY || $SSH_CLIENT2 ]] && export TMOUT=600 || export TMOUT=3600
fi
if [[ -z $INPUTRC && ! -r $HOME/.inputrc && -r /etc/inputrc ]]; then
export INPUTRC=/etc/inputrc
fi
export BASHRCREAD=1
if [[ -r /etc/profile && -z $KBW_SYSTEM_PROFILE ]]; then
dprint "- loading /etc/profile ... "
export KBW_SYSTEM_PROFILE=1
. /etc/profile
fi
if [[ $- == *i* ]]; then
if [[ $TERM == xterm* || $OSTYPE == darwin* ]]; then
PSterminfo='\[\e]2;\u@\h: \w\a\]'
fi
PSparts[3]='(\d \T)\n'
PSparts[2]='[\u@\h \W]'
PSparts[1]='\$ '
PScolors[2]='\[\e[34m\]'
PScolors[3]='\[\e[35m\]'
PScolors[4]='\[\e[36m\]'
PScolors[5]='\[\e[32m\]'
PScolors[6]='\[\e[33m\]'
PScolors[100]='\[\e[31m\]'
PScolors[0]='\[\e[0m\]'
if [[ $USER == root ]] ; then
PScolors[1]='\[\e[31m\]'
elif [[ $SSH_CLIENT || $SSH_TTY || $SSH_CLIENT2 ]] ; then
PScolors[1]="${PScolors[6]}"
if [[ $HOSTNAME == marvin ]] ; then
PScolors[1]="${PScolors[5]}"
fi
else
unset PSparts[3]
PScolors[1]=""
fi
function bashrc_genps {
if [ "$1" -a "${PScolors[$1]}" ] ; then
PSgood="$PSterminfo${PSparts[3]}${PScolors[$1]}${PSparts[2]}${PSparts[1]}${PScolors[0]}"
else
PSgood="$PSterminfo${PSparts[3]}${PSparts[2]}${PSparts[1]}"
fi
PSbad="$PSterminfo${PSparts[3]}${PScolors[$1]}${PSparts[2]}${PScolors[100]}${PSparts[1]}${PScolors[0]}"
}
bashrc_genps 1
function safeprompt {
export PS1='{\u@\h \W}\$ '
unset PROMPT_COMMAND
}
alias stdprompt='bashrc_genps 1'
alias blueprompt='bashrc_genps 2'
alias purpleprompt='bashrc_genps 3'
alias cyanprompt='bashrc_genps 4'
alias greenprompt='bashrc_genps 5'
alias whiteprompt='bashrc_genps'
export PROMPT_COMMAND='[ $? = 0 ] && PS1=$PSgood || PS1=$PSbad'
fi
dprint Manipulating your path ...
verify_path PATH
add_to_path PATH "/usr/local/sbin"
add_to_path PATH "/usr/local/teTeX/bin"
add_to_path PATH "/usr/X11R6/bin"
add_to_path PATH "$HOME/bin"
add_to_path PATH "$HOME/Public/bin"
add_to_path PATH /System/Library/Frameworks/Python.framework/Versions/2.3/bin
add_to_path PATH /Developer/usr/bin/
add_to_path_first PATH "/sbin"
add_to_path_first PATH "/bin"
add_to_path_first PATH "/usr/sbin"
add_to_path_first PATH "/opt/local/bin"
add_to_path_first PATH "/opt/local/sbin"
add_to_path_first PATH "/usr/local/bin"
add_to_path_first PATH "/usr/local/texlive/2008/bin/universal-darwin/"
if [[ $OSTYPE == darwin* ]] ; then
add_to_path PATH "$HOME/.conf/darwincmds"
add_to_path PATH "/usr/local/cuda/bin"
add_to_path DYLD_LIBRARY_PATH "$HOME/lib"
add_to_path DYLD_LIBRARY_PATH "/usr/local/cuda/lib"
[ -d /opt/local/lib/X11/app-defaults/ ] && \
add_to_path_force XFILESEARCHPATH /opt/local/lib/X11/%T/%N
[ -d /sw/etc/app-defaults/ ] && \
add_to_path_force XFILESEARCHPATH /sw/etc/%T/%N
add_to_path_force XFILESEARCHPATH /private/etc/X11/%T/%N
fi
verify_path MANPATH
add_to_path MANPATH "/usr/man"
add_to_path MANPATH "/usr/share/man"
add_to_path MANPATH "/usr/X11R6/man"
add_to_path_first MANPATH "/opt/local/share/man"
add_to_path_first MANPATH "/opt/local/man"
add_to_path_first MANPATH "/usr/local/man"
add_to_path_first MANPATH "/usr/local/share/man"
verify_path INFOPATH
add_to_path INFOPATH "/usr/share/info"
add_to_path INFOPATH "/opt/local/share/info"
export PATH MANPATH INFOPATH
dprint Setting up standard envariables ...
export PAGER='less'
have vim && export EDITOR='vim' || export EDITOR='vi'
if [[ -z $DISPLAY && $OSTYPE == darwin* ]]; then
processes=`ps ax`
if [[ ${processes} == *xinit* || ${processes} == *quartz-wm* ]]; then
export DISPLAY=:0
else
unset DISPLAY
fi
fi
if [[ $HOSTNAME == wizard ]] ; then
dprint Wizards X forwarding is broken
unset DISPLAY
fi
export TZ="US/Central"
if [ "${BASH_VERSINFO[0]}" -le 2 ]; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL="ignorespace:erasedups"
fi
export HISTIGNORE="&:ls:[bf]g:exit"
export GLOBIGNORE=".:.."
export CVSROOT=kyle@cvs.memoryhole.net:/home/kyle/cvsroot
export CVS_RSH=ssh
export BASH_ENV=$HOME/.bashrc
if [[ $- == *i* ]]; then
[ -r "$HISTFILE" -a -w "$HISTFILE" ] || echo "HISTFILE $HISTFILE has wrong permissions!"
fi
add_to_path_file MAILCAPS $HOME/.mailcap
add_to_path_file MAILCAPS /etc/mailcap
add_to_path_file MAILCAPS /usr/etc/mailcap
add_to_path_file MAILCAPS /usr/local/etc/mailcap
export EMAIL='kyle-envariable@memoryhole.net'
export GPG_TTY=$TTY
export RSYNC_RSH="ssh -2 -c arcfour -o Compression=no -x"
if [ -d /opt/local/include -a -d /opt/local/lib ] ; then
export CPPFLAGS="-I/opt/local/include $CPPFLAGS"
export LDFLAGS="-L/opt/local/lib $LDFLAGS"
fi
if have glibtoolize ; then
have libtoolize || export LIBTOOLIZE=glibtoolize
fi
add_to_path LD_LIBRARY_PATH $HOME/lib
add_to_path LD_LIBRARY_PATH $HOME/Public/lib
if [[ -z $LANG ]] ; then
dprint no LANG set
if [[ $WINDOWID ]] && have xprop ; then
dprint querying xprop
__bashrc__wmlocal=(`xprop -id $WINDOWID -f WM_LOCALE_NAME 8s ' $0' -notype WM_LOCALE_NAME`)
export LANG=`eval echo ${__bashrc__wmlocal[1]}`
unset __bashrc__wmlocal
elif [[ $OSTYPE == darwin* ]] ; then
dprint "I'm on Darwin"
if [[ ( $SSH_LANG && \
( $SSH_LANG == *.UTF* || $SSH_LANG == *.utf* ) || \
$TERM_PROGRAM == Apple_Terminal ) && \
-d "/usr/share/locale/en_US.UTF-8" ]] ; then
export LANG='en_US.UTF-8'
elif [ -d "/usr/share/locale/en_US" ] ; then
export LANG='en_US'
else
export LANG=C
fi
elif [[ $TERM == linux || $TERM_PROGRAM == GLterm ]] ; then
if [ -d "/usr/share/locale/en_US" ] ; then
export LANG='en_US'
else
export LANG=C
fi
else
if [[ $SSH_LANG == C ]] ; then
export LANG=C
elif have locale ; then
dprint "checking locale from big list (A)"
locales=`locale -a`
locales="${locales//[[:space:]]/|}"
if [[ en_US.utf8 == @($locales) ]] ; then
export LANG='en_US.utf8'
elif [[ en_US.utf-8 == @($locales) ]] ; then
export LANG='en_US.utf-8'
elif [[ en_US.UTF8 == @($locales) ]] ; then
export LANG='en_US.UTF8'
elif [[ en_US.UTF-8 == @($locales) ]] ; then
export LANG='en_US.UTF-8'
elif [[ en_US == @($locales) ]] ; then
export LANG='en_US'
else
export LANG=C
fi
unset locales
fi
fi
else
dprint "- LANG IS ALREADY SET! ($LANG)"
if [[ $SSH_LANG && $SSH_LANG != $LANG ]]; then
if [[ $SSH_LANG == C ]] ; then
export LANG=C
else
dprint "checking locale from big list (B)"
locales=`locale -a`
locales="${locales//[[:space:]]/|}"
if [[ $SSH_LANG == @(${locales}) ]] ; then
dprint "- SSH_LANG is a valid locale, resetting LANG"
LANG=$SSH_LANG
else
dprint "- SSH_LANG is NOT a valid locale"
wantutf8=no
if [[ $SSH_LANG == *.@(u|U)@(t|T)@(f|F)?(-)8 ]] ; then
wantutf8=yes
if [[ ! $LANG == *.@(u|U)@(t|T)@(f|F)?(-)8 ]] ; then
dprint "- want utf-8, but LANG is not utf8, unsetting"
unset LANG
fi
else
dprint "- don't want utf-8"
fi
if [[ ! $LANG || ! $LANG == @($locales) ]] ; then
if [ "$wantutf8" = yes ] ; then
dprint "- finding a utf8 LANG"
if [[ en_US.utf8 == @($locales) ]] ; then
export LANG='en_US.utf8'
elif [[ en_US.utf-8 == @($locales) ]] ; then
export LANG='en_US.utf-8'
elif [[ en_US.UTF8 == @($locales) ]] ; then
export LANG='en_US.UTF8'
elif [[ en_US.UTF-8 == @($locales) ]] ; then
export LANG='en_US.UTF-8'
elif [[ en_US == @($locales) ]] ; then
export LANG='en_US'
else
export LANG=C
fi
else
dprint "- finding a basic LANG"
if [[ en_US == @($locales) ]] ; then
export LANG='en_US'
else
export LANG=C
fi
fi
fi
unset wantutf8
fi
unset locales
fi
else
dprint "- ... without SSH_LANG, why mess with it?"
fi
fi
dprint - LANG is $LANG
unset LESSCHARSET
if [[ $LANG == *.@(u|U)@(t|T)@(f|F)?(-)8 ]] ; then
export LESSCHARSET=utf-8
fi
if [[ -r /sw/bin/init.sh ]] ; then
dprint Loading fink stuff ...
source /sw/bin/init.sh
fi
if have ssh-agent ; then
function get_ssh_info \
{
dprint - getting ssh-agent info
{ read SSH_AUTH_SOCK; read SSH_AGENT_PID; } < ~/.ssh_agent_socketinfo
SSH_AUTH_SOCK="${SSH_AUTH_SOCK%; export *}"
SSH_AUTH_SOCK="${SSH_AUTH_SOCK#SSH_AUTH_SOCK=}"
SSH_AGENT_PID="${SSH_AGENT_PID%; export *}"
SSH_AGENT_PID="${SSH_AGENT_PID#SSH_AGENT_PID=}"
export SSH_AUTH_SOCK SSH_AGENT_PID
}
dprint Setting up the ssh-agent environment
if [[ -z $SSH_AUTH_SOCK ]] ; then
if [ -f ~/.ssh_agent_socketinfo ] ; then
get_ssh_info
fi
if [[ $USER != root && ( -z $SSH_AUTH_SOCK || ! -S $SSH_AUTH_SOCK ) ]] ; then
dprint - launching ssh-agent
ssh-agent -s > ~/.ssh_agent_socketinfo
get_ssh_info
fi
fi
dprint "- SSH_AUTH_SOCK => $SSH_AUTH_SOCK"
dprint "- SSH_AGENT_PID => $SSH_AGENT_PID"
unset -f get_ssh_info
fi
function get_gpg_info \
{
dprint - getting gpg-agent info
read GPG_AGENT_INFO < ~/.gpg_agent_socketinfo
export GPG_AGENT_INFO="${GPG_AGENT_INFO#GPG_AGENT_INFO=}"
}
function setup_gpg_agent \
{
dprint - launching gpg-agent
gpg-agent --daemon --quiet \
--write-env-file ~/.gpg_agent_socketinfo >/dev/null
get_gpg_info
export GPG_TTY=`tty`
}
function fix_gpg_agent \
{
dprint Setting up the gpg-agent environment
if [ -f ~/.gpg_agent_socketinfo ] ; then
get_gpg_info
fi
if [ "$GPG_AGENT_INFO" -a -r "${GPG_AGENT_INFO%%:*}" ] ; then
gpg_agent_pid=${GPG_AGENT_INFO%:*}
gpg_agent_pid=${gpg_agent_pid#*:}
if kill -0 $gpg_agent_pid 2>/dev/null ; then
dprint - agent already running
export GPG_AGENT_INFO
export GPG_TTY=`tty`
else
setup_gpg_agent
fi
unset gpg_agent_pid
else
setup_gpg_agent
fi
dprint "- GPG_AGENT_INFO => $GPG_AGENT_INFO"
dprint "- GPG_TTY => $GPG_TTY"
}
if have gpg-agent ; then
fix_gpg_agent
else
unset -f setup_gpg_agent fix_gpg_agent get_gpg_info
fi
dprint Setting up aliases ...
function exec_cvim {
for V in /Applications/Vim-cocoa.app/Contents/MacOS/Vim \
/Applications/Vim.app/Contents/MacOS/Vim ; do
if [ -x "$V" ] ; then
"$V" -g "$@" 2>/dev/null &
break;
fi
done
}
function darwin_locate { mdfind "kMDItemDisplayName == '$@'wc"; }
if [[ $- == *i* && $OSTYPE == darwin* && ${OS_VER[0]} -ge 8 ]] ; then
alias locate=darwin_locate
fi
function printargs { for F in "$@" ; do printf '%s\n' "$F" ; done ; }
function printarray {
for ((i=0;$i<`eval 'echo ${#'$1'[*]}'`;i++)) ; do
echo $1"[$i]" = `eval 'echo ${'$1'['$i']}'`
done
}
function foreach { prog="$1"; shift; for F in "$@" ; do "$prog" "$F" & done }
if [[ $- == *i* ]]; then
alias back='cd "$OLDPWD"'
if [[ $OSTYPE == darwin* ]]; then
dprint "- DARWIN ls"
alias ls='/bin/ls -FG'
alias ll='/bin/ls -lhFG'
elif have colorls ; then
dprint "- BSD colorls"
alias ls='colorls -FG'
alias ll='colorls -lhFG'
else
__kbwbashrc__lsarray=(`\type -ap ls`)
__kbwbashrc__lsfound=no
for ((i=0;$i<${#__kbwbashrc__lsarray[*]};i=$i+1)) ; do
if ${__kbwbashrc__lsarray[$i]} --version 2>/dev/null | grep 'GNU coreutils' &>/dev/null ; then
dprint "- found GNU ls: ${__kbwbashrc__lsarray[$i]}"
alias ls="${__kbwbashrc__lsarray[$i]} --color -F"
alias ll="${__kbwbashrc__lsarray[$i]} --color -F -lh"
__kbwbashrc__lsfound=yes
break
fi
done
if [ "$__kbwbashrc__lsfound" == no ] ; then
if ls -F &>/dev/null ; then
dprint "- POSIX ls"
alias ls='ls -F'
alias ll='ls -lhF'
else
alias ll='ls -lh'
fi
fi
unset __kbwbashrc__lsarray __kbwbashrc__lsfound
fi
if [[ $OSTYPE == linux* ]] ; then
alias gv="gv --watch --antialias"
else
alias gv="gv -watch -antialias"
fi
if have gsed ; then
alias sed=gsed
elif have gnused ; then
alias sed=gnused
fi
if have gmake ; then
alias make=gmake
elif have gnumake ; then
alias make=gnumake
fi
have ggrep && alias grep=ggrep
if [[ $OSTYPE == darwin* ]] ; then
_PSARGS="-a -w -w -x"
elif [[ $OSTYPE == linux* ]] ; then
_PSARGS="awx"
elif ps awx &>/dev/null ; then
_PSARGS="awx"
elif ps -A -f &>/dev/null ; then
_PSARGS="-A -f"
else
_PSARGS="ax"
fi
eval "function psq { ps ${_PSARGS} | grep -i \"\$@\" | grep -v grep ; }"
unset _PSARGS
alias macfile="perl -e 'tr/\x0d/\x0a/'"
have tidy && alias tidy='tidy -m -c -i'
have vim && alias vi='vim'
[ -x /Applications/Vim.app/Contents/MacOS/Vim ] && alias vim=/Applications/Vim.app/Contents/MacOS/Vim
alias vlock='vlock -a'
alias fastscp='scp -c arcfour -o Compression=no'
alias startx='nohup ssh-agent startx & exit'
alias whatlocale='printenv | grep ^LC_'
alias fixx='xauth generate $DISPLAY'
alias whatuses='fuser -v -n tcp'
alias which=type
have watch || source ~/.conf/watch.sh
alias ssh='env TERM="$TERM:$LANG" ssh'
have realpath || alias realpath=realpath_func
if have readlink ; then
unset -f readlink_func
else
alias readlink=readlink_func
fi
if [[ $OSTYPE == darwin* ]]; then
alias top='top -R -F -ocpu -Otime'
if have mvim ; then
alias cvim=mvim
alias gvim=mvim
else
alias cvim=exec_cvim
alias gvim=exec_cvim
fi
fi
if ! have uxterm ; then
have xterm && alias uxterm="~/.conf/uxterm"
fi
fi
completion_options=(
/etc/bash_completion
/opt/local/etc/bash_completion
~/.conf/bash_completion
)
if [[ $BASH_VERSION && -z $BASH_COMPLETION && $- == *i* ]] ; then
bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
if [ $bmajor -eq 2 -a $bminor '>' 04 ] || [ $bmajor -gt 2 ] ; then
for bc in "${completion_options[@]}" ; do
if [[ -r $bc ]] ; then
dprint Loading the bash_completion file $bc
[[ ${BASH_COMPLETION} ]] || BASH_COMPLETION="$bc"
export COMP_CVS_ENTRIES=yes
source "$bc"
break
fi
done
fi
unset bash bminor bmajor
fi
unset completion_options
function have { type "$1" &>/dev/null ; }
dprint Checking for bashrc.local in $HOME
if [[ -r ${HOME}/.bashrc.local ]]; then
dprint - loading local bashrc
source "${HOME}/.bashrc.local"
fi
if [[ $TMOUT && $- == *i* ]]; then
echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
echo You will be autologged out after:
echo -e -n '\t'
seconds=$TMOUT
days=$((seconds/60/60/24))
seconds=$((seconds-days*24*60*60))
hours=$((seconds/60/60))
seconds=$((seconds-hours*60*60))
minutes=$((seconds/60))
seconds=$((seconds-minutes*60))
[[ $days != 0 ]] && echo -n "$days days "
[[ $hours != 0 ]] && echo -n "$hours hours "
[[ $minutes != 0 ]] && echo -n "$minutes minutes "
[[ $seconds != 0 ]] && echo -n "$seconds seconds "
echo
echo ... of being idle.
unset days hours minutes seconds
fi
unset -f verify_path
[[ $OSTYPE == solaris* ]] || unset KBW_SYSTEM_BASHRC KBW_SYSTEM_PROFILE
dprint BASHRC_DONE