From c197a13d445aede97e31020449e4e8de0cbc07c5 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Tue, 31 Jan 2012 11:18:05 -0800 Subject: [PATCH] organize aliases and fix platform detection --- dot-files/zshrc | 123 ++++++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 55 deletions(-) diff --git a/dot-files/zshrc b/dot-files/zshrc index df9a5e5..cae5abf 100644 --- a/dot-files/zshrc +++ b/dot-files/zshrc @@ -46,6 +46,11 @@ $__history - %(!.%{%}#%{%}.%%) " } setPrompt +logCommand() +{ + ~/bin/log_command.sh +} + # recursive grep # Usage: rg [extension] rg() { @@ -66,51 +71,20 @@ mmas () { sudo $(history|tail -1|sed "s/ [0-9][0-9]*[ *] //") } -### Options and aliases export EDITOR=vim export TERM=xterm-256color - -# ls opts: size, color when to a term -export LS_OPTS="-I '*.pyc' -h --color=auto --group-directories-first" -alias ll='ls -lA' # long listing, + hidden -alias ls="ls $LS_OPTS" - # tree opts: ignore pyc, color, size, skip big directories -export TREE_OPTS="-I '*.pyc' -Ch --filelimit 20" -alias tree="tree $TREE_OPTS" - -#### OS- or distribution-dependent... -ARCH=[ -e /etc/arch-release ] -DEBIAN=[ -e /etc/debian_version ] -MAC=[ "$(uname)" -eq "Darwin" ] #### User-dependent -if [ "$USER" -eq "root" ]; then +SUDO='sudo' +if [ "$USER" = "root" ]; then SUDO='' -else - SUDO='sudo' -fi - - -alias cmi="$SUDO date && ./configure $CONF && make && make test && $SUDO make install && make clean && date" -alias apres="$SUDO apache2ctl restart" - -if $ARCH; then - alias get="$SUDO pacman -S" - alias agu="$SUDO pacman -Syu" - alias acs="$SUDO pacman -Ss" -fi -if $DEBIAN; then - alias get="$SUDO apt-get install" - alias agu="$SUDO apt-get update; $SUDO apt-get upgrade; $SUDO apt-get dist-upgrade" - alias acs="apt-cache search" -fi -if $MAC; then - alias get="brew install" - alias agu="brew update && brew upgrade" - alias acs="brew search" fi +# Apache sites +es () { + $SUDO vim /etc/apache2/sites-available/$1.terst.org && $SUDO apache2ctl restart +} ns () { $SUDO vim /etc/apache2/sites-available/$1.terst.org +":0r /etc/apache2/sites-available/template" +":%s/DEFAULT/$1/g" if [ $? -eq 0 ]; then @@ -123,9 +97,6 @@ ns () { echo "cancelled...." fi } -es () { - $SUDO vim /etc/apache2/sites-available/$1.terst.org && $SUDO apache2ctl restart -} # xkcd.com/149 mmas () { @@ -134,20 +105,8 @@ mmas () echo "Ok." $SUDO $(history|tail -1|sed "s/ [0-9][0-9][0-9][0-9][ *] //") } - -# update this config and reload -alias rc='vim ~/.zshrc && source ~/.zshrc' -alias so="source ~/.zshrc" - -alias histc="rm -rf ~/.lesshst ~/.histfile ~/.viminfo ~/.mysql_history ~/.zcompdump ~/.bash_history ~/.DS_Store ~/.Xauthority ~/.cache ~/.sqlite_history" - - -# Development -alias tailf="tail -fn0" -tlog () -{ - if [ -z "$1" ] - then +tlog () { + if [ -z "$1" ]; then tail -fn0 "/var/log/apache2/*" else tail -fn0 /var/log/apache2/{$1.access,error,rewrite}.log @@ -155,6 +114,60 @@ tlog () } cdls () { \cd $1 - ls -t --color=always | head -3 | sed 's/^/\t/' + # interpolating LS_OPTS at runtime is weird... + ls -thG | head -3 | sed 's/^/ /' } + + +#### OS- or distribution-dependent... +ARCH=false +DEBIAN=false +MAC=false + +if [ "$(uname)" = "Darwin" ]; then + MAC=true +else + if [ -e /etc/arch-release ]; then + ARCH=true + else + if [ -e /etc/debian_version ]; then + DEBIAN=true + fi + fi +fi + +if $ARCH; then + alias get="$SUDO pacman -S" + alias agu="$SUDO pacman -Syu" + alias acs="$SUDO pacman -Ss" +fi +if $DEBIAN; then + alias get="$SUDO apt-get install" + alias agu="$SUDO apt-get update; $SUDO apt-get upgrade; $SUDO apt-get dist-upgrade" + alias acs="apt-cache search" +fi +if $MAC; then + alias get="brew install" + alias agu="brew update && brew upgrade" + alias acs="brew search" + + # Mac UNIX utils aren't GNU + export LS_OPTS="-h -G" + export TREE_OPTS="-Ch" +else + export LS_OPTS="-I '*.pyc' -h --color=auto --group-directories-first" + export TREE_OPTS="-I '*.pyc' -Ch --filelimit 20" +fi + + +alias apres="$SUDO apache2ctl restart" alias cd=cdls +alias cmi="$SUDO date && ./configure \$CONF && make && make test && $SUDO make install && make clean && date" +alias histc="rm -rf ~/.lesshst ~/.histfile ~/.viminfo ~/.mysql_history ~/.zcompdump ~/.bash_history ~/.DS_Store ~/.Xauthority ~/.cache ~/.sqlite_history" +alias ll='ls -lA' # long listing, + hidden +alias ls="ls $LS_OPTS" +alias pu='phpunit --verbose --colors' +alias rc='vim ~/.zshrc && source ~/.zshrc' +alias so="source ~/.zshrc" +alias tailf="tail -fn0" +alias tree="tree $TREE_OPTS"