From 99355c4dd618336c07c44396fd8a2e1b8beaf5aa Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 4 Oct 2015 02:32:18 +0200 Subject: .bashrc from adam --- dot/bashrc | 292 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 dot/bashrc diff --git a/dot/bashrc b/dot/bashrc new file mode 100644 index 0000000..eb4c818 --- /dev/null +++ b/dot/bashrc @@ -0,0 +1,292 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. + +. /usr/local/src/haskell-platform/hproj.sh + +memoize_retval() +{ + local var="$1" func="$2" + if [ -z "${!var}" ]; then + eval "$func" + eval "$var=$?" + fi + return ${!var} +} + +move_download() +{ + rsync --remove-source-files -aP "$@" hydra:/srv/depot/hermes-downloads/ +} + +backup_downloads() +{ + rsync -aP /home/d/downloads/ hydra:/srv/depot/hermes-downloads/ +} + +backup_home() +{ + rsync -aP --delete-after --exclude /downloads /home/d/ hydra:/srv/depot/hermes-backup/ +} + +### history archival ### + + if [ -n "$PS1" -a -f ~/.bash_history_archive ]; then + if cat ~/.bash_history >> ~/.bash_history_archive; then + history -r ~/.bash_history + :> ~/.bash_history + fi + fi + +### keychain ### + +if false && [ -n "$(which keychain)" ]; then + keychain --quiet --inherit any + if [ -f "$HOME"/.keychain/"$(hostname)"-sh ]; then + . "$HOME"/.keychain/"$(hostname)"-sh; + fi +fi + +### utility functions ### + + quiet() { "$@" >/dev/null 2>&1; } + match_glob() { eval "case \"$2\" in $1) true ;; *) false ;; esac"; } + match_path() { match_glob "*:$1:*|$1:*|*:$1" "$PATH"; } + if match_glob "*zsh" "$SHELL"; then + have() { for c in "$@"; do quiet whence -p "$c" || return 1; done; } + else + have() { for c in "$@"; do quiet type -P "$c" || return 1; done; } + fi + add_path() + { + if [ "$1" = "-a" ]; then + local after=1 + shift + else + local after= + fi + for p in "$@"; do + if [ -d "$p" ] && ! match_path "$p" ]; then + [ -n "$after" ] && PATH="$PATH:$p" + [ -z "$after" ] && PATH="$p:$PATH" + fi + done + } + +### bash settings, general environment ### + + add_path -a /usr/games + add_path "$HOME/.cabal/bin" "$HOME/.local/bin" "$HOME/bin" +# add_path "/home/d/.stack/programs/i386-linux/ghc-7.10.1/bin/" + + if match_glob "*zsh" "$SHELL"; then + autoload -U select-word-style + select-word-style bash + # WORDCHARS='*?_-[]~\!#$%^(){}<>|`@#$%^*()+:?' + fi + + if match_glob "*bash" "$SHELL"; then + export PS1='\u@\h:\w\$ ' + fi + if have sea; then + eval `sea` # sets PS1 and PROMPT_COMMAND + # must come before dynamic titles section, below + fi + case $SHELL in + bash) shopt -s checkwinsize ;; + *) ;; + esac + umask 002 + + if have vim; then + alias vi=vim + export EDITOR=vim + elif have vi; then + export EDITOR=vi + fi + + if have less; then + export PAGER=less + export LESS=-XS + have lesspipe && eval "$(lesspipe)" + elif have w3m; then + export PAGER=w3m + elif have more; then + export PAGER=more + fi + +### dynamic titles for xterm & screen ### + + function set_xterm_title () { + # This is unneeded since my .screenrc is configured to set the xterm + # title to the hardstatus line, which is configured to include the + # current screen title... and a good thing too, or xterm titles + # wouldn't change when screen windows were switched... + echo -ne "\033]0;$*\007" >&2 + } + function set_screen_title () { + echo -ne "\033k$*\033\\" >&2 + } + function xterm_preexec () { + set_xterm_title ${PREEXEC_CMD[@]} + } + function screen_preexec () { + set_screen_title ${PREEXEC_CMD[@]} + } + function screen_postexec () { + set_screen_title "${PWD/$HOME/~}" + } + function xterm_postexec () { + set_xterm_title "$USER@$HOST:${PWD/$HOME/~}" + } + if [ -n "$STY" ]; then + PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }screen_postexec" + PREEXEC_COMMAND=screen_preexec + elif match_glob "xterm*" "$TERM"; then + HOST=$(hostname) + PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }xterm_postexec" + PREEXEC_COMMAND=xterm_preexec + fi + +### program settings and aliases ### + + alias ip=/sbin/ip + alias ipaddr='ip addr' + + if have ps && match_glob 'procps*' $(ps -V 2>/dev/null); then + export PS_FORMAT=pid,user:6,tty,\%mem,\%cpu,start,cmd + alias p='ps x -H' + have less && alias pp='p a |grep -v " \[[^] ]\+\]\$"| less -RSeX' +# have less && alias pp='p a |sed -ne '\''1,/^[^ ]* *1 /!p;/^[^ ]* *1 /p'\''| less -RSeX' + fi + + export PARINIT='rTbgqR B=.,?_A_a Q=_s>|' + export JACK_START_SERVER=1; + + if have irssi; then + alias anet='irssi -c Afternet' + alias freenode='irssi -c Freenode' + fi + + if have Xvnc; then + alias startvnc='xinit -- `which Xvnc` :1 -geometry 800x600' + fi + + if have xemacs; then + alias gnus='DISPLAY= xemacs -f gnus' + alias emacs='DISPLAY= xemacs' + fi + + if have firefox; then + alias ff='killall firefox-bin; firefox' + fi + + if quiet ls -d -sCF --color=tty /; then + alias ls='ls -sCF --color=tty'; + lss () { command ls -sCF --color "$@" | less -RSeX; }; + elif quiet ls -d -sCF /; then + alias ls='ls -sCF'; + lss () { command ls -sCF "$@" | less -RSeX; }; + fi + + nw() + { + if [ -z "$SSH_AGENT_PID" ]; then + eval $(ssh-agent -s) + ssh-add + fi + ssh -A ns1.nextwerk.com + } + + bt() + { + btdownloadheadless "$@" | paragraph-uniq | paragraph-clear + } + + mplayer() + { + MPLAYER_VERBOSE=-9 command mplayer -msglevel avsync=5 "$@" 2>/dev/null; + } + + mkcd() + { + if [ $# -gt 1 ]; then + echo 'mkcd: usage: mkcd ' + fi + mkdir -p "$1" && cd "$1"; + } + + alias m-a='m-a -t' + alias jf='ssh -tX bucky ' + alias jfs='ssh -tX bucky screen -x' + + alias ll='ls -l'; + alias lls='lss -l'; + alias pd=pushd + + alias sudo='sudo ' + alias s='screen ' + + alias csi='csi -q' + alias bc='bc -q' + alias apt='sudo aptitude' + + alias df='df -x fuse' + alias mtr='mtr --curses' + + doc () { pushd /usr/share/doc/$1; } + + lddsize() + { + ldd "$@"|while read lib _x file addr; do + [ -f "$file" ] || continue; + echo -en "$file\0"; + done | xargs -0 du -cshD; + } + +### w3m bookmarks ### + +if have w3m; then + alias sd='w3m http://www.slashdot.org' + alias blog='w3m http://insoul.net/blogdate.php?plain=yes' + alias news='w3m http://news.google.com/?ned=tus' + alias cl='w3m hartford.craigslist.org' +fi + +if ! have srfi; then + srfi () + { + w3m http://srfi.schemers.org/srfi-"$1"/srfi-"$1".html + } +fi + +### array stack interface ### + +pusha () +{ + local arr="$1"; + shift; + for t in "$@"; do + eval $arr'[${#'$arr'[@]}]='"\"$t\"" + done; +} + +popa () { eval unset $1'[${#'$1'[@]}-1]'; } +topa () { eval echo '${'$1'[${#'$1'[@]}-1]}'; } +echoa () { eval echo '${'$1'[@]}'; } +alias irc='jfx jerkface.net screen -xRR irc' +alias code='jfx jerkface.net screen -xRR code' +alias grep='grep --exclude-dir=.svn' + +pigeondl () +{ + rsync -aP "$@" pigeon:watch.onion/; +} +skp () +{ + a=$* + w3m -o http_proxy=http://localhost:8123 -o use_proxy=1 http://wtwfzc6ty2s6x4po.onion/"$a" +} +skp () { 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/; } +dorner () +{ + 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 +} -- cgit v1.2.3