文档中提到了一种叫做代码的可执行文件,但我不确定在哪里可以找到它,所以我可以把它放在我的路径上。我从VSCode网站下载的zip文件不包括任何这样的可执行文件。(我可以很好地运行.app。)
这是windows独有的功能吗?
文档中提到了一种叫做代码的可执行文件,但我不确定在哪里可以找到它,所以我可以把它放在我的路径上。我从VSCode网站下载的zip文件不包括任何这样的可执行文件。(我可以很好地运行.app。)
这是windows独有的功能吗?
当前回答
在OSX Mavericks上,我在~/bin中创建了一个名为vscode的bash脚本(改编自vscode Setup中的.bashrc):
#!/bin/bash
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
Vscode <文件或目录>现在按预期工作。
其他回答
运行代码的步骤。命令启动VSCode应用程序-
打开VSCode 打开命令托盘(Cmd+Shift+P) 输入Shell命令:在PATH中安装'code'命令并选择 你会得到Shell命令'code'成功安装在PATH的通知。 重新启动终端并输入代码。 这将从其中的当前文件夹文件打开VSCode。
在OSX Mavericks上,我在~/bin中创建了一个名为vscode的bash脚本(改编自vscode Setup中的.bashrc):
#!/bin/bash
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
Vscode <文件或目录>现在按预期工作。
在VS Code命令行中给出的启动路径的指令是不正确的;示例中显示的前导冒号不起作用。但是,以反斜杠结束的目录名启动将按预期打开指定的目录。
举个例子,
代码C:\Users\DAVE\Documents\编程\角\ StringCalculator \ src \
在C:\Users\DAVE\Documents\Programming\Angular\StringCalculator\src目录下打开Visual Studio代码编辑器。
重要提示:终端反斜杠虽然是可选的,但很有用,因为它清楚地表明意图是打开一个目录,而不是打开一个文件。请记住,文件扩展名一直都是可选的。
注意:附加到PATH列表的目录是\bin目录,shell命令代码启动Windows NT command脚本。
因此,当合并到另一个shell脚本中时,如果您希望运行脚本的其余部分,则必须调用或启动代码。值得庆幸的是,在我第一次测试一个新的shell脚本之前,我发现了这一点。我创建这个脚本是为了在本地Web服务器、默认的Web浏览器和Visual Studio Code中同时启动一个Angular 2项目。
下面是我的Angular启动脚本,经过调整,消除了对某个发布在其他地方的系统实用程序的依赖,但不是严格要求的。
@echo off
goto SKIPREM
=========================================================================
Name: StartAngularApp.CMD
Synopsis: Start the Angular 2 application installed in a specified
directory.
Arguments: %1 = OPTIONAL: Name of directory in which to application
is installed
Remarks: If no argument is specified, the application must be in
the current working directory.
This is a completely generalized Windows NT command
script (shell script) that uses the NPM Angular CLI to
load an Angular 2 application into a Node development
Web server, the default Web browser, and the Visual
Studio Code text editor.
Dependencies: Unless otherwise specified in the command line, the
application is created in the current working directory.
All of the following shell scripts and programs must be
installed in a directory that is on the Windows PATH
directory list.
1) ShowTime.CMD
2) WWPause.exe
3) WWSleep.exe
4) npm (the Node Package Manager) and its startup
script, npm.cmd, must be accessible via the Windows
PATH environment string. By default, this goes into
directory C:\Program Files\nodejs.
5) The Angular 2 startup script, ng.cmd, and the Node
Modules library must be installed for global access.
By default, these go into directory %AppData%\npm.
Author: David A. Gray
Created: Monday, 23 April 2017
-----------------------------------------------------------------------
Revision History
-----------------------------------------------------------------------
Date By Synopsis
---------- --- --------------------------------------------------------
2017/04/23 DAG Script created, tested, and deployed.
=======================================================================
:斯基普雷姆
echo BOJ %~0, version %~t0
echo.
echo -------------------------------------------------------
echo Displaying the current node.js version:
echo -------------------------------------------------------
echo.
node -v
echo.
echo -------------------------------------------------------
echo Displaying the current Node Package Manager version:
echo -------------------------------------------------------
echo.
call npm -v
echo.
echo -------------------------------------------------------
echo Loading Angular starter application %1
echo into a local Web server, the default Web browser, and
echo the Visual Studio Code text editor.
echo -------------------------------------------------------
echo.
if "%1" neq "" (
echo.
echo -------------------------------------------------------
echo Starting the Angular application in directory %1
echo -------------------------------------------------------
echo.
cd "%~1"
call code %1\src\
) else (
echo.
echo -------------------------------------------------------
echo Starting the Angular application in directory %CD%
echo -------------------------------------------------------
echo.
call code %CD%\src\
)
call ng serve --open
echo.
echo -------------------------------------------------------
echo %~nx0 Done!
echo -------------------------------------------------------
echo.
Pause
链接你当前的文件夹到vscode。
Windows Registry Editor Version 5.00
; Directory\Background\shell => on empty space
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
"Icon"="C:\\current-folder-vscode\\Code.exe,0"
@="VsCode"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="C:\\current-folder-vscode\\Code.exe ."
; Directory\shell => on a folder
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="VsCode"
"Icon"="C:\\current-folder-vscode\\Code.exe,0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="C:\\current-folder-vscode\\Code.exe ."
将此添加到/usr/local/bin/code,如果它们不同,您可能需要修改路径。
#!/usr/bin/env bash
CONTENTS="/Applications/Visual Studio Code.app/Contents"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?
之后制作可执行文件
sudo chmod +x /usr/local/bin/code