Skip to content

Instantly share code, notes, and snippets.

@dnyall
Last active December 19, 2024 19:28
Show Gist options
  • Select an option

  • Save dnyall/b33f9ab28a10b670d17cf6f1ac991d1b to your computer and use it in GitHub Desktop.

Select an option

Save dnyall/b33f9ab28a10b670d17cf6f1ac991d1b to your computer and use it in GitHub Desktop.
osx "automator application" script to add "Open in jupyterNotebook" action in finder
# 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