d3112d67a3eb55fc39975f917467704ebb2c296b

Author
Vyacheslav Scherbinin <shcherbinin@ccfit.nsu.ru>
Committer
GitHub <noreply@github.com>
Date

Message

feat(vscode): allow arguments to `vsc` alias (#11903)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>

Diff

 1diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md
 2index e95ed5d4f8ca1a15486b39e6ca32bf18c0a2ce7c..726b23d359f77230352e42416550267384a21e69 100644
 3--- a/plugins/vscode/README.md
 4+++ b/plugins/vscode/README.md
 5@@ -31,7 +31,7 @@ the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell
 6 
 7 ## Using multiple flavours
 8 
 9-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 
10+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
11 manually specify the flavour's executable. Add the following line to the .zshrc file (between the `ZSH_THEME` and the `plugins=()` lines).
12 This will make the plugin use your manually defined executable.
13 
14@@ -53,6 +53,7 @@ source $ZSH/oh-my-zsh.sh
15 | Alias                   | Command                        | Description                                                                                                 |
16 | ----------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------- |
17 | vsc                     | code .                         | Open the current folder in VS code                                                                          |
18+| vsc `dir`               | code `dir`                     | Open passed folder in VS code                                                                               |
19 | vsca `dir`              | code --add `dir`               | Add folder(s) to the last active window                                                                     |
20 | vscd `file` `file`      | code --diff `file` `file`      | Compare two files with each other.                                                                          |
21 | vscg `file:line[:char]` | code --goto `file:line[:char]` | Open a file at the path on the specified line and character position.                                       |
22diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh
23index 48d90437702d696b4df53b2055138c8e7efaf5fe..356c6236088dabfa407bf6542739962ad17f4361 100644
24--- a/plugins/vscode/vscode.plugin.zsh
25+++ b/plugins/vscode/vscode.plugin.zsh
26@@ -23,7 +23,14 @@ if [[ -z "$VSCODE" ]]; then
27   fi
28 fi
29 
30-alias vsc="$VSCODE ."
31+function vsc {
32+  if (( $# )); then
33+    $VSCODE $@
34+  else
35+    $VSCODE .
36+  fi
37+}
38+
39 alias vsca="$VSCODE --add"
40 alias vscd="$VSCODE --diff"
41 alias vscg="$VSCODE --goto"