Skip to content

Instantly share code, notes, and snippets.

@book000
Created January 7, 2024 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save book000/8c23a1c2948a3a2be9fc20710ff004a2 to your computer and use it in GitHub Desktop.
Save book000/8c23a1c2948a3a2be9fc20710ff004a2 to your computer and use it in GitHub Desktop.
#!/bin/bash
function devopen() {
local workspace_folder="$(readlink -f "$1")"
if [ -d "$workspace_folder" ]; then
local wsl_path="$(wslpath -w "$workspace_folder")"
local path_id=$(printf "%s" "$wsl_path" | xxd -ps -c 256)
code --folder-uri "vscode-remote://dev-container%2B${path_id}/workspaces/$(basename "$workspace_folder")"
else
echo "Usage: devopen <directory>" 1>&2
echo "" 1>&2
echo "Error: Directory ${1@Q} does not exist" 1>&2
false
fi
}
devopen $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment