1password cli op run with python in Visual Studio Code using remote SSH
I am really interested in using 1password cli in Visual studio code but needing to add 'op run --' before the command is nearly impossible when using VSC python debugger. At least I have not found a sensible solution to it. I have come up with this approach which works. Does anyone else have a better solution?
VSC uses /usr/bin/env before every command it executes on linux, when debugging, and even when starting a remote ssh session.
sudo mv /usr/bin/env to /usr/bin/env_orig
vi /usr/bin/env
And paste this script
```bash
!/bin/bash
if [[ $@ == 'code-server' ]]; then
/usr/bin/env_orig $@
else
source /etc/1p.sh && op run --env-file "~/1password.env" -- /usr/bin/env_orig $@
fi
```
chmod +x /usr/bin/env
The file /etc/1p.sh contains two exports
export OP_CONNECT_HOST=
export OP_CONNECT_TOKEN=
I didn't want these in the /usr/bin folder
This will ensure that op run is executed every time env is run.
The if statement is necessary to prevent this process running when VSC starts the remote ssh session. Without this, the environment variables get permanently injected into the VSC remote session.
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Browser:_ Not Provided
