Visual Studio Code 통합 터미널에서 Windows에서 Bash를 어떻게 사용합니까?
Windows의 Visual Studio Code는 기본적으로 PowerShell을 통합 터미널로 사용합니다. Visual Studio Code에서 Bash를 사용하려면 어떤 단계를 수행해야합니까?
더 이상 bash.exe 경로를 수동으로 입력 할 필요가 없습니다. 이 답변은 더 이상 사용되지 않습니다. 이제 bash로 직접 전환 할 수 있습니다. git이 설치되어 있는지 확인하십시오.
https://git-scm.com/download/win 에서 Git을 설치 하십시오 .
그런 다음 Visual Studio Code를 열고 Ctrl+ Shift+를 사용하여 명령 팔레트를 엽니 다 P. 그런 다음 "사용자 설정 열기"를 입력 한 다음 드롭 다운 메뉴에서 "사용자 설정 열기"를 선택하십시오.
그러면 왼쪽에 기본 설정이 있고 오른쪽에 설정이있는이 탭이 열립니다.
이제이 코드 줄을 자신의 설정 페이지 (오른쪽 창)에 복사하고- "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
참고 : Git 설치에서 파일 "C:\\Program Files\Git\bin\bash.exe"
이있는 경로 bash.exe
입니다. Linux 용 Windows 서브 시스템 (WSL) Bash 쉘을 사용하는 경우 경로는 다음과 같습니다."C:\Windows\System32\bash.exe"
이제 Ctrl+ `를 눌러 Visual Studio Code에서 터미널을 엽니 다. 그리고 당신은 배쉬를 가질 것입니다-
https://git-scm.com/download/win 에서 Git 설치
Visual Studio Code 를 열고 Ctrl+ `를 길게 눌러 터미널을 엽니 다.
Ctrl+ Shift+를 사용하여 명령 팔레트를 엽니 다 P.
유형-기본 쉘 선택
옵션에서 Git Bash를 선택하십시오.
터미널 창에서 + 아이콘을 클릭하십시오
새로운 터미널은 이제 Git Bash 터미널이됩니다. Git Bash를로드하는 데 몇 초가 걸립니다.
You can now toggle between the different terminals as well from the dropdown in terminal.
Updated: Newer versions of Visual Studio Code have the Select Default Shell command in the terminal pull down menu:
Remember that it just lists the shells that are in your %PATH% environment variable. For shells that aren't in your path, see other answers.
Before version 1.36 (June 2019)
The easiest way now (at least from Visual Studio Code 1.22 on) is to type Shift + Ctrl + P to open the Command Palette and type:
Select Default Shell
Now you can easily select your preferred shell between the ones found in your path:
For shells that aren't in your %PATH%, see the other answers.
See the complete Visual Studio Code shell reference. There's lot of meaty stuff.
Press and hold Ctrl + ` to open the terminal. Inside the terminal, type bash
to use Git Bash in the terminal. Note: Make sure you have Git Bash installed on your machine.
If you wish to use PowerShell again, just type powershell
in the terminal. To use the Windows command line, type cmd
in the terminal.
The setting you choose will be used as your default.
For me the following is the only combination that works!
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-cmd.exe",
"terminal.integrated.shellArgs.windows": [
"--command=usr/bin/bash.exe",
"-l",
"-i"
]
With git-bash.exe as the ...shell.windows
, every time Bash was opening outside Visual Studio!!
I followed this tutorial from Paul DeCarlo to use the Bash from the Windows Subsystem for Linux (WSL) instead of what comes with Git Bash for Windows. They are the same steps as above in the answer, but use the below in your User Settings instead.
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe",
This worked for me the first time... which is rare for this stuff.
Things has been a little bit changed due to the latest updates on Visual Studio Code. The following steps work for me.
Press Ctrl + Shift + P to open the Visual Studio Code command palate.
Type
>preferences: Open Settings (JSON)
in the text area.Add the following lines at the end of the JSON file which is displayed in your right hand pane.
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
Close and reopen your Visual Studio Code instance.
This, at least for me, will make Visual Studio Code open a new Bash window as an external terminal.
If you want the integrated environment you need to point to the sh.exe
file inside the bin
folder of your Git installation.
So the configuration should say C:\\<my-git-install>\\bin\\sh.exe
.
It depends on whether you have installed Git Bash in the current user only or all users:
If it is installed on all users then put "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
in your User Settings (Ctrl + Comma).
If it is installed on only the current user then put "terminal.integrated.shell.windows": "C:\\Users\\<name of your user>\\AppData\\Local\\Programs\\Git\\bin\\bash.exe"
in your User Settings (Ctrl + Comma).
If the methods listed above do not work then you should try Christer's solution which says -
If you want the integrated environment you need to point to the
sh.exe
file inside thebin
folder of your Git installation.So the configuration should say
C:\\<my-git-install>\\bin\\sh.exe
.
Note: The sh.exe and bash.exe appear completely same to me. There should be no difference between them.
Add the Git\bin
directory to the Path
environment variable. The directory is %ProgramFiles%\Git\bin
by default. By this way you can access Git Bash with simply typing bash
in every terminal including the integrated terminal of Visual Studio Code.
How to set the path and environment variables in Windows
I had already set up lots of conda
environments on WSL
(Bash on Ubuntu on Windows), so I wanted to use the same Bash installation on Visual Studio Code.
To do that, I just had to specify the path of this particular Bash executable (instead of the Git-Bash
) on Visual Studio Code's settings:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
PS: to make sure where your Ubuntu on Bash executable is installed on your Windows machine, open the Command prompt
(search: cmd
) and run:
where bash.exe
This answer is similar to the top voted answer, but with an important distinction: a lot of the previous answers on this question focus on running Git Bash while my answer focuses on running WSL Bash.
Enable Windows Subsystem for Linux on your Windows 10 machine.
Open Visual Studio Code and press and hold Ctrl + ` to open the terminal.
Open the command palette using Ctrl + Shift + P.
Type -
Select Default Shell
.Select
WSL Bash
(NOTGit Bash
) from the options.
- Click on the
+
icon in the terminal window. The new terminal now will be a WSL Bash terminal!
Fortune 500 회사에 문의하는 것은 슬프게도 Windows 7 이며 관리자 권한이 없습니다. 따라서 Node.js, Npm, Visual Studio Code 등이 내 컴퓨터로 푸시되었습니다. 많이 변경할 수 없습니다.
Windows 7을 실행하는이 컴퓨터의 경우 :
아래는 새로운 설정입니다. 작동하지 않는 것은 주석 처리됩니다.
{
"update.channel": "none",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
//"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
}
'Programing' 카테고리의 다른 글
컬 설치 Ubuntu LAMP 스택을 활성화하는 방법은 무엇입니까? (0) | 2020.04.27 |
---|---|
UISegmentedControl의 글꼴 크기 변경 (0) | 2020.04.27 |
Android Studio 3.0 맛 차원 문제 (0) | 2020.04.27 |
.css 파일을 .less 파일로 가져 오기 (0) | 2020.04.27 |
목록에서 임의의 항목에 액세스하는 방법? (0) | 2020.04.27 |