Created
January 9, 2019 08:50
-
-
Save ulfaslak/6a50db6eb058489041ddd17f0a81f621 to your computer and use it in GitHub Desktop.
nbopen minimal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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