Support xdg-open / open with browser for SSH terminals #18817

Closed
opened 2026-01-31 06:25:16 +00:00 by claunia · 13 comments
Owner

Originally created by @misterjoshua on GitHub (Nov 3, 2022).

Description of the new feature/enhancement

I want Windows Terminal to support opening a browser over SSH as VS Code does. This is useful for tools that want the user to open a browser to a given website, such as for authorizing a device or authenticating via SSO.

For instance, we use Granted to access our cloud accounts. Granted comes with a tool called assume that helps get access credentials. After running assume, the tool takes me to a device authorization endpoint and my company's SSO where I can authorize the session via my desktop browser. After authorizing by browser, the tool completes the device authorization process and I am logged into the cloud with short-lived credentials.

Example

In Windows Terminal, I get the error output shown and I need to ctrl-click to open the URL:

image

But in VS Code, the browser opens on my desktop right away, saving me some time:

image

The tool above uses FreeDesktop's well-known xdg-open tool. When I run xdg-open manually, I get substantially similar error messages:

image

But the tool works fine in VS Code:

image

Proposed technical implementation details (optional)

I'm not sure how this would be implemented in Windows Terminal, but I suspect that you could look at how VS Code is doing it for some hints on how this could work.

Originally created by @misterjoshua on GitHub (Nov 3, 2022). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement I want Windows Terminal to support opening a browser over SSH as VS Code does. This is useful for tools that want the user to open a browser to a given website, such as for authorizing a device or authenticating via SSO. For instance, we use [Granted](https://granted.dev/) to access our cloud accounts. Granted comes with a tool called `assume` that helps get access credentials. After running `assume`, the tool takes me to a device authorization endpoint and my company's SSO where I can authorize the session via my desktop browser. After authorizing by browser, the tool completes the device authorization process and I am logged into the cloud with short-lived credentials. **Example** In Windows Terminal, I get the error output shown and I need to ctrl-click to open the URL: ![image](https://user-images.githubusercontent.com/644092/199789860-4b71e1c3-543e-42ca-8b4f-291711401a83.png) But in VS Code, the browser opens on my desktop right away, saving me some time: ![image](https://user-images.githubusercontent.com/644092/199790071-2ad10925-b03f-4c4c-b8f8-dbd21e67614c.png) The tool above uses FreeDesktop's well-known `xdg-open` tool. When I run xdg-open manually, I get substantially similar error messages: ![image](https://user-images.githubusercontent.com/644092/199790400-95c06561-13d1-42ca-ba06-39a3f88aab05.png) But the tool works fine in VS Code: ![image](https://user-images.githubusercontent.com/644092/199790490-7822ed73-2aeb-4ecd-9368-b9999c9f4ec4.png) <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) I'm not sure how this would be implemented in Windows Terminal, but I suspect that you could look at how VS Code is doing it for some hints on how this could work. <!-- A clear and concise description of what you want to happen. -->
claunia added the Issue-FeatureNeeds-Tag-FixProduct-TerminalArea-Extensibility labels 2026-01-31 06:25:17 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 3, 2022):

@Tyriar / @benhillis / @craigloewen-msft - any idea why this would be different between Terminal and VsCode? I'd guess that it has something to do with to do with env vars not being configured the same between both. I'm not totally sure how WSLg sets up the environment though, so I don't know why launching this from the Terminal vs from VsCode would be different.

@zadjii-msft commented on GitHub (Nov 3, 2022): @Tyriar / @benhillis / @craigloewen-msft - any idea why this would be different between Terminal and VsCode? I'd guess that it has something to do with to do with env vars not being configured the same between both. I'm not totally sure how WSLg sets up the environment though, so I don't know why launching this from the Terminal vs from VsCode would be different.
Author
Owner

@zadjii-msft commented on GitHub (Nov 3, 2022):

Maybe it's using different ssh's?

@zadjii-msft commented on GitHub (Nov 3, 2022): Maybe it's using different ssh's?
Author
Owner

@misterjoshua commented on GitHub (Nov 3, 2022):

For reference, here are the environment variables for each of the setups:

Windows Terminal

josh@nyx:~$ env | sort
ARGOCD_OPTS=--port-forward --port-forward-namespace argocd
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DEPOT_INSTALL_DIR=/home/josh/.depot/bin
EDITOR=vim
GOPATH=/home/josh/go
HOME=/home/josh
LANG=en_CA.UTF-8
LANGUAGE=en_CA:en
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSOPEN=| /usr/bin/lesspipe %s
LOGNAME=josh
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MOTD_SHOWN=pam
NVM_BIN=/home/josh/.nvm/versions/node/v16.17.0/bin
NVM_CD_FLAGS=
NVM_DIR=/home/josh/.nvm
NVM_INC=/home/josh/.nvm/versions/node/v16.17.0/include/node
PATH=/home/josh/.local/bin:/home/josh/.krew/bin:/home/josh/.depot/bin:/home/josh/.cargo/bin:/home/josh/.nvm/versions/node/v16.17.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/josh/go/bin:/home/josh/.local/bin:/home/josh/.config/composer/vendor/bin:/home/josh/go/bin:/home/josh/.local/bin
PWD=/home/josh
SHELL=/bin/bash
SHLVL=0
SSH_AUTH_SOCK=/tmp/ssh-XXXXlhkcZB/agent.1955089
SSH_CLIENT=192.168.1.126 58838 22
SSH_CONNECTION=192.168.1.126 58838 192.168.1.120 22
SSH_TTY=/dev/pts/0
TERM=xterm-256color
USER=josh
_=/usr/bin/env
VISUAL=vim
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_CLASS=user
XDG_SESSION_ID=930

VS Code

josh@nyx:~$ env | sort
ARGOCD_OPTS=--port-forward --port-forward-namespace argocd
BROWSER=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/bin/helpers/browser.sh
COLORTERM=truecolor
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DEPOT_INSTALL_DIR=/home/josh/.depot/bin
EDITOR=vim
GIT_ASKPASS=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/extensions/git/dist/askpass.sh
GOPATH=/home/josh/go
HOME=/home/josh
LANG=en_CA.UTF-8
LANGUAGE=en_CA:en
LESSCLOSE=/usr/bin/lesspipe %s %s
LESSOPEN=| /usr/bin/lesspipe %s
LOGNAME=josh
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MOTD_SHOWN=pam
NVM_BIN=/home/josh/.nvm/versions/node/v16.17.0/bin
NVM_CD_FLAGS=
NVM_DIR=/home/josh/.nvm
NVM_INC=/home/josh/.nvm/versions/node/v16.17.0/include/node
OLDPWD=/home/josh/proj/mullen/cdk8s
PATH=/home/josh/.krew/bin:/home/josh/.depot/bin:/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/bin/remote-cli:/home/josh/.local/bin:/home/josh/.krew/bin:/home/josh/.depot/bin:/home/josh/.cargo/bin:/home/josh/.nvm/versions/node/v16.17.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/josh/go/bin:/home/josh/.local/bin:/home/josh/.config/composer/vendor/bin:/home/josh/go/bin:/home/josh/.local/bin:/usr/local/go/bin:/home/josh/go/bin:/home/josh/.local/bin:/home/josh/.config/composer/vendor/bin:/home/josh/go/bin:/home/josh/.local/bin
PWD=/home/josh
SHELL=/bin/bash
SHLVL=0
SSH_AUTH_SOCK=/run/user/1000/vscode-ssh-auth-sock-112895175
SSH_CLIENT=192.168.1.126 58313 22
SSH_CONNECTION=192.168.1.126 58313 192.168.1.120 22
TERM_PROGRAM_VERSION=1.72.2
TERM_PROGRAM=vscode
TERM=xterm-256color
USER=josh
_=/usr/bin/env
VISUAL=vim
VSCODE_GIT_ASKPASS_EXTRA_ARGS=
VSCODE_GIT_ASKPASS_MAIN=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/extensions/git/dist/askpass-main.js
VSCODE_GIT_ASKPASS_NODE=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/node
VSCODE_GIT_IPC_HANDLE=/run/user/1000/vscode-git-dd89c4144a.sock
VSCODE_IPC_HOOK_CLI=/run/user/1000/vscode-ipc-53da19f2-2a2a-4d3c-94b1-c93ba163dca8.sock
XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_CLASS=user
XDG_SESSION_ID=926
XDG_SESSION_TYPE=tty
@misterjoshua commented on GitHub (Nov 3, 2022): For reference, here are the environment variables for each of the setups: **Windows Terminal** ``` josh@nyx:~$ env | sort ARGOCD_OPTS=--port-forward --port-forward-namespace argocd DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DEPOT_INSTALL_DIR=/home/josh/.depot/bin EDITOR=vim GOPATH=/home/josh/go HOME=/home/josh LANG=en_CA.UTF-8 LANGUAGE=en_CA:en LESSCLOSE=/usr/bin/lesspipe %s %s LESSOPEN=| /usr/bin/lesspipe %s LOGNAME=josh LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36: MOTD_SHOWN=pam NVM_BIN=/home/josh/.nvm/versions/node/v16.17.0/bin NVM_CD_FLAGS= NVM_DIR=/home/josh/.nvm NVM_INC=/home/josh/.nvm/versions/node/v16.17.0/include/node PATH=/home/josh/.local/bin:/home/josh/.krew/bin:/home/josh/.depot/bin:/home/josh/.cargo/bin:/home/josh/.nvm/versions/node/v16.17.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/josh/go/bin:/home/josh/.local/bin:/home/josh/.config/composer/vendor/bin:/home/josh/go/bin:/home/josh/.local/bin PWD=/home/josh SHELL=/bin/bash SHLVL=0 SSH_AUTH_SOCK=/tmp/ssh-XXXXlhkcZB/agent.1955089 SSH_CLIENT=192.168.1.126 58838 22 SSH_CONNECTION=192.168.1.126 58838 192.168.1.120 22 SSH_TTY=/dev/pts/0 TERM=xterm-256color USER=josh _=/usr/bin/env VISUAL=vim XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop XDG_RUNTIME_DIR=/run/user/1000 XDG_SESSION_CLASS=user XDG_SESSION_ID=930 ``` **VS Code** ``` josh@nyx:~$ env | sort ARGOCD_OPTS=--port-forward --port-forward-namespace argocd BROWSER=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/bin/helpers/browser.sh COLORTERM=truecolor DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DEPOT_INSTALL_DIR=/home/josh/.depot/bin EDITOR=vim GIT_ASKPASS=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/extensions/git/dist/askpass.sh GOPATH=/home/josh/go HOME=/home/josh LANG=en_CA.UTF-8 LANGUAGE=en_CA:en LESSCLOSE=/usr/bin/lesspipe %s %s LESSOPEN=| /usr/bin/lesspipe %s LOGNAME=josh LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36: MOTD_SHOWN=pam NVM_BIN=/home/josh/.nvm/versions/node/v16.17.0/bin NVM_CD_FLAGS= NVM_DIR=/home/josh/.nvm NVM_INC=/home/josh/.nvm/versions/node/v16.17.0/include/node OLDPWD=/home/josh/proj/mullen/cdk8s PATH=/home/josh/.krew/bin:/home/josh/.depot/bin:/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/bin/remote-cli:/home/josh/.local/bin:/home/josh/.krew/bin:/home/josh/.depot/bin:/home/josh/.cargo/bin:/home/josh/.nvm/versions/node/v16.17.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/josh/go/bin:/home/josh/.local/bin:/home/josh/.config/composer/vendor/bin:/home/josh/go/bin:/home/josh/.local/bin:/usr/local/go/bin:/home/josh/go/bin:/home/josh/.local/bin:/home/josh/.config/composer/vendor/bin:/home/josh/go/bin:/home/josh/.local/bin PWD=/home/josh SHELL=/bin/bash SHLVL=0 SSH_AUTH_SOCK=/run/user/1000/vscode-ssh-auth-sock-112895175 SSH_CLIENT=192.168.1.126 58313 22 SSH_CONNECTION=192.168.1.126 58313 192.168.1.120 22 TERM_PROGRAM_VERSION=1.72.2 TERM_PROGRAM=vscode TERM=xterm-256color USER=josh _=/usr/bin/env VISUAL=vim VSCODE_GIT_ASKPASS_EXTRA_ARGS= VSCODE_GIT_ASKPASS_MAIN=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/extensions/git/dist/askpass-main.js VSCODE_GIT_ASKPASS_NODE=/home/josh/.vscode-server/bin/d045a5eda657f4d7b676dedbfa7aab8207f8a075/node VSCODE_GIT_IPC_HANDLE=/run/user/1000/vscode-git-dd89c4144a.sock VSCODE_IPC_HOOK_CLI=/run/user/1000/vscode-ipc-53da19f2-2a2a-4d3c-94b1-c93ba163dca8.sock XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share:/usr/share:/var/lib/snapd/desktop XDG_RUNTIME_DIR=/run/user/1000 XDG_SESSION_CLASS=user XDG_SESSION_ID=926 XDG_SESSION_TYPE=tty ```
Author
Owner

@misterjoshua commented on GitHub (Nov 3, 2022):

I noticed a $BROWSER env var in the VS Code terminal pointing to a script file. I'd share the contents of the file but it looks like the vscode team are distributing this file with a restricted license.

@misterjoshua commented on GitHub (Nov 3, 2022): I noticed a `$BROWSER` env var in the VS Code terminal pointing to a script file. I'd share the contents of the file but it looks like the vscode team are distributing this file with a restricted license.
Author
Owner

@ebarzilay-godaddy commented on GitHub (Nov 3, 2022):

xdg-open defaults to using $BROWSER, which as you noted is set to a vscode script, which you're using remotely. Your local vscode talks to the remote server, which will send it a command to open the url (Probably this thing).

There's no way that any of that will work in terminal, unless it implements some built-in ssh functionality, with a pipe to the target, and implement more bits to run stuff locally like vscode does. IOW, open some local folder in vscode, start a shell, ssh to some place, and xdg-open should fail in the same way you see above.

@ebarzilay-godaddy commented on GitHub (Nov 3, 2022): `xdg-open` defaults to using `$BROWSER`, which as you noted is set to a vscode script, which you're using remotely. Your local vscode talks to the remote server, which will send it a command to open the url (Probably [this thing](https://github.com/microsoft/vscode/blob/main/src/vs/server/node/server.cli.ts#L354-L357)). There's no way that any of that will work in terminal, unless it implements some built-in ssh functionality, with a pipe to the target, and implement more bits to run stuff locally like vscode does. IOW, open some local folder in vscode, start a shell, ssh to some place, and `xdg-open` should fail in the same way you see above.
Author
Owner

@misterjoshua commented on GitHub (Nov 3, 2022):

I see that could be problematic, as Windows Terminal doesn't install anything on the remote host, unlike VS Code. Can users plug into an extension system to add this functionality for themselves?

@misterjoshua commented on GitHub (Nov 3, 2022): I see that could be problematic, as Windows Terminal doesn't install anything on the remote host, unlike VS Code. Can users plug into an extension system to add this functionality for themselves?
Author
Owner

@ebarzilay-godaddy commented on GitHub (Nov 3, 2022):

You could use a linux browser, with an X server tunneled through ssh, but that will probably not be convenient.

Or you could implement a tiny "server" on windows that just listens on some port (read input and run a browser on each line), then forward it via ssh -R 12345:localhost:12345, then add a tiny script that uses netcat to write a url out to the forwarded port.

... Or you can just use vscode :) (Maybe with some extension that makes it start with a full-screen terminal...)

@ebarzilay-godaddy commented on GitHub (Nov 3, 2022): You could use a linux browser, with an X server tunneled through ssh, but that will probably not be convenient. Or you could implement a tiny "server" on windows that just listens on some port (read input and run a browser on each line), then forward it via `ssh -R 12345:localhost:12345`, then add a tiny script that uses `netcat` to write a url out to the forwarded port. ... Or you can just use vscode :) (Maybe with some extension that makes it start with a full-screen terminal...)
Author
Owner

@misterjoshua commented on GitHub (Nov 3, 2022):

Great suggestion! That's very doable. Thank you.

@misterjoshua commented on GitHub (Nov 3, 2022): Great suggestion! That's very doable. Thank you.
Author
Owner

@misterjoshua commented on GitHub (Nov 4, 2022):

Though at some point I'd still like to see built-in ssh support for xdg-open in Windows Terminal, for now, I've created a tool which takes the ssh tunnelling approach and I'm using a Windows Terminal command line that looks something like this:

ssh server -AtR 12345:127.0.0.1:12345 BROWSER=tunnel-tool bash
@misterjoshua commented on GitHub (Nov 4, 2022): Though at some point I'd still like to see built-in ssh support for `xdg-open` in Windows Terminal, for now, I've created a tool which takes the ssh tunnelling approach and I'm using a Windows Terminal command line that looks something like this: ``` ssh server -AtR 12345:127.0.0.1:12345 BROWSER=tunnel-tool bash ```
Author
Owner

@ebarzilay-godaddy commented on GitHub (Nov 8, 2022):

FWIW, that would be a pretty big extension to the scope, since strictly speaking this is not really related to the functionality of a terminal. It would be similar in spirit to adding a feature for browsing remote files, or opening a local editor for a remote file (and you can see how this is quickly reaching a point where it's questionable to implement a bunch of stuff that vscode is doing...).

@ebarzilay-godaddy commented on GitHub (Nov 8, 2022): FWIW, that would be a pretty big extension to the scope, since strictly speaking this is not really related to the functionality of a terminal. It would be similar in spirit to adding a feature for browsing remote files, or opening a local editor for a remote file (and you can see how this is quickly reaching a point where it's questionable to implement a bunch of stuff that vscode is doing...).
Author
Owner

@jack775544 commented on GitHub (Nov 13, 2022):

You can already do this with just the stock functionality of WSL. Since WSL by default will add files from your Windows path you can make a desktop file entry in your WSL instance that points to your windows browser.

Personally I use Firefox for my browsing so I grabbed the firefox desktop file and saved it to ~/.local/share/applications/firefox.desktop. One thing you will have to change in this file will be updating the executable names to firefox.exe. This is since the windows interop on WSL needs file extensions to work.

Then afterwards I ran xdg-mime default firefox.desktop x-scheme-handler/http and xdg-mime default firefox.desktop x-scheme-handler/https. Now if I try doing xdg-open https://google.com from the terminal, it will open my Windows firefox browser.

Should be a very similar process if you are using any other browser as well.

EDIT: Realised this was talking about SSH and not WSL.

@jack775544 commented on GitHub (Nov 13, 2022): You can already do this with just the stock functionality of WSL. Since WSL by default will add files from your Windows path you can make a desktop file entry in your WSL instance that points to your windows browser. Personally I use Firefox for my browsing so I grabbed the [firefox desktop file](https://hg.mozilla.org/mozilla-central/file/tip/browser/components/shell/search-provider-files/firefox.desktop) and saved it to `~/.local/share/applications/firefox.desktop`. One thing you will have to change in this file will be updating the executable names to `firefox.exe`. This is since the windows interop on WSL needs file extensions to work. Then afterwards I ran `xdg-mime default firefox.desktop x-scheme-handler/http` and `xdg-mime default firefox.desktop x-scheme-handler/https`. Now if I try doing `xdg-open https://google.com` from the terminal, it will open my Windows firefox browser. Should be a very similar process if you are using any other browser as well. EDIT: Realised this was talking about SSH and not WSL.
Author
Owner

@Tyriar commented on GitHub (Nov 30, 2022):

A lot of effort went into the remoting support in VS Code, I see this is in the Icebox milestone but this seems like it would be out of scope for WT?

@zadjii-msft I'd recommend just closing this as not to give a false sense of hope, unless you would accept a change that downloads script files on ssh remotes (people will complain this is unexpected and a security/privacy problem) and allowing it to communicate back with the frontend somehow (probably also security complaints).

@Tyriar commented on GitHub (Nov 30, 2022): A lot of effort went into the remoting support in VS Code, I see this is in the Icebox milestone but this seems like it would be out of scope for WT? @zadjii-msft I'd recommend just closing this as not to give a false sense of hope, unless you would accept a change that downloads script files on ssh remotes (people will complain this is unexpected and a security/privacy problem) and allowing it to communicate back with the frontend somehow (probably also security complaints).
Author
Owner

@misterjoshua commented on GitHub (Dec 1, 2022):

Thanks all for clarifying WT's scope. I'll close this issue.

@misterjoshua commented on GitHub (Dec 1, 2022): Thanks all for clarifying WT's scope. I'll close this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18817