简体   繁体   中英

add a shortcut in Windows Git Bash (MinGW) for Visual Studio Code

I am looking for a way to add shortcuts in Windows Git Bash (MinGW).

$ code . // should open code in current location

The Visual Studio Code setup page shows how to setup shortcuts in Mac OS X / Linux.

I just need a way to setup a basic shortcut so when I type

code c:\

it will execute:

"c:\\Program Files (x86)\\Microsoft VS Code\\bin\\code.cmd" c:\\


I got it to work using node:

node /c/Program\ Files\ \(x86\)/Microsoft\ VS\ Code/bin/code.js .

Now I just need to make this into a shortcut.

I think this could be accomplished using a symlink. I'm just not sure how to add an extra variable in there ie

ln -s "node /c/path/to/code.js" code

Doing something like the above fails since adding a string is not recognized as valid path.

solution

to expand on zoon's answer the following worked for me

  1. create a code.cmd file with the following contents
 #! /bin/sh node /c/Program\\ Files\\ \\(x86\\)/Microsoft\\ VS\\ Code/bin/code.js $* 
  1. add a symlink to that code.cmd

    ln /c/path/to/file/code.cmd code

this allows me to pass path parameter to code

code ./somefolder/

Create a shell script:

#! /bin/sh
cmd //C code.cmd $*

name it 'code' and put it with 'code.cmd'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM