Created
February 16, 2021 19:49
-
-
Save ianloic/ddd8105da589d10760638af6f5306ae7 to your computer and use it in GitHub Desktop.
Zsh function to invoke vscode remote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code () { | |
local script=$(echo ~/.vscode-server/bin/*/bin/code(*ocNY1)) | |
if [[ -z ${script} ]] | |
then | |
echo "VSCode remote script not found" | |
exit 1 | |
fi | |
local socket=$(echo /run/user/$UID/vscode-ipc-*.sock(=ocNY1)) | |
if [[ -z ${socket} ]] | |
then | |
echo "VSCode IPC socket not found" | |
exit 1 | |
fi | |
export VSCODE_IPC_HOOK_CLI=${socket} | |
${script} $* | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instead of using an echo with a glob you could try using
ls
andhead
. Something like:I haven't tested it but that should list list all of the matching files in time order with the most recent at the top, suppress any errors (for example if the glob fails) and then take just the first. It won't do the other things that the zsh glob is doing like checking that the file is executable, but that is just a nice sanity check. Bash doesn't seem to do anything clever with filename expansion, sadly: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html