Skip to content

Instantly share code, notes, and snippets.

@ulfaslak
Created January 9, 2019 08:50
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 ulfaslak/6a50db6eb058489041ddd17f0a81f621 to your computer and use it in GitHub Desktop.
Save ulfaslak/6a50db6eb058489041ddd17f0a81f621 to your computer and use it in GitHub Desktop.
nbopen minimal
function nbopen(){
# For this function to work, in .jupyter/jupyter_notebook_config.py, set `c.NotebookApp.notebook_dir = '/'` so notebook always launches from root
if [ $# -eq 0 ] ; then
if lsof -Pi :8888 -sTCP:LISTEN -t > /dev/null ; then
echo "A Jupyter Notebook is already open on port 8888"
else
jupyter notebook --port 8888
fi
else
if [ "${1:0:1}" != "/" ] ; then
address=$(pwd)/$1
else
address=$1
fi
if lsof -Pi :8888 -sTCP:LISTEN -t > /dev/null ; then
open http://localhost:8888/tree"$address"
else
jupyter notebook "$address" --port 8888
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment