gh cs list: add a way to extract the currently bound SSH port
- Dominant language
- Go
- Stars
- 46.3k
- Forks
- 9k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 89
Description
### Describe the feature or problem you’d like to solve
I want to set up my Codespace using Ansible. (The default dotfiles setup does not meet my needs.) However, Ansible is designed to take a hostname and port, so I cannot use `gh cs ssh`. (`gh cs ssh` also prints unwanted status messages to stderr, which would interfere with my playbook even if I could use it.)
Right now, I have to mount it with `gh cs ssh`, find the bound port with `sudo netstat -tapn`, and then use that port with my Ansible playbook.
### Proposed solution
It's easy enough to mount the port with `gh cs ssh -c CODESPACE-NAME -- -N 2>/dev/null &`, but I still need to find the port. If `gh cs list` had some way to list the currently bound port so I can retrieve it later with just the codespace name (e.g., with `--json`), then I could extract it and script the entire setup process whenever I create a new codespace.
I realize that I could specify a specific port, but that isn't quite sufficient, since I'd still like to use `gh cs list` to extract the data in, for example, some Vimscript, and it's a lot less convenient to have to preserve the port and reuse it elsewhere than to just look it up in the Vimscript.
### Additional context
If you're happy with the design, I'm happy to implement it.
Contributor guide
Assessment
This issue has not been assessed yet.