Back to Ohmyzsh

VS Code

plugins/vscode/README.md

latest5.4 KB
Original Source

VS Code

This plugin provides useful aliases to simplify the interaction between the command line and VS Code, VSCodium, or Cursor editor.

To start using it, add the vscode plugin to your plugins array in ~/.zshrc:

zsh
plugins=(... vscode)

Requirements

This plugin requires to have a flavour of VS Code installed and its executable available in PATH.

You can install either:

  • VS Code (code)
  • VS Code Insiders (code-insiders)
  • VSCodium (codium)
  • Cursor (cursor)

MacOS

While Linux installations will add the executable to PATH, MacOS users might still have to do this manually:

For VS Code and VS Code Insiders, open the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:

Shell Command: Install 'code' command in PATH

For VSCodium, open the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:

Shell Command: Install 'codium' command in PATH

For Cursor, open the Command Palette via (F1 or ⌘⇧P) and type shell command to find the Shell Command:

Shell Command: Install 'cursor' command in PATH

Using multiple flavours

If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code Insiders, you can manually specify the flavour's executable. Add the following line to the .zshrc file (between the ZSH_THEME and the plugins=() lines). This will make the plugin use your manually defined executable.

zsh
ZSH_THEME=...

# Choose between one [code, code-insiders, codium, or cursor]
# The following line will make the plugin to open VS Code Insiders
# Invalid entries will be ignored, no aliases will be added
VSCODE=code-insiders

plugins=(... vscode)

source $ZSH/oh-my-zsh.sh

Common aliases

AliasCommandDescription
vsccode .Open the current folder in VS code
vsc dircode dirOpen passed folder in VS code
vsca dircode --add dirAdd folder(s) to the last active window
vscd file filecode --diff file fileCompare two files with each other.
vscg file:line[:char]code --goto file:line[:char]Open a file at the path on the specified line and character position.
vscncode --new-windowForce to open a new window.
vscrcode --reuse-windowForce to open a file or folder in the last active window.
vscwcode --waitWait for the files to be closed before returning.
vscu dircode --user-data-dir dirSpecifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.
vscp profilecode --profile profileSpecifies the profile to open Code with.

Extensions aliases

AliasCommandDescription
vsced dircode --extensions-dir dirSet the root path for extensions.
vscie id or vsix-pathcode --install-extension extension-id> or <extension-vsix-pathInstalls an extension.
vscue id or vsix-pathcode --uninstall-extension id or vsix-pathUninstalls an extension.

Other options:

AliasCommandDescription
vscvcode --verbosePrint verbose output (implies --wait).
vscl levelcode --log levelLog level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.
vscdecode --disable-extensionsDisable all installed extensions.