From 6bd8783260a3a63d21d6c4604b69544ca6521dec Mon Sep 17 00:00:00 2001 From: Christian Volkmann <15794071+chvolkmann@users.noreply.github.com> Date: Mon, 22 Feb 2021 15:19:19 +0100 Subject: [PATCH 1/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9bb1c2b..be681b8 100644 --- a/README.md +++ b/README.md @@ -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...] From f68f15fd14aa08c93097cdad46725359615e6605 Mon Sep 17 00:00:00 2001 From: Andrew Freckelton <7751633+frecks@users.noreply.github.com> Date: Mon, 4 Apr 2022 14:55:33 -0400 Subject: [PATCH 2/8] Fish shell doesn't use colon termination for `if` This commit removes the python style colon line termination on the if statement. The colon was causing undesired behavior when executing this function in the fish shell. Reference the fish shell docs [example](https://fishshell.com/docs/current/cmds/if.html#example) of an `if` statement for proper syntax. --- functions/code.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/code.fish b/functions/code.fish index 0fd06a5..de3a4f2 100644 --- a/functions/code.fish +++ b/functions/code.fish @@ -4,7 +4,7 @@ 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": + if test -n "$local_code_executable" # code is in the PATH, use that binary instead of the code-connect $local_code_executable $argv else From 1e658c7f50564c6fab22db5ee9c797a98c8bbce5 Mon Sep 17 00:00:00 2001 From: Andrew Freckelton <7751633+frecks@users.noreply.github.com> Date: Mon, 4 Apr 2022 15:13:23 -0400 Subject: [PATCH 3/8] Silence which command's standard error output The GNU which v2.21 command found on CentOS Stream 8 behaves differently than the which command on Debian based systems such as Ubuntu 20.04. The GNU which command prints to stderr when the command is not found. This can cause an error message to be erroneously printed during our test for a locally installed VS Code binary. Redirecting stderr to /dev/null silences this error message so our code produces the same behavior for either version of the which command. --- bash/code.sh | 2 +- functions/code.fish | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 functions/code.fish diff --git a/bash/code.sh b/bash/code.sh index 7581864..f120b82 100755 --- a/bash/code.sh +++ b/bash/code.sh @@ -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 $@ diff --git a/functions/code.fish b/functions/code.fish old mode 100644 new mode 100755 index de3a4f2..aba04ed --- a/functions/code.fish +++ b/functions/code.fish @@ -3,7 +3,7 @@ # 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) + 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 From 3ba498c31191040536028450c249084c8f448677 Mon Sep 17 00:00:00 2001 From: Andrew Freckelton <7751633+frecks@users.noreply.github.com> Date: Mon, 4 Apr 2022 18:45:10 -0400 Subject: [PATCH 4/8] Update code binary location The binary location changed from `~/.vscode-server/bin//bin/code` to `~/.vscode-server/bin//bin/remote-cli/code` in [commit f4ba7dd12b684b144457c6fc6ccc9f4fe71bde3c](https://github.com/microsoft/vscode/commit/f4ba7dd12b684b144457c6fc6ccc9f4fe71bde3c), which was released in [March 2022 (version 1.66)](https://github.com/microsoft/vscode/releases/tag/1.66.0). --- bin/code_connect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/code_connect.py b/bin/code_connect.py index c2b0af3..3e83de9 100755 --- a/bin/code_connect.py +++ b/bin/code_connect.py @@ -77,7 +77,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: From 2149a9bcfa55c4bbec5d13836984a988d0938ebf Mon Sep 17 00:00:00 2001 From: Andrew Freckelton <7751633+frecks@users.noreply.github.com> Date: Mon, 4 Apr 2022 19:13:22 -0400 Subject: [PATCH 5/8] Support Python 3.5 and up The `capture_output` parameter was added to `subprocess.run()` in Python 3.7. Directing stdout & stderr to `subprocess.PIPE` accomplishes the same goal & is supported from Python 3.5. --- bin/code_connect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/code_connect.py b/bin/code_connect.py index 3e83de9..3b0285f 100755 --- a/bin/code_connect.py +++ b/bin/code_connect.py @@ -29,7 +29,7 @@ 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: From 0e8cebcbaeefb347d3ae42fe9909ffa99d1985e1 Mon Sep 17 00:00:00 2001 From: Andrew Freckelton <7751633+frecks@users.noreply.github.com> Date: Mon, 4 Apr 2022 19:42:24 -0400 Subject: [PATCH 6/8] Poetry code style update --- bin/code_connect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/code_connect.py b/bin/code_connect.py index 3b0285f..368691d 100755 --- a/bin/code_connect.py +++ b/bin/code_connect.py @@ -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()}"], - stdout=sp.PIPE, stderr=sp.PIPE, + stdout=sp.PIPE, + stderr=sp.PIPE, ) return proc.returncode == 0 except FileNotFoundError: From a68d07560d408913851c1d567c79c642a3a9afc5 Mon Sep 17 00:00:00 2001 From: Andrew Freckelton <7751633+frecks@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:04:12 -0400 Subject: [PATCH 7/8] Update README Update documentation of supported/tested Python versions. Update documentation of `code` executable location. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index be681b8..882c99a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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//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//bin/remote-cli/code`. A similar method is used to list all of VS Code's IPC sockets, which are located under `/run/user//vscode-ipc-.sock`, where `` is the [current user's UID](https://en.wikipedia.org/wiki/User_identifier) and `` 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. From 8e84ee003bc0de57fbe340a0042cd14b5219b1ec Mon Sep 17 00:00:00 2001 From: Andrew Freckelton <7751633+frecks@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:35:17 -0400 Subject: [PATCH 8/8] Update CHANGELOG and VERSION --- CHANGELOG.md | 13 +++++++++++++ VERSION | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c237a0..0f2c47b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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//bin/code` to +`~/.vscode-server/bin//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 diff --git a/VERSION b/VERSION index 0d91a54..9e11b32 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.0 +0.3.1