Skip to content

Instantly share code, notes, and snippets.

@icholy
Created October 12, 2012 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icholy/3879562 to your computer and use it in GitHub Desktop.
Save icholy/3879562 to your computer and use it in GitHub Desktop.
quickly link the current dir to /var/www and open the browser there.
#!/bin/bash
REG_USER=icholy
LINK_NAME=browse
LINK_PATH=/var/www/$LINK_NAME
BROWSER_CMD=chromium-browser
# make sure we're root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2;
exit 1;
fi
# delete old link if one exists
if [ -h $LINK_PATH ]; then
unlink $LINK_PATH;
fi
# create the new link
ln -s "$(pwd)" $LINK_PATH;
# open the browser to the linked dir
su $REG_USER -c "${BROWSER_CMD} http://localhost/${LINK_NAME}/";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment