Add subcommand to `gp` CLI for detecting if the command was run from Web-VSCode or Desktop-VSCode or other
Is your feature request related to a problem? Please describe
Such a shorthand subcommand would be useful for a use case such as:
- On web, your webserver root address is something
- But on desktop it may/could be different.
So you could run something like
gp which ideinside a script and decide upon the result to modify your environment.
Describe the behaviour you'd like
gp which ide tells you the IDE name.
Describe alternatives you've considered
if {
pgrep -f 'sshd: gitpod@notty' \
|| pgrep -f "$HOME/.vscode-server/bin" \
|| test -e "$HOME/.ssh/authorized_keys";
} 1>/dev/null; then {
printf '%s\n' "Gitpod on desktop";
: "http://localhost:3000";
} else {
printf '%s\n' "Gitpod on da web";
: "$(gp url 3000)";
} fi
export HMR_HOST="$_"
Additional context
Please see these discord threads:
- https://discord.com/channels/816244985187008514/1003809353213673542
- https://discord.com/channels/816244985187008514/959977556692574248
I don't really understand the intent. Could you put what you want to solve not how?
I am not sure gp ide is great idea, we are allowing multiple IDEs running in the same workspace, you can start from web and desktop then or start from desktop and go back to web without restart in both cases.
The intent is to find out if a dev server is reachable using the localhost address (when using the desktop IDE, e.g. http://localhost:3000) or a Gitpod address (when using the browser IDE, e.g. https://for-bar-n2oi8b9a6wr.ws-eu60.gitpod.io/), because sometimes it's relevant for some developer tools.
Hey @akosyakov 👋
I don't really understand the intent. Could you put what you want to solve not how?
As @medihack as described above, we want to know which IDE/ssh server backends are running for use in scripts.
I am not sure gp ide is great idea, we are allowing multiple IDEs running in the same workspace, you can start from web and desktop then or start from desktop and go back to web without restart in both cases.
Great point 🙏
Now after thinking again, I guess instead of trying to detect the specific active backend, it could instead list names for all the running backends. So, one could do something like gp <special-command> | grep -q <ide-backend-name>.
Here's another use case:
- Imagine you used the
sshcommand to connect to a workspace. - Later, you also attached to an task terminal:
gp tasks attach <id>- But since the terminal was created earlier by
supervisor, so it doesn't have theSSH_CONNECTIONvariable in it's environment, otherwise we could use that to detect in a script.
- But since the terminal was created earlier by
I think you are asking for https://github.com/gitpod-io/gitpod/issues/11849, i.e. you should run gp url <port> and it evaluates it in the context of last focused client and if a client can tunnel then gives you localhost:<port> otherwise exposed URL on internet.
duplicate of https://github.com/gitpod-io/gitpod/issues/11849