# HG changeset patch # User Steve Huston # Date 1421269203 18000 # Node ID 28c2ddd02e8f273f79eac7abd6186a0644b68e84 # Parent 3f720fcb97108b493f3f24444edcedddabe36fa9 Replace hgs alias with function diff -r 3f720fcb9710 -r 28c2ddd02e8f .bash_aliases --- a/.bash_aliases Fri Jan 09 12:36:43 2015 -0500 +++ b/.bash_aliases Wed Jan 14 16:00:03 2015 -0500 @@ -91,7 +91,6 @@ alias atari='atari800 -height 800 -width 600' alias base64='openssl enc -a' alias bsr='bigscreen -raAx' -alias hgs="hg serve -a localhost -p 0 & sleep 1 ; open http://\`lsof -p \$! | grep LISTEN | awk '{print \$9}'\`/ ; fg" alias irssi-test='irssi --home=$HOME/irssi-test/' alias jt65='wine /Users/huston/.wine/drive_c/Program\ Files/jt65hf109/jt65-hf.exe' alias pine='alpine' @@ -247,4 +246,19 @@ echo Files stored in $OUTDIR } +hgs() { + # Currently works on Macs, I should write a version for Linux as well + # someday + if [ "$1" == "end" -a -e .hgserve-PID ] ; then + kill `cat .hgserve-PID` + rm .hgserve-PID + elif [ -e .hgserve-PID ] ; then + P=`cat .hgserve-PID` + URL=`lsof -p $P | grep LISTEN | awk '{print $9}'` + open http://$URL/ + else + hg serve -a localhost -d -p 0 --pid-file .hgserve-PID | sed 's#.*bound to \(.*\))#http://\1/#' | xargs open + fi +} + # vim: set filetype=sh :