71f0189ed57911360b19883cb6211fe621292086

Author
Džiugas Eiva <dziugaseiva@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

vscode: add support for VSCodium (#9080)

Co-authored-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
Co-authored-by: Marc Cornellà <marc.cornella@live.com>

Diff

This diff is truncated to protect this page.

 1diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md
 2index 469c57ea83fdcfd98aee158bb5f3d289402629cf..e95ed5d4f8ca1a15486b39e6ca32bf18c0a2ce7c 100644
 3--- a/plugins/vscode/README.md
 4+++ b/plugins/vscode/README.md
 5@@ -1,6 +1,6 @@
 6 # VS Code
 7 
 8-This plugin makes interaction between the command line and the VS Code editor easier.
 9+This plugin provides useful aliases to simplify the interaction between the command line and VS Code or VSCodium editor.
10 
11 To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`:
12 
13@@ -10,23 +10,37 @@ plugins=(... vscode)
14 
15 ## Requirements
16 
17-To use VS Code in the terminal **in macOS**, first you need to install the `code` command in the PATH,
18-otherwise you might receive this message: `zsh: command not found: code`.
19+This plugin requires to have a flavour of VS Code installed and it's executable available in PATH.
20 
21-[As the docs say](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open
22+You can install either:
23+
24+* VS Code (code)
25+* VS Code Insiders (code-insiders)
26+* VSCodium (codium)
27+
28+### MacOS
29+While Linux installations will add the executable to PATH, MacOS users might still have to do this manually:
30+
31+[For VS Code and VS Code Insiders](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open
32 the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
33-> Install 'code' command in PATH
34+> Shell Command: Install 'code' command in PATH
35 
36-## VS Code Insiders
37+[For VSCodium](https://github.com/VSCodium/vscodium/blob/master/DOCS.md#how-do-i-open-vscodium-from-the-terminal), open
38+the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
39+> Shell Command: Install 'codium' command in PATH
40 
41-🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.**
42+## Using multiple flavours
43 
44diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh
45index 0144e0baa5c60d988bf22255407958d8d8a10076..48d90437702d696b4df53b2055138c8e7efaf5fe 100644
46--- a/plugins/vscode/vscode.plugin.zsh
47+++ b/plugins/vscode/vscode.plugin.zsh
48@@ -1,17 +1,28 @@
49-# VScode zsh plugin
50+# VS Code (stable / insiders) / VSCodium zsh plugin
51 # Authors:
52 #   https://github.com/MarsiBarsi (original author)
53 #   https://github.com/babakks
54+#   https://github.com/SteelShot
55 
56-# Use the stable VS Code release, unless the Insiders version is the only
57-# available installation
58-if ! which code > /dev/null && which code-insiders > /dev/null; then
59-  : ${VSCODE:=code-insiders}
60-else
61-  : ${VSCODE:=code}
62+# Verify if any manual user choice of VS Code exists first.
63+if [[ -n "$VSCODE" ]] && ! which $VSCODE &>/dev/null; then
64+  echo "'$VSCODE' flavour of VS Code not detected."
65+  unset VSCODE
66+fi
67+
68+# Otherwise, try to detect a flavour of VS Code.
69+if [[ -z "$VSCODE" ]]; then
70+  if which code &>/dev/null; then
71+    VSCODE=code
72+  elif which code-insiders &>/dev/null; then
73+    VSCODE=code-insiders
74+  elif which codium &>/dev/null; then
75+    VSCODE=codium
76+  else
77+    return
78+  fi
79 fi
80 
81-# Define aliases
82 alias vsc="$VSCODE ."
83 alias vsca="$VSCODE --add"
84 alias vscd="$VSCODE --diff"