mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
added --browser option to notebook
now you can specify --browser=firefox when starting ipython notebook
This commit is contained in:
parent
7b9099041d
commit
407c8ee6d7
@ -208,6 +208,7 @@ aliases.update({
|
||||
'keyfile': 'NotebookApp.keyfile',
|
||||
'certfile': 'NotebookApp.certfile',
|
||||
'notebook-dir': 'NotebookManager.notebook_dir',
|
||||
'browser': 'NotebookApp.browser',
|
||||
})
|
||||
|
||||
# remove ipkernel flags that are singletons, and don't make sense in
|
||||
@ -285,16 +286,16 @@ class NotebookApp(BaseIPythonApplication):
|
||||
help="""Whether to open in a browser after starting.
|
||||
The specific browser used is platform dependent and
|
||||
determined by the python standard library `webbrowser`
|
||||
module, which allows setting of the BROWSER
|
||||
environment variable to override it. As a one-time
|
||||
change, you can start the notebook using:
|
||||
module, unless it is overridden using the --browser
|
||||
(NotebookApp.browser) configuration option.
|
||||
""")
|
||||
|
||||
BROWSER=firefox ipython notebook
|
||||
|
||||
To make the change more permanent, modify your
|
||||
~/.bashrc you can include a line like the following:
|
||||
|
||||
export BROWSER=firefox
|
||||
browser = Unicode(u'', config=True,
|
||||
help="""Specify which browser to use when opening the
|
||||
notebook. If not specified, the default browser will be
|
||||
determined by the `webbrowser` standard library module,
|
||||
which allows setting of the BROWSER environment variable
|
||||
to override it.
|
||||
""")
|
||||
|
||||
read_only = Bool(False, config=True,
|
||||
@ -440,7 +441,11 @@ class NotebookApp(BaseIPythonApplication):
|
||||
|
||||
if self.open_browser:
|
||||
ip = self.ip or '127.0.0.1'
|
||||
b = lambda : webbrowser.open("%s://%s:%i%s" % (proto, ip, self.port,
|
||||
if len(self.browser) == 0:
|
||||
browser = webbrowser.get()
|
||||
else:
|
||||
browser = webbrowser.get(self.browser)
|
||||
b = lambda : browser.open("%s://%s:%i%s" % (proto, ip, self.port,
|
||||
self.base_project_url),
|
||||
new=2)
|
||||
threading.Thread(target=b).start()
|
||||
|
Loading…
Reference in New Issue
Block a user