Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Volkmann committed Jun 26, 2022
2 parents 7158716 + b232e05 commit 0a76bc3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Maybe your next idea?

## [0.3.1] - 2022-04-04

### Changed

- Updated to reflect the VS Code binary location change from `~/.vscode-server/bin/<commit-id>/bin/code` to
`~/.vscode-server/bin/<commit-id>/bin/remote-cli/code` in [commit
f4ba7dd12b684b144457c6fc6ccc9f4fe71bde3c](microsoft/vscode@f4ba7dd),
which was released in [March 2022 (version
1.66)](https://github.com/microsoft/vscode/releases/tag/1.66.0).
- Updated to support Python 3.5 and up.
- Silence the `which` command's stderr stream, because the GNU `which` v2.21 command found on CentOS Stream 8 produces unnecessary error messages when we test for a locally installed VS Code binary.
- Fixed a small formatting bug with an `if` statement in code.fish.

## [0.3.0] - 2021-02-18

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The aim of this project is to make the `code` cli available to _any_ terminal, n
> Macs could also support everything out of the box, confirmation needed. Please don't hesitate to come into contact if you have any information to share.
- **Python 3**
> Tested under Python 3.8, but slightly older versions should work fine
> Tested under Python 3.6 and Python 3.8, but should work fine in Python 3.5 or newer.
- **socat** - used for pinging UNIX sockets
```bash
apt-get install socat
Expand Down Expand Up @@ -85,7 +85,7 @@ Deletes the aliases from `~/.bashrc` and removes the folder `~/.code-connect`

Use `code` as you would normally!

If you have VS Code installed on your remote machine as well (i.e. a `code` executable already exists), you can use `code` for your local instance and `code-connect` for a IPC connected instance.
If you have VS Code installed on your remote machine as well (i.e. a `code` executable already exists), you can use `code` for your local instance and `code-connect` for an IPC connected instance.

```
Usage: code [options][paths...]
Expand Down Expand Up @@ -118,7 +118,7 @@ VS Code uses datagram sockets to communicate between a terminal and the renderin

The integrated terminal as well as the WSL terminal spawn an IPC socket. You also create one when connecting through a remote SSH session. These sockets can be found in the folders of VS Code Server.

Each time you connect remotely, the VS Code client instructs the server to fetch the newest version of itself. All versions are stored by commit id in `~/.vscode-server/bin`. `code-connect` uses the version that has been most recently accessed. The corresponding `code` executable can be found in `~/.vscode-server/bin/<commid-id>/bin/code`.
Each time you connect remotely, the VS Code client instructs the server to fetch the newest version of itself. All versions are stored by commit id in `~/.vscode-server/bin`. `code-connect` uses the version that has been most recently accessed. The corresponding `code` executable can be found in `~/.vscode-server/bin/<commit-id>/bin/remote-cli/code`.

A similar method is used to list all of VS Code's IPC sockets, which are located under `/run/user/<userid>/vscode-ipc-<UUID>.sock`, where `<userid>` is the [current user's UID](https://en.wikipedia.org/wiki/User_identifier) and `<UUID>` is a unique ID. VS Code does not seem to clean up all stale connections, so some of these sockets are active, some are not.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.3.1
2 changes: 1 addition & 1 deletion bash/code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Use this script through an alias
# alias code="/path/to/code.sh"

local_code_executable="$(which code)"
local_code_executable="$(which code 2>/dev/null)"
if test -n "$local_code_executable"; then
# code is in the PATH, use that binary instead of the code-connect
$local_code_executable $@
Expand Down
5 changes: 3 additions & 2 deletions bin/code_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def is_socket_open(path: Path) -> bool:
# https://unix.stackexchange.com/a/556790/106406
proc = sp.run(
["socat", "-u", "OPEN:/dev/null", f"UNIX-CONNECT:{path.resolve()}"],
capture_output=True,
stdout=sp.PIPE,
stderr=sp.PIPE,
)
return proc.returncode == 0
except FileNotFoundError:
Expand Down Expand Up @@ -77,7 +78,7 @@ def get_code_binary() -> Path:
)

_, code_repo = code_repos[0]
return code_repo / "bin" / "code"
return code_repo / "bin" / "remote-cli" / "code"


def get_ipc_socket(max_idle_time: int = DEFAULT_MAX_IDLE_TIME) -> Path:
Expand Down
4 changes: 2 additions & 2 deletions functions/code.fish
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# https://github.com/chvolkmann/code-connect

function code --description 'Run local code exectuable if installed, run code-connect otherwise'
set -l local_code_executable (which code)
if test -n "$local_code_executable":
set -l local_code_executable (which code 2>/dev/null)
if test -n "$local_code_executable"
# code is in the PATH, use that binary instead of the code-connect
$local_code_executable $argv
else
Expand Down

0 comments on commit 0a76bc3

Please sign in to comment.