Created
March 8, 2024 20:01
-
-
Save sozercan/7c904ef862c8305057486666850986c8 to your computer and use it in GitHub Desktop.
This file contains 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
#! /usr/bin/env bash | |
script="$(find ~/.vscode-server-insiders/bin -iname code-insiders | tail -n 1)" | |
if [ -z "${script}" ]; then | |
echo "VSCode remote script not found" | |
exit 1 | |
fi | |
sockets="$(find /run/user/${UID}/ -iname vscode-ipc-* 2>/dev/null)" | |
for s in $sockets; do | |
out="$(socat /dev/null "UNIX-CONNECT:${s}" 2>&1)" | |
if [ $? -eq 0 ]; then | |
socket="${s}" | |
break | |
fi | |
if [[ "${out}" = *"Connection refused"* ]]; then | |
rm "${s}" | |
fi | |
done | |
if [ -z "${socket}" ]; then | |
echo "VSCode IPC socket not found" | |
exit 1 | |
fi | |
export VSCODE_IPC_HOOK_CLI=${socket} | |
if [ ! -v 1 ]; then | |
${script} . | |
else | |
${script} $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment