Last active
December 19, 2024 19:28
-
-
Save dnyall/b33f9ab28a10b670d17cf6f1ac991d1b to your computer and use it in GitHub Desktop.
osx "automator application" script to add "Open in jupyterNotebook" action in finder
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
| # Steps to Create a Quick Action in Automator for Opening a Folder in Jupyter Notebook: | |
| # 1. In Automator, create a Quick Action. | |
| # 2. Set the workflow to receive current files or folders in any application. | |
| # 3. Add a Run Shell Script action. | |
| # 4. Set “Pass input” as “arguments”. | |
| # 5. Paste the following bash script into the shell script section. | |
| # Now, you can easily open the selected folder in Jupyter Notebook from finder actions. Enjoy! | |
| #!/bin/zsh | |
| # Get the file/folder path (passed as input) | |
| input_path="$1" | |
| # Debug: Print the input path passed from Automator | |
| echo "Received input path: '$input_path'" | |
| # Check if the input is a directory (in case it's a folder) | |
| if [ -d "$input_path" ]; then | |
| # Change to the folder and start Jupyter Notebook | |
| cd "$input_path" && /opt/anaconda3/bin/jupyter notebook | |
| else | |
| # If the path is a file, extract the directory path | |
| input_folder=$(dirname "$input_path") | |
| echo "Extracted folder: '$input_folder'" | |
| # Start Jupyter Notebook in the extracted folder | |
| cd "$input_folder" && /opt/anaconda3/bin/jupyter notebook | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment