Last active
December 19, 2015 23:08
-
-
Save joyrexus/6032345 to your computer and use it in GitHub Desktop.
Revised bash profile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Standard shell environment | |
GREEN="\[\033[0;32m\]" | |
ORANGE="\[\033[0;33m\]" | |
BLUE="\[\033[0;34m\]" | |
RESET="\[\033[0m\]" | |
. /usr/local/etc/bash_completion # tab completion | |
. /usr/local/etc/bash_completion.d/git-prompt.sh # git-enhanced prompt | |
# git-enhanced prompt powered by `git-prompt.sh` | |
PS1="${GREEN}\w${BLUE}\$(__git_ps1 ':%s')${ORANGE}⚡${RESET} " # show git branch | |
PS2='> ' | |
ENV=~/.bashrc | |
PROFILE=~/.bash_profile | |
SHELL=/bin/bash | |
PATH=.:/usr/local/share/python:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/texbin | |
MANPATH=usr/local/share/man:/usr/share/man | |
INFOPATH=/usr/share/info | |
MADPATH=/usr/local/share/mad # man pages in markdown | |
VIM=/usr/share/vim | |
VIMRUNTIME=$VIM/vim72 | |
EDITOR=/usr/bin/vim | |
SVN_EDITOR=$EDITOR | |
PAGER='less -RsMe' | |
LESS='-m' | |
DICT=/usr/share/dict/words | |
LC_ALL="en_US.UTF-8" | |
LANG="en_US" | |
# Colorize ls output | |
CLICOLOR=1 | |
LSCOLORS=exfxcxdxbxegedabagCxEx | |
# User | |
CSS=/Users/jvoigt/Sites/css | |
HOME=/Users/jvoigt | |
REPOS=~/Repos/mine | |
WEBDOCS=/Library/WebServer/Documents | |
# Work | |
WORK=~/Documents/Work | |
CODE=$WORK/Code | |
LIB=$CODE/lib | |
BIN=$CODE/bin | |
REPORTS=$WORK/Reports | |
SANDBOX=$REPOS/sandbox | |
LDP=$WORK/LDP | |
LDP_DB=$LDP/data/trunk/ldp.db | |
LDP_BIN=$LDP/code/trunk/bin | |
LDP_LIB=$LDP/code/trunk/lib | |
LDP_DOCS=$LDP/docs | |
LDP_CODE=$LDP/code/trunk | |
LDP_DATA=$LDP/data/trunk | |
LDP_JOBS=$LDP/data/trunk/jobs | |
# Node | |
NPM_BIN=/usr/local/share/npm/bin | |
NPM_LIB=/usr/local/share/npm/lib/node_modules | |
NODE_PATH=.:$NPM_LIB:$LDP_LIB/node:$LDP_LIB/coffee | |
PATH=$NPM_BIN:$LDP_BIN:$BIN:$PATH | |
# Python | |
export PYTHONPATH=$LDP_LIB/python:$LIB/python | |
export PYTHONSTARTUP="/Users/jvoigt/.pystartup" | |
# Perl | |
PERLDIR=/System/Library/Perl/5.10.0 | |
PERLLIB=/Library/Perl/5.10.0:/System/Library/Perl/5.10.0:$LIB/perl | |
# Settings | |
umask 022 | |
set -o vi | |
set -o noclobber | |
set -o notify | |
# set -o allexport # WAT! conflicts with bash-completion! | |
shopt -s expand_aliases | |
shopt -s extglob | |
shopt -s nocaseglob # case-insensitive globbing (used in pathname expansion) | |
shopt -s cmdhist | |
shopt -s histappend # append to ~/.bash_history rather than overwriting | |
# Supplements | |
. ~/.bashrc # custom aliases and functions | |
. /usr/local/etc/profile.d/z.sh # see github.com/rupa/z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Functions | |
# Convert litcoffee to coffee | |
ltc() { | |
grep '^ ' $1 | sed 's/^ //' | |
} | |
show() { | |
marko --css $CSS/clean.css $1 | browse | |
} | |
# Manage a simple HTTP server | |
# Usage: http start|stop|restart [port] | |
http () { | |
local port="${2:-8000}" | |
case $1 in | |
"start") | |
echo "starting http server" | |
nohup python -m SimpleHTTPServer >| /tmp/nohup.out & | |
open "http://localhost:${port}/" | |
;; | |
"stop") | |
echo "stopping http server" | |
kill $(ps aux | grep "python -m SimpleHTTPServer" \ | |
| grep -v grep \ | |
| awk '{print $2}') > /dev/null | |
;; | |
"restart") | |
echo "restarting http server" | |
kill $(ps aux | grep "python -m SimpleHTTPServer" \ | |
| grep -v grep | awk '{print $2}') > /dev/null | |
nohup python -m SimpleHTTPServer >| /tmp/nohup.out & | |
;; | |
*) | |
echo "need start|stop|restart" | |
esac | |
} | |
# Print IP address | |
ip () { | |
ipconfig getifaddr en0 | |
} | |
# Convert restructuredText file to HTML | |
rst2html () { | |
local FILE=$(echo $1 | sed s/rst/html/) | |
rst2html.py --stylesheet-path $CSS/readme.css $1 >| $FILE | |
open $FILE | |
} | |
# Make a file executable | |
cx () { | |
chmod +x $1 | |
} | |
# Move into latest "dated" directory (DD-MM-YY) | |
cdd () { | |
cd `latest .` | |
} | |
# Move to directory in $REPORTS starting with given string | |
cdr () { | |
local dir=$(echo $1 | tr 'A-Z' 'a-z') | |
cd $REPORTS/$dir* | |
} | |
# Remove directory from svn revision control | |
nosvn () { | |
local DIR=${1:-"."} | |
if [ ! -d $DIR ]; then | |
echo "You need to specify a directory"; | |
break | |
fi | |
read -e -p "Remove $DIR from revision control? (y/n): " CHOICE | |
if [ $CHOICE == "y" ]; then | |
find $DIR -name ".svn" -print0 | xargs -0 rm -Rf | |
fi | |
} | |
# Print repo revision number | |
svnrev () { | |
svn info $1 | awk '/Rev:/ { sub(/.*: /, ""); print }' | |
} | |
# Start the subversion server | |
svnstart () { | |
svnserve -d -r ~/svn --listen-port=3690 | |
} | |
# File aliases | |
alias p=$PROFILE | |
alias e=$ENV | |
alias i="$JOYREX/files/info*" | |
alias t="$JOYREX/files/tips" | |
# Directory aliases | |
alias w=$WORK | |
alias r=$REPOS | |
alias l=$LDP_LIB | |
alias b=$LDP_BIN | |
alias x=$SANDBOX | |
# Command aliases | |
alias P="source $PROFILE" | |
alias d='dirs -v' | |
alias 0='pushd +0 > /dev/null ; dirs -v' | |
alias 1='pushd +1 > /dev/null ; dirs -v' | |
alias 2='pushd +2 > /dev/null ; dirs -v' | |
alias 3='pushd +3 > /dev/null ; dirs -v' | |
alias 4='pushd +4 > /dev/null ; dirs -v' | |
alias 5='pushd +5 > /dev/null ; dirs -v' | |
alias cp='cp -i' | |
alias rm='rm -i' | |
alias mv='mv -i' | |
alias vi='vim ' | |
alias du='du -hc -d 1 ' | |
alias ls='ls -F' | |
alias cd='cd ' | |
alias cdc='cd ~; clear' | |
alias rmc='rm -f *class *pyc' | |
alias cpan='sudo cpan' | |
alias chmod='sudo chmod' | |
alias chown='sudo chown' | |
alias unmount='diskutil unmountDisk' | |
alias hlog='tail /var/log/apache2/error_log' # show tail of httpd error log | |
alias hhup='sudo apachectl restart' # restart web server | |
alias hchk='sudo apachectl configtest' # check web config | |
# alias http='python -m SimpleHTTPServer' # see `declare -f http` | |
alias sql=/usr/bin/sqlite3 | |
alias q="sqlite3 $LDP_DB" # query ldp dataset | |
alias update="svn update $LDP/code $LDP/data $LDP/docs $SGM" | |
alias hotcopy="hot-backup.py --num-backups=2 --archive-type=zip" | |
alias rst2htm="rst2html.py --stylesheet-path $CSS/readme.css" | |
# backup main repos | |
backup () { | |
SOURCE="$HOME/svn" | |
TARGET="$WORK/Backups/repos" | |
if [ -n "$*" ]; then | |
for repo in "$@"; do | |
hotcopy $SOURCE/$repo $TARGET/$repo | |
done | |
else | |
for repo in "sgm" "code" "data" "joyrex" "morphosyntax"; do | |
hotcopy $SOURCE/$repo $TARGET/$repo | |
done | |
hotcopy $SOURCE/ldp $TARGET/docs | |
fi | |
} | |
# mirror backups and versioned data files to $RSYNC | |
mirror () { | |
SOURCE="$WORK/Backups/repos" | |
TARGET="$RSYNC:Backups/Repos" | |
echo "Mirroring backups on $RSYNC" | |
rsync -arzL --delete $SOURCE/* $TARGET | |
SOURCE="$WEBDOCS/LDP/data" | |
TARGET="$RSYNC:Data" | |
echo "Mirroring versioned data files on $RSYNC" | |
rsync -arzL --delete $SOURCE $TARGET | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment