Created
September 11, 2017 19:20
-
-
Save liuyigh/94ec5838e8fbe56a063c61a8d9e29be1 to your computer and use it in GitHub Desktop.
iPyNbViewer: Standalone App for IPython Notebook v2 (outdated; use v3 instead)
This file contains hidden or 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
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