changeset 125:28c2ddd02e8f

Replace hgs alias with function
author Steve Huston <huston@astro.princeton.edu>
date Wed, 14 Jan 2015 16:00:03 -0500
parents 3f720fcb9710
children 6040767bddec
files .bash_aliases
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 :