Integrate Bash in Visual Studio2019 on Windows

·

2 min read

Recently, I want to integrate git hook into my project written in C++. But the most git hook scripts except framework like pre-commit or husky are needed to run on Unix-like system.

Moreover, our team mainly develop on platform mainly on Windows. In order to let git hook scripts work smoothly and painlessly in the teams. I try to integrate bash used by git-windows and visual studio to make scripts work on Windows

Required Install

  1. Visual Studio

  2. Git on Windows , for I install git before install Visual Studio, I am not sure that install git-on-windows via Extension Manager whether auto-integrate or not

Steps

  1. In VS2019, function tab: Tools > Options

  2. Then under Environments > Terminal

  1. Add a profile "bash" for example, fill Name field and Shell location where you install Git. Usually install git

  2. On whole PC, the path is "C:\Program Files\Git\bin\bash.exe", and there is also sh.exe you can choose

  3. After Click Apply and OK buttons, you could see there is a bash profile on the view of terminal(Ctrl-`) you can call to run a bash terminal in Visual Studio. Basically, as long as you open the repo or directory with Visual Studio, the terminal will cd to the path of this repo in default.

Others

Take care your eyes: Change the font size of terminal

Options > Environment > Fonts and Colors

Show settings: Terminal, and you can adjust font size of terminal

If you have other better solution, welcome to comment <3