# HG changeset patch # User Steve Huston # Date 1491852708 14400 # Node ID cfbaaeb8b71d4d94277bb84c76c08c6e8f534a95 # Parent 1dc2b14d4f02b78dfd6457dc8f587ec9386cf190 This makes 'hgs' work nicer on Linux, still may be more tweaks to do diff -r 1dc2b14d4f02 -r cfbaaeb8b71d .bash_aliases --- a/.bash_aliases Wed Mar 15 11:40:14 2017 -0400 +++ b/.bash_aliases Mon Apr 10 15:31:48 2017 -0400 @@ -246,18 +246,25 @@ } hgs() { - # Currently works on Macs, I should write a version for Linux as well - # someday + # We assume here that if the host is a Mac, we're going to open the + # connection automatically, otherwise we echo the URL to the terminal to be + # opened ROOT=`hg root` if [ "$1" == "end" -a -e $ROOT/.hg/hgserve-PID ] ; then kill `cat $ROOT/.hg/hgserve-PID` rm $ROOT/.hg/hgserve-PID - elif [ -e $ROOT/.hg/hgserve-PID ] ; then - P=`cat $ROOT/.hg/hgserve-PID` - URL=`lsof -p $P | grep LISTEN | awk '{print $9}'` - open http://$URL/ else - hg serve -a localhost -d -p 0 --pid-file $ROOT/.hg/hgserve-PID | sed 's#.*bound to \(.*\))#http://\1/#' | xargs open + if [ -e $ROOT/.hg/hgserve-PID ] ; then + P=`cat $ROOT/.hg/hgserve-PID` + URL=`lsof -n -p $P | grep LISTEN | awk '{print $9}'` + else + URL=`hg serve -a localhost -d -p 0 --pid-file $ROOT/.hg/hgserve-PID | sed 's#.*bound to \(.*\))#\1#'` + fi + if [ -z "$DARWIN" ] ; then + echo hg serve on http://$URL/ + else + open http://$URL/ + fi fi }