Skip to content

Commit

Permalink
Read workspace folder from devcontainer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Feb 15, 2023
1 parent f0c46e0 commit 221fd17
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions home/dot_local/bin/executable_code
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ fi
for arg; do
shift
if [ "${arg}" = "--devcontainer" ]; then
echo "dropping --devcontainer flag" >&2

if workspace_folder=$(is_first_arg_a_folder "$@"); then
workspace_folder="$(realpath "${workspace_folder}")"
else
Expand All @@ -63,13 +61,18 @@ for arg; do
fi

if [ -d "${workspace_folder}" ]; then
basename_workspace_folder="$(basename "${workspace_folder}")"
workspace_folder_in_devcontainer=$(
# https://github.com/microsoft/vscode-remote-release/issues/2133#issuecomment-1430651840
devcontainer read-configuration --workspace-folder "${workspace_folder}" 2>/dev/null |
jq --exit-status --raw-output .workspace.workspaceFolder
)

if [ -n "${WSL_DISTRO_NAME}" ]; then
workspace_folder=$(wslpath -w "${workspace_folder}")
fi
path_id=$(printf "%s" "${workspace_folder}" | xxd -ps -c 256)

set -- --folder-uri "vscode-remote://dev-container%2B${path_id}/workspaces/${basename_workspace_folder}"
set -- --folder-uri "vscode-remote://dev-container%2B${path_id}${workspace_folder_in_devcontainer}"
break
fi
fi
Expand Down

5 comments on commit 221fd17

@CodeMan99
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas on what would be the URI for opening the devcontainer from within a SSH target?

You seem to be looking for microsoft/vscode-remote-release#190 (comment)

@felipecrs
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's for opening an SSH target, but not the devcontainer itself.

@CodeMan99
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe combine the last example with a devcontainer URI?

code --remote=ssh-remote+<hostname> --folder-uri <devcontainer-uri>

No idea if that'd work.

@felipecrs
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. It's worth trying! Will try!

@felipecrs
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it does not work. It tries to look for the docker binary in my host machine rather than in the SSH machine as it should.

But anyway, thank you!

Please sign in to comment.