Skip to content

Commit a65c7b3

Browse files
committed
Use notebook_dir or file_to_run automatically
1 parent c52790f commit a65c7b3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

nbopen.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ def nbopen(filename, profile='default'):
3131
webbrowser.open(url, new=2)
3232
elif filename.startswith(home_dir):
3333
print("Starting new server")
34-
notebookapp.launch_new_instance(file_to_run=os.path.abspath(filename),
35-
notebook_dir=home_dir,
36-
open_browser=True,
34+
filename = os.path.abspath(filename)
35+
if os.path.isdir(filename):
36+
kw = {'notebook_dir': filename}
37+
else:
38+
kw = {'file_to_run': filename}
39+
notebookapp.launch_new_instance(open_browser=True,
3740
argv=[], # Avoid it seeing our own argv
41+
**kw,
3842
)
3943
else:
4044
raise OutsideHomeDir

0 commit comments

Comments
 (0)