Skip to content

Instantly share code, notes, and snippets.

@liuyigh
Created September 11, 2017 19:20
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 liuyigh/94ec5838e8fbe56a063c61a8d9e29be1 to your computer and use it in GitHub Desktop.
Save liuyigh/94ec5838e8fbe56a063c61a8d9e29be1 to your computer and use it in GitHub Desktop.
iPyNbViewer: Standalone App for IPython Notebook v2 (outdated; use v3 instead)
on open this_item
tell application "iTerm"
activate
set iPyNbViewer to (make new terminal)
tell iPyNbViewer
activate current session
launch session "Default Session"
tell the last session
set name to "IPython Notebook"
write text "ipython notebook " & (quoted form of POSIX path of this_item)
end tell
end tell
end tell
end open
on run
set choice to display dialog ("Shall we select a file or folder?") ¬
buttons {"Cancel", "File", "Folder"} with icon note ¬
cancel button 1 default button 2
if button returned of choice is "File" then
set ipynb to choose file
tell application "iTerm"
activate
set iPyNbViewer to (make new terminal)
tell iPyNbViewer
activate current session
launch session "Default Session"
tell the last session
set name to "IPython Notebook"
write text "ipython notebook " & (quoted form of POSIX path of ipynb)
end tell
end tell
end tell
else
set ipynbf to choose folder
tell application "iTerm"
activate
set iPyNbViewer to (make new terminal)
tell iPyNbViewer
activate current session
launch session "Default Session"
tell the last session
set name to "IPython Notebook"
write text "cd " & (quoted form of POSIX path of ipynbf)
write text "ipython notebook"
end tell
end tell
end tell
end if
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment