delete emacs from base
[home-base.git] / .bashrc
1 # ~/.bashrc: executed by bash(1) for non-login shells.
2 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
3 # for examples
4
5 # If running interactively, then:
6 if [ "$PS1" ]; then
7
8     # don't put duplicate lines in the history. See bash(1) for more options
9     export HISTCONTROL=ignoredups
10     if [ -x ~/bin/sane_editor ]; then
11         EDITOR=~/bin/sane_editor;
12     elif [ -x /usr/bin/jed ]; then
13         EDITOR="/usr/bin/jed";
14     elif [ -x /usr/bin/vi ]; then
15         EDITOR="/usr/bin/vi";
16     fi;
17
18     if [ -n "$EDITOR" ]; then
19         export EDITOR;
20     fi;
21     # bts debian options
22
23     if [ -e bin/faf ]; then
24         complete -F _command faf
25     fi;
26
27     export DEBEMAIL="don@debian.org"
28     export DEBHOME="$(eval 'echo' '~/projects/debian')"
29
30     export GTK_IM_MODULE=xim
31     export QT_IM_MODULE=xim
32
33     # enable color support of ls and also add handy aliases
34     eval `dircolors -b`
35     alias ls='ls --color=auto'
36     alias gr='gimp-remote'
37     alias emc='sane_editor'
38
39     alias svn-b="svn-buildpackage --svn-builder 'pdebuild --buildresult ..' --svn-ignore-new"
40
41     # set a fancy prompt
42     #printf '\33]2;%s\007'
43     
44     # See if we're in a chroot
45     if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
46         debian_chroot=$(cat /etc/debian_chroot)
47     fi
48
49     # we want to set the color based on what machine we're on
50     # if it's a remote, SSH_CONNECTION will be set
51     # set variable identifying the chroot you work in (used in the prompt below)
52     
53     # disable terminal bell
54     bind 'set bell-style none'
55
56     if [ -n "$SSH_CONNECTION" -o -n "$SSH_CLIENT" ]; then
57         # figure out what color to use
58         COLOR=$(hostname|md5sum|perl -ne 'if (/^([a-f\d]{8})/) {
59               my $num = unpack(q(L),pack(q(H*),$1));
60               my @col = map {(qq(0;${_}m),qq(1;${_}m))} 31..37;
61               my $col = $col[$num % @col];
62               if ($col eq q(0;36m)) {
63                  $col = q(1;30m);
64               }
65               print $col;
66               }')
67         PS1="${debian_chroot:+($debian_chroot)}\[\033[$COLOR\]\h \[\033[0;36m\]\t \w$\[\033[0m\] "
68         unset COLOR
69     else
70         PS1="${debian_chroot:+($debian_chroot)}\[\033[0;36m\]\h \t \w$\[\033[0m\] "
71     fi;
72     # \[\033[1;36m\][\w]\n\[\033[0;36m\][\h|\t]$ \[\033[0m\]
73
74     # make sure the term we're using exists in the termcap
75     TOEOPT='-a'
76     if ! toe $TOEOPT >/dev/null 2>&1; then
77         TOEOPT=''
78     fi;
79     if ! toe $TOEOPT|grep -q "^$TERM    "; then
80         # if it doesn't, try to switch
81         case $TERM in
82             rxvt*)
83                 TERM="rxvt"
84                 ;;
85             xterm*)
86                 TERM="xterm"
87                 ;;
88             *)
89                 ;;
90         esac
91         export TERM;
92     fi;
93     # If this is an xterm set the title to user@host:dir
94     case $TERM in
95         screen|xterm*)
96             PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
97             ;;
98         rxvt*)
99             PROMPT_COMMAND='echo -ne "\033]2;${USER}@${HOSTNAME}: ${PWD}\007"'
100             ;;
101
102         *)
103             ;;
104     esac
105
106     # enable programmable completion features (you don't need to enable
107     # this, if it's already enabled in /etc/bash.bashrc).
108     if [ -f /etc/bash_completion ]; then
109       . /etc/bash_completion;
110     fi;
111
112     # set up ssh-agent
113     if which ssh-agent >/dev/null && [ -d ~/.ssh ] &&  \
114         [ -z "$SSH_CONNECTION" ] &&  [ -z "$SSH_CLIENT" ]; then 
115 #       for 
116         if [ -e ~/.ssh/ssh_agent_info ] && \
117             [ -n "$(awk -F '[=;]' '/^SSH_AGENT_PID/{print $2}' ~/.ssh/ssh_agent_info)" ] && \
118             kill -0 "$(awk -F '[=;]' '/^SSH_AGENT_PID/{print $2}' ~/.ssh/ssh_agent_info)" >/dev/null 2>&1; then
119             . ~/.ssh/ssh_agent_info > /dev/null
120         elif [ -e ~/.ssh/ssh_agent_info_$(hostname) ] && \
121             kill -0 "$(awk -F '[=;]' '/^SSH_AGENT_PID/{print $2}' ~/.ssh/ssh_agent_info_$(hostname))" >/dev/null 2>&1; then
122             . ~/.ssh/ssh_agent_info_$(hostname) > /dev/null
123         else
124             ssh-agent -s > ~/.ssh/ssh_agent_info_$(hostname)
125             . ~/.ssh/ssh_agent_info_$(hostname) > /dev/null
126         fi;
127     fi;
128     
129     alias aumix2='aumix -d /dev/mixer1 -I'
130     if locale -a |grep -qi en_US.utf8; then
131         LANG="en_US.UTF-8"
132     else
133         LANG=C
134     fi;
135     export LANG
136     
137     # If we're running on liszt, include /var/list/.bin in the path
138     if [ "$(hostname)" == "liszt" ] && [ -d /var/list/.bin ]; then
139         PATH="/var/list/.bin:$PATH"
140     fi;
141     export PATH="$(getent passwd $(id -u)|awk -F: '{print $6}')/bin:$PATH"
142     
143     if [ ! -e ~/tmp ]; then
144         mkdir ~/tmp;
145     fi;
146     export TMPDIR="$(echo ~/tmp)";
147
148 #     if [ -n "$(which devtodo)" ]; then
149 #       for a in tda tdd tde; do
150 #           alias "s${a}"="STODO_NO_COMMIT=1 $a"
151 #       done;
152
153 #       TODO_OPTIONS="--timeout --summary"
154
155         cd ()
156         {
157             # use pushd instead of cd
158             if [ -z "$1" ] || [ "$1" == "-" ]; then
159                 builtin cd "$@"; # && [ -r .todo ] && devtodo ${TODO_OPTIONS};
160             else
161                 builtin pushd "$@" >/dev/null; # && [ -r .todo ] && devtodo ${TODO_OPTIONS};
162             fi;
163         }
164
165         # various livetv streams
166         alias "watch_cspan"="rtmpdump -v -r rtmp://cp82346.live.edgefcs.net:1935/live -y CSPAN1@14845 -W http://www.c-span.org/cspanVideoHD.swf -p http://www.c-span.org/Live-Video/C-SPAN/ | mplayer -xy 3 -"
167         alias "watch_cspan2"="rtmpdump -v -r rtmp://cp82347.live.edgefcs.net:1935/live -y CSPAN2@14846 -W http://www.c-span.org/cspanVideoHD.swf -p http://www.c-span.org/Live-Video/C-SPAN2/ | mplayer -xy 3 -"
168         alias "watch_cspan3"="rtmpdump -v -r rtmp://cp82348.live.edgefcs.net:1935/live -y CSPAN3@14847 -W http://www.c-span.org/cspanVideoHD.swf -p http://www.c-span.org/Live-Video/C-SPAN3/ | mplayer -xy 3-"
169         alias "watch_cnn"="rtmpdump -v -r rtmp://cp44679.live.edgefcs.net/live -y cnn_stream1_low@2785 -a live -W http://i.cdn.turner.com/cnn/.element/apps/CNNLive/2.1.5.7/assets/swfs/LivePlayer.swf -p http://www.cnn.com/video/flashLive/live.html?stream=1 | mplayer -xy 2 -"
170         alias "watch_bloomberg"="rtmpt://cp87869.live.edgefcs.net:1935/live -a live -y us_300@21006 -W http://cdn.gotraffic.net/v/20110210_153738//flash/BloombergMediaPlayer.swf -p http://www.bloomberg.com/tv/ | mplayer -xy 2 -"
171
172
173 #       pushd ()
174 #       {
175 #             builtin pushd "$@" && [ -r .todo ] && devtodo ${TODO_OPTIONS}
176 #       }
177 #       
178 #       popd ()
179 #       {
180 #             builtin popd "$@" && [ -r .todo ] && devtodo ${TODO_OPTIONS}
181 #       }              
182         
183         # Run todo initially upon login
184 #       devtodo ${TODO_OPTIONS}
185 #     fi;
186 fi