Skip to content

Commit

Permalink
Generalize commands across OSes
Browse files Browse the repository at this point in the history
- support Arch, Debian and Mac OS (with homebrew) with package shortcuts
- generalize sudo commands for root
  • Loading branch information
thepeterstone committed Jan 27, 2012
1 parent 84cf679 commit 9a671cf
Showing 1 changed file with 39 additions and 26 deletions.
65 changes: 39 additions & 26 deletions dot-files/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -79,39 +79,60 @@ alias ls="ls $LS_OPTS"
export TREE_OPTS="-I '*.pyc' -Ch --filelimit 20"
alias tree="tree $TREE_OPTS"

# installation and compilation
alias cmi="sudo date && ./configure $CONF && make && make test && sudo make install && make clean && date"
#### 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=''
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

# screen-related
alias svim='screen vim'

# frequent sudo tasks
alias get='sudo apt-get install'
alias apres='sudo apache2ctl restart'
alias agu='sudo apt-get update; sudo apt-get upgrade; sudo apt-get dist-upgrade'
alias acs='apt-cache search'
ns () {
sudo vim /etc/apache2/sites-available/$1.terst.org +":0r /etc/apache2/sites-available/template" +":%s/DEFAULT/$1/g"
$SUDO vim /etc/apache2/sites-available/$1.terst.org +":0r /etc/apache2/sites-available/template" +":%s/DEFAULT/$1/g"
if [ $? -eq 0 ]; then
sudo mkdir -p /workspace/sites/$1.terst.org/docroot
sudo ln -s /workspace/sites/$1.terst.org /var/www/htdocs/$1.terst.org
sudo a2ensite $1.terst.org
sudo apache2ctl restart
$SUDO mkdir -p /workspace/sites/$1.terst.org/docroot
$SUDO ln -s /workspace/sites/$1.terst.org /var/www/htdocs/$1.terst.org
$SUDO a2ensite $1.terst.org
$SUDO apache2ctl restart
echo "http://$1.terst.org/ is active."
else
echo "cancelled...."
fi
}
es () {
sudo vim /etc/apache2/sites-available/$1.terst.org && sudo apache2ctl restart
$SUDO vim /etc/apache2/sites-available/$1.terst.org && $SUDO apache2ctl restart
}
# xkcd.com/149
mmas ()
{
echo "What? Make it yourself."
echo "-> sudo $(history|tail -1|sed "s/ [0-9][0-9][0-9][0-9][ *] //")"
echo "-> $SUDO $(history|tail -1|sed "s/ [0-9][0-9][0-9][0-9][ *] //")"
echo "Ok."
sudo $(history|tail -1|sed "s/ [0-9][0-9][0-9][0-9][ *] //")
$SUDO $(history|tail -1|sed "s/ [0-9][0-9][0-9][0-9][ *] //")
}

# update this config and reload
Expand All @@ -132,14 +153,6 @@ tlog ()
tail -fn0 /var/log/apache2/{$1.access,error,rewrite}.log
fi
}


sd ()
{
svn diff --diff-cmd=colordiff $@ | more
}
alias zf=/workspace/runtimes/ZendFramework-1.11.10/bin/zf.sh
alias sc="sudo -u www-data /workspace/sites/s.terst.org/app/console"
cdls () {
\cd $1
ls -t --color=always | head -3 | sed 's/^/\t/'
Expand Down

0 comments on commit 9a671cf

Please sign in to comment.