简体   繁体   English

在Windows Git Bash(MinGW)中为Visual Studio Code添加快捷方式

[英]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). 我正在寻找一种在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. Visual Studio代码设置页面显示了如何在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:\\ “ 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 扩展zoon的答案,以下对我有用

  1. create a code.cmd file with the following contents 创建具有以下内容的code.cmd文件
 #! /bin/sh node /c/Program\\ Files\\ \\(x86\\)/Microsoft\\ VS\\ Code/bin/code.js $* 
  1. add a symlink to that code.cmd 将符号链接添加到该code.cmd

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

this allows me to pass path parameter to code 这使我可以将path参数传递给代码

code ./somefolder/

Create a shell script: 创建一个shell脚本:

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

name it 'code' and put it with 'code.cmd'. 将其命名为“ code”,并以“ code.cmd”命名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于运行Git Bash脚本的Windows快捷方式 - Windows shortcut to run a Git Bash script 在Windows上使用MinGW编译Glew git代码 - Compile Glew git code with MinGW on Windows 无法在具有MinGW和git bash的Windows上运行Cmake - Can't run Cmake on windows with MinGW and git bash 在Windows上从git的mingw在bash中运行db2 - running db2 in bash from git's mingw on windows 未配置使用 MinGW 的 Windows 上 bash 脚本的 git - git from bash script on Windows using MinGW is not configured 从 windows 上的 ubuntu bash 终端打开 Visual Studio(不是 Visual Studio 代码) - Open Visual Studio (Not Visual Studio Code) from the ubuntu bash terminal on windows 在 Windows 上的 MINGW bash 中执行时,docker build 命令将“C:/Program Files/Git”添加到作为构建参数传递的路径中 - docker build command add 'C:/Program Files/Git' to the path passed as build argument when executed in MINGW bash on Windows Visual Studio Code 在 Windows 提示符下使用快捷键 ctrl+shift+B 运行构建任务 - Visual Studio Code Run build task in the Windows prompt with shortcut ctrl+shift+B 如何使用快捷键打开windows Git Bash 上的当前目录? - How open the current directory on Git Bash in windows using keyboard shortcut? Windows Bash和Visual Studio代码:如何将bash作为运行任务启动? - Windows Bash and Visual Studio Code: How can I launch bash as a run task?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM