summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-10-04 02:32:18 +0200
committerAndrew Cady <d@jerkface.net>2015-10-04 02:32:18 +0200
commit99355c4dd618336c07c44396fd8a2e1b8beaf5aa (patch)
treef2733d8d7a8826b235662f28280f2e6d5fe8bdd5
parent13a17d4d90505bb6ead6938ffa5e9f3b4eaf76ee (diff)
.bashrc from adam
-rw-r--r--dot/bashrc292
1 files changed, 292 insertions, 0 deletions
diff --git a/dot/bashrc b/dot/bashrc
new file mode 100644
index 0000000..eb4c818
--- /dev/null
+++ b/dot/bashrc
@@ -0,0 +1,292 @@
1# ~/.bashrc: executed by bash(1) for non-login shells.
2
3. /usr/local/src/haskell-platform/hproj.sh
4
5memoize_retval()
6{
7 local var="$1" func="$2"
8 if [ -z "${!var}" ]; then
9 eval "$func"
10 eval "$var=$?"
11 fi
12 return ${!var}
13}
14
15move_download()
16{
17 rsync --remove-source-files -aP "$@" hydra:/srv/depot/hermes-downloads/
18}
19
20backup_downloads()
21{
22 rsync -aP /home/d/downloads/ hydra:/srv/depot/hermes-downloads/
23}
24
25backup_home()
26{
27 rsync -aP --delete-after --exclude /downloads /home/d/ hydra:/srv/depot/hermes-backup/
28}
29
30### history archival ###
31
32 if [ -n "$PS1" -a -f ~/.bash_history_archive ]; then
33 if cat ~/.bash_history >> ~/.bash_history_archive; then
34 history -r ~/.bash_history
35 :> ~/.bash_history
36 fi
37 fi
38
39### keychain ###
40
41if false && [ -n "$(which keychain)" ]; then
42 keychain --quiet --inherit any
43 if [ -f "$HOME"/.keychain/"$(hostname)"-sh ]; then
44 . "$HOME"/.keychain/"$(hostname)"-sh;
45 fi
46fi
47
48### utility functions ###
49
50 quiet() { "$@" >/dev/null 2>&1; }
51 match_glob() { eval "case \"$2\" in $1) true ;; *) false ;; esac"; }
52 match_path() { match_glob "*:$1:*|$1:*|*:$1" "$PATH"; }
53 if match_glob "*zsh" "$SHELL"; then
54 have() { for c in "$@"; do quiet whence -p "$c" || return 1; done; }
55 else
56 have() { for c in "$@"; do quiet type -P "$c" || return 1; done; }
57 fi
58 add_path()
59 {
60 if [ "$1" = "-a" ]; then
61 local after=1
62 shift
63 else
64 local after=
65 fi
66 for p in "$@"; do
67 if [ -d "$p" ] && ! match_path "$p" ]; then
68 [ -n "$after" ] && PATH="$PATH:$p"
69 [ -z "$after" ] && PATH="$p:$PATH"
70 fi
71 done
72 }
73
74### bash settings, general environment ###
75
76 add_path -a /usr/games
77 add_path "$HOME/.cabal/bin" "$HOME/.local/bin" "$HOME/bin"
78# add_path "/home/d/.stack/programs/i386-linux/ghc-7.10.1/bin/"
79
80 if match_glob "*zsh" "$SHELL"; then
81 autoload -U select-word-style
82 select-word-style bash
83 # WORDCHARS='*?_-[]~\!#$%^(){}<>|`@#$%^*()+:?'
84 fi
85
86 if match_glob "*bash" "$SHELL"; then
87 export PS1='\u@\h:\w\$ '
88 fi
89 if have sea; then
90 eval `sea` # sets PS1 and PROMPT_COMMAND
91 # must come before dynamic titles section, below
92 fi
93 case $SHELL in
94 bash) shopt -s checkwinsize ;;
95 *) ;;
96 esac
97 umask 002
98
99 if have vim; then
100 alias vi=vim
101 export EDITOR=vim
102 elif have vi; then
103 export EDITOR=vi
104 fi
105
106 if have less; then
107 export PAGER=less
108 export LESS=-XS
109 have lesspipe && eval "$(lesspipe)"
110 elif have w3m; then
111 export PAGER=w3m
112 elif have more; then
113 export PAGER=more
114 fi
115
116### dynamic titles for xterm & screen ###
117
118 function set_xterm_title () {
119 # This is unneeded since my .screenrc is configured to set the xterm
120 # title to the hardstatus line, which is configured to include the
121 # current screen title... and a good thing too, or xterm titles
122 # wouldn't change when screen windows were switched...
123 echo -ne "\033]0;$*\007" >&2
124 }
125 function set_screen_title () {
126 echo -ne "\033k$*\033\\" >&2
127 }
128 function xterm_preexec () {
129 set_xterm_title ${PREEXEC_CMD[@]}
130 }
131 function screen_preexec () {
132 set_screen_title ${PREEXEC_CMD[@]}
133 }
134 function screen_postexec () {
135 set_screen_title "${PWD/$HOME/~}"
136 }
137 function xterm_postexec () {
138 set_xterm_title "$USER@$HOST:${PWD/$HOME/~}"
139 }
140 if [ -n "$STY" ]; then
141 PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }screen_postexec"
142 PREEXEC_COMMAND=screen_preexec
143 elif match_glob "xterm*" "$TERM"; then
144 HOST=$(hostname)
145 PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }xterm_postexec"
146 PREEXEC_COMMAND=xterm_preexec
147 fi
148
149### program settings and aliases ###
150
151 alias ip=/sbin/ip
152 alias ipaddr='ip addr'
153
154 if have ps && match_glob 'procps*' $(ps -V 2>/dev/null); then
155 export PS_FORMAT=pid,user:6,tty,\%mem,\%cpu,start,cmd
156 alias p='ps x -H'
157 have less && alias pp='p a |grep -v " \[[^] ]\+\]\$"| less -RSeX'
158# have less && alias pp='p a |sed -ne '\''1,/^[^ ]* *1 /!p;/^[^ ]* *1 /p'\''| less -RSeX'
159 fi
160
161 export PARINIT='rTbgqR B=.,?_A_a Q=_s>|'
162 export JACK_START_SERVER=1;
163
164 if have irssi; then
165 alias anet='irssi -c Afternet'
166 alias freenode='irssi -c Freenode'
167 fi
168
169 if have Xvnc; then
170 alias startvnc='xinit -- `which Xvnc` :1 -geometry 800x600'
171 fi
172
173 if have xemacs; then
174 alias gnus='DISPLAY= xemacs -f gnus'
175 alias emacs='DISPLAY= xemacs'
176 fi
177
178 if have firefox; then
179 alias ff='killall firefox-bin; firefox'
180 fi
181
182 if quiet ls -d -sCF --color=tty /; then
183 alias ls='ls -sCF --color=tty';
184 lss () { command ls -sCF --color "$@" | less -RSeX; };
185 elif quiet ls -d -sCF /; then
186 alias ls='ls -sCF';
187 lss () { command ls -sCF "$@" | less -RSeX; };
188 fi
189
190 nw()
191 {
192 if [ -z "$SSH_AGENT_PID" ]; then
193 eval $(ssh-agent -s)
194 ssh-add
195 fi
196 ssh -A ns1.nextwerk.com
197 }
198
199 bt()
200 {
201 btdownloadheadless "$@" | paragraph-uniq | paragraph-clear
202 }
203
204 mplayer()
205 {
206 MPLAYER_VERBOSE=-9 command mplayer -msglevel avsync=5 "$@" 2>/dev/null;
207 }
208
209 mkcd()
210 {
211 if [ $# -gt 1 ]; then
212 echo 'mkcd: usage: mkcd <directory>'
213 fi
214 mkdir -p "$1" && cd "$1";
215 }
216
217 alias m-a='m-a -t'
218 alias jf='ssh -tX bucky '
219 alias jfs='ssh -tX bucky screen -x'
220
221 alias ll='ls -l';
222 alias lls='lss -l';
223 alias pd=pushd
224
225 alias sudo='sudo '
226 alias s='screen '
227
228 alias csi='csi -q'
229 alias bc='bc -q'
230 alias apt='sudo aptitude'
231
232 alias df='df -x fuse'
233 alias mtr='mtr --curses'
234
235 doc () { pushd /usr/share/doc/$1; }
236
237 lddsize()
238 {
239 ldd "$@"|while read lib _x file addr; do
240 [ -f "$file" ] || continue;
241 echo -en "$file\0";
242 done | xargs -0 du -cshD;
243 }
244
245### w3m bookmarks ###
246
247if have w3m; then
248 alias sd='w3m http://www.slashdot.org'
249 alias blog='w3m http://insoul.net/blogdate.php?plain=yes'
250 alias news='w3m http://news.google.com/?ned=tus'
251 alias cl='w3m hartford.craigslist.org'
252fi
253
254if ! have srfi; then
255 srfi ()
256 {
257 w3m http://srfi.schemers.org/srfi-"$1"/srfi-"$1".html
258 }
259fi
260
261### array stack interface ###
262
263pusha ()
264{
265 local arr="$1";
266 shift;
267 for t in "$@"; do
268 eval $arr'[${#'$arr'[@]}]='"\"$t\""
269 done;
270}
271
272popa () { eval unset $1'[${#'$1'[@]}-1]'; }
273topa () { eval echo '${'$1'[${#'$1'[@]}-1]}'; }
274echoa () { eval echo '${'$1'[@]}'; }
275alias irc='jfx jerkface.net screen -xRR irc'
276alias code='jfx jerkface.net screen -xRR code'
277alias grep='grep --exclude-dir=.svn'
278
279pigeondl ()
280{
281 rsync -aP "$@" pigeon:watch.onion/;
282}
283skp ()
284{
285 a=$*
286 w3m -o http_proxy=http://localhost:8123 -o use_proxy=1 http://wtwfzc6ty2s6x4po.onion/"$a"
287}
288skp () { w3m -o http_proxy=http://localhost:8123 -o use_proxy=1 -o use_cookie=1 -o accept_cookie=1 -o show_cookie=0 http://wtwfzc6ty2s6x4po.onion/; }
289dorner ()
290{
291 DOOMWADDIR=$HOME/src/zdoom/release LD_LIBRARY_PATH=$HOME/src/zdoom/fmodapi42636linux/api/lib/ $HOME/src/zdoom/release/zdoom -file \$HOME/Dorners\ Last\ Stand Skins/DoRnerLastStand.wad
292}