Skip to content

Instantly share code, notes, and snippets.

@workeffortwaste
Last active July 28, 2026 10:11
Show Gist options
  • Select an option

  • Save workeffortwaste/be741b0468235031301d213e6472d30b to your computer and use it in GitHub Desktop.

Select an option

Save workeffortwaste/be741b0468235031301d213e6472d30b to your computer and use it in GitHub Desktop.
Finder (MacOS) 'Open in VS Code' automation (with SSH remote support for Orbstack folders)
CODE="/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"
ORB_ROOT="$HOME/OrbStack"
for item in "$@"; do
# Remove a trailing slash
item="${item%/}"
if [[ "$item" == "$ORB_ROOT/"* ]]; then
relative="${item#"$ORB_ROOT/"}"
machine="${relative%%/*}"
# "docker" contains Docker volumes/containers rather than an SSH machine
if [[ "$machine" != "docker" ]]; then
if [[ "$relative" == "$machine" ]]; then
remote_path="/"
else
remote_path="/${relative#*/}"
fi
# Make sure VS Code treats directories containing dots as folders
if [[ -d "$item" ]]; then
remote_path="${remote_path%/}/"
fi
"$CODE" \
--new-window \
--remote "ssh-remote+${machine}@orb" \
"$remote_path"
continue
fi
fi
# Normal macOS folder
"$CODE" --new-window "$item"
done
@workeffortwaste

Copy link
Copy Markdown
Author
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment