Last active
July 28, 2026 10:11
-
-
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)
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
| 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
commented
Jul 28, 2026
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment