Add git bash profile to windows terminal что это

Содержание

Введение
Установка Git Bash
Добавить Git Bash в Windows Terminal
Alias
Добавить в Git Bash tree, wget…
kdiff
Другие статьи про Git

Введение

Обычно

git

не установлен по умолчанию, поэтому нужно установить

Git Bash
,

Tortoise Git

или какое-то другое решение.

Установка Git Bash

Если Вы работаете в

Windows

, нужно скачать git for windows

git-scm.com

На следующих скриншотах Вы увидите установку git for windows в случае, когда
Вы хотите пользоваться только GitBash и не планируете использовать Tortoise Git

Скачайте файл с установщиком, например

Git-2.39.2-64-bit.exe

, и запустите его двойным щелчком мыши.

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

В современных версиях Git Bash появилась возможность добавлять её в

Windows Terminal

прямо во время установки. Если вы ещё не пользуетесь

Windows Terminal

советую прочитать про него статью

здесь
.

Выберите Add a Git Bash Profile to Windows Terminal

Добавить Git Bash в терминал установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Добавить Git Bash в Terminal


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

Теперь нужно сделать важный выбор.

Если Вы выберете Tortoise Git то все SSH ключи нужно будет
указывать через Tortoise Git, что мне не очень понравилось.

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru
Git Setup


Установка Git Bash

Alias

В Git Bash можно использовать алиасы также как и в обычном

Bash

с поправкой на особенности

Windows

Так, например, будет выглядеть алиас для проигрывателя VLC

alias vlc=»/c/Program\ Files/VideoLAN/VLC/vlc.exe»

Обратите внимание на разницу с

WSL

там нужно было бы указывать #47;mnt

Также в Git Bash команда cd приведёт вас в

/c/Users/Andrei

А не в

/home/andrei

Добавить в Git Bash утилиты tree, wget и другие

Для того чтобы расширять возможности Git Bash нужно понять куда он установлен.

Сделать это можно зайдя в терминал Git Bash и выполнив

cd /

explorer .

После этого в Windows должно открыться окно проводника с той директорией, в которой лежит

git-bash.exe

Обычно это

C:\Program Files\Git\

Либо

C:\Users\Username\AppData\Local\Programs\Git\

Добавление новых утилит происходит путём помещения .exe файлов вида

name.exe

в поддиректорию usr/bin

Полный путь до неё это, например

C:\Program Files\Git\usr\bin

или

C:\Users\Username\AppData\Local\Programs\Git\usr\bin

Сперва нужно скачать исполняемый файл, в эту директорию, затем проверить
работает ли новая команда.

Если сразу не получилось — попробуйте перезапустить Git Bash

tree

Чтобы использовать команду tree в Git Bash нужно скачать .zip файл
с Binaries с сайта:

https://gnuwin32.sourceforge.net/packages/tree.htm

Затем этот архив нужно распаковать и найти там (в директории bin) файл

tree.exe

и поместить его в usr/bin

Изучить примеры работы с

tree

вы можете

здесь

wget

wget

можно скачать с сайта

https://eternallybored.org/misc/wget/

и добавить в ту же директорию, о которой мы говорили в

начале темы

По этому же принципу будут добавляться и другие утилиты.

Изучить примеры работы с

wget

вы можете

wget

Добавить в Git Bash kdiff3

Если в Git Bash не выбрано ни одного diff и merge инструмента — в главном окне будет
предупреждение.

Изучите Settings — Checklist

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Одним из доступных на выбор инструментов является kdiff3

Выберите kdiff3

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Начните установку и нажмите I Agree

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Выберите компоненты и нажмите Next >

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Выберите директорию для установки и нажмите Next >

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Задайте тип установки и нажмите Next >

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Выберите директорию для стартового меню и нажмите Install

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Завершите установку нажав Finish

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Изучите README

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Вернитесь в Git Extensions и укажите путь до kdiff3.exe в Path to mergetool и Path to difftool

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Теперь можно спокойно пользоваться Git Extensions

установка git for windows с openSSH изображение с сайта www.andreyolegovich.ru

Git Setup


Установка Git Bash

Похожие статьи

Git
Установка
Перейти с HTTPS на SSH
.gitignore
Необходимые Bash команды
Remote
GitHub
GitLab
Ошибки
Git Bash
Работа с API GitHub

Let’s look at how to add Git Bash to Windows Terminal in just a few steps.

Prerequisites

  • Windows Terminal – download from the Microsoft Windows Apps website or Microsoft Store
  • Git Bash – download here

Let’s begin!

🎥 Want to watch a video to supplement your reading? Check this out:

Add Git Bash to Windows Terminal

Open up Windows Terminal.

Press down CTRL + , (comma) or click the dropdown arrow to open the Settings.

Windows Terminal Settings

Next, click Add a new profile.

Windows Terminal Add New Profile

Click the New empty profile button.

Windows Terminal Create New Empty Profile

Name the profile Git Bash, or any suggestive name you’d like.

Set the executable Git path to C:\Program Files\Git\bin\bash.exe in the Command Line section.

Your path may be different, depending on where you installed Git.

⚠️In any case, make sure to choose the executable file from the bin folder!

Set the starting directory to %USERPROFILE% or any directory you’re using the most.

Set the path to the icon to C:\Program Files\Git\mingw64\share\git\git-for-windows.ico

Set the Title Tab to Git Bash (not visible in the picture) or any suggestive name you’d like.

Press Save when you are done.

Add Git Bash to Windows Terminal configuration

Try it

Now you are ready to test it out!

Open the Git Bash window by clicking the dropdown arrow and then Git Bash or by using the CTRL + SHIFT + 6 hotkey.

try out Git Bash in Windows Terminal

Congrats! 🥳

We have successfully added Git Bash to Windows Terminal!

Git Bash integrated in Windows Terminal

Set Git Bash as Default Terminal

If you had the curiosity of opening a new terminal by pressing the + icon you are probably now disappointed that Git Bash wasn’t the one that popped up.

That’s because the Git Bash profile we just created was not set as the default profile.

Let’s fix that!

Go back to Settings -> Startup -> Default Profile and select Git Bash as the default profile.

Set GIt Bash as Default profile in Windows Terminal

Add Git Bash to Windows Terminal via settings.json

You can add Git Bash to Windows Terminal via the settings.json file.

Click the cog icon at the bottom left of the screen where it says Open JSON file.

Or you can access the path directly C:\Users\YOUR_USER\AppData\Local\Packages\Microsoft.WindowsTerminal_<SOME_HASH>\LocalState\settings.json

Windows Terminal add Git Bash via settings.json file

Open the file with your favorite text editor and add the following chunk of code inside {} profiles > [] list > {} object.

Add Git Bash to Windows Terminal via settings.json file

We went through all of this and now you tell me there was a simpler way?

Well, not really.

You still have to replace the guid with your own and that can be found only by checking the Windows Registry which in itself is not a pleasant thing to do.

Still, it’s a faster way of adding Git Bash to Windows Terminal if you already know the guid in advance.

That was it! 🎉


Let me know what you think about this article in the comments section below.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.

  

Overview

  1. Open settings with Ctrl+,
  2. You’ll want to append one of the profiles options below (depending on what version of git you have installed) to the "list": portion of the settings.json file:

Open settings.json in Windows Terminal sidebar

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{00000000-0000-0000-ba54-000000000001}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles
        },
        "list":
        [
            <put one of the configuration below right here>
        ]
    }
}

Profile options

Uncomment correct paths for commandline and icon if you are using:

  • Git for Windows in %PROGRAMFILES%
  • Git for Windows in %USERPROFILE%
  • If you’re using scoop
{
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    "commandline": "%PROGRAMFILES%/Git/usr/bin/bash.exe -i -l",
    // "commandline": "%USERPROFILE%/AppData/Local/Programs/Git/bin/bash.exe -l -i",
    // "commandline": "%USERPROFILE%/scoop/apps/git/current/usr/bin/bash.exe -l -i",
    "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
    // "icon": "%USERPROFILE%/AppData/Local/Programs/Git/mingw64/share/git/git-for-windows.ico",
    // "icon": "%USERPROFILE%/scoop/apps/git/current/usr/share/git/git-for-windows.ico",
    "name" : "Bash",
    "startingDirectory" : "%USERPROFILE%"
},

You can also add other options like:

{
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    // ...
    "acrylicOpacity" : 0.75,
    "closeOnExit" : true,
    "colorScheme" : "Campbell",
    "cursorColor" : "#FFFFFF",
    "cursorShape" : "bar",
    "fontFace" : "Consolas",
    "fontSize" : 10,
    "historySize" : 9001,
    "padding" : "0, 0, 0, 0",
    "snapOnInput" : true,
    "useAcrylic" : true
}

Notes

  • make your own guid as of https://github.com/microsoft/terminal/pull/2475 this is no longer generated.
  • the guid can be used in in the globals > defaultProfile so you can press CtrlShiftT
    or start a Windows terminal and it will start up bash by default
"defaultProfile" : "{00000000-0000-0000-ba54-000000000001}",
  • -l -i to make sure that .bash_profile gets loaded
  • use environment variables so they can map to different systems correctly.
  • target git/bin/bash.exe to avoid spawning off additional processes which saves about 10MB per process according to Process Explorer compared to using bin/bash or git-bash

I have my configuration that uses Scoop in https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8

Rodrigo's user avatar

Rodrigo

611 silver badge12 bronze badges

answered Aug 6, 2019 at 5:09

Archimedes Trajano's user avatar

21

There are below things to do.

  1. Make sure the git command runs successfully in Command Prompt.

That means you need to add git to path when install git or add it to system environment later.

Run git in Command Prompt

  1. Update the file profile.json: open Settings by pressing Ctrl+, in Windows Terminal, click on Open JSON file in the sidebar, and add following snippet inside the word profiles:

Open settings.json in Windows Terminal sidebar

        { 
            "tabTitle": "Git Bash",
            "acrylicOpacity" : 0.75, 
            "closeOnExit" : true, 
            "colorScheme" : "Campbell", 
            "commandline" : "C:/Program Files/Git/bin/bash.exe --login", 
            "cursorColor" : "#FFFFFF", 
            "cursorShape" : "bar", 
            "fontFace" : "Consolas", 
            "fontSize" : 12, 
            "guid" : "{14ad203f-52cc-4110-90d6-d96e0f41b64d}", 
            "historySize" : 9001, 
            "icon": "ms-appdata:///roaming/git-bash_32px.ico",
            "name" : "Git Bash", 
            "padding" : "0, 0, 0, 0", 
            "snapOnInput" : true, 
            "useAcrylic" : true 
        }

The icon can be obtained here: git-bash_32px.ico

You can add icons for Tab to this location:

%LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState

Put 32×32 PNG/icons in this folder, and then in profile.json you can reference the image resource with the path starting with ms-appdata://.

Note that, please make sure the Guidis correct and it matches the corresponding correct configurations.

  1. Test that git bash works in Windows Terminal.

The final result is below:
enter image description here

Aryan Beezadhur's user avatar

answered Aug 6, 2019 at 6:01

Bravo Yeung's user avatar

Bravo YeungBravo Yeung

8,7125 gold badges38 silver badges45 bronze badges

11

This is the complete answer (GitBash + color scheme + icon + context menu)

  1. Set default profile:
"globals": 
{
    "defaultProfile" : "{00000000-0000-0000-0000-000000000001}",
    ...
  1. Add GitBash profile
"profiles": [
    {
        "guid": "{00000000-0000-0000-0000-000000000001}",
        "acrylicOpacity": 0.75,
        "closeOnExit": true,
        "colorScheme": "GitBash",
        "commandline": "\"%PROGRAMFILES%\\Git\\usr\\bin\\bash.exe\" --login -i",
        "cursorColor": "#FFFFFF",
        "cursorShape": "bar",
        "fontFace": "Consolas",
        "fontSize": 10,
        "historySize": 9001,
        "icon": "%PROGRAMFILES%\\Git\\mingw64\\share\\git\\git-for-windows.ico",
        "name": "GitBash",
        "padding": "0, 0, 0, 0",
        "snapOnInput": true,
        "startingDirectory": "%USERPROFILE%",
        "useAcrylic": false
    }
]
  1. Add GitBash color scheme
  "schemes": [
      {
          "background": "#000000",
          "black": "#0C0C0C",
          "blue": "#6060ff",
          "brightBlack": "#767676",
          "brightBlue": "#3B78FF",
          "brightCyan": "#61D6D6",
          "brightGreen": "#16C60C",
          "brightPurple": "#B4009E",
          "brightRed": "#E74856",
          "brightWhite": "#F2F2F2",
          "brightYellow": "#F9F1A5",
          "cyan": "#3A96DD",
          "foreground": "#bfbfbf",
          "green": "#00a400",
          "name": "GitBash",
          "purple": "#bf00bf",
          "red": "#bf0000",
          "white": "#ffffff",
          "yellow": "#bfbf00",
          "grey": "#bfbfbf"
      }
  ]
  1. To add a right-click context menu «Windows Terminal Here»
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="C:\\Users\\{YOUR_WINDOWS_USERNAME}\\AppData\\Local\\Microsoft\\WindowsApps\\{YOUR_ICONS_FOLDER}\\icon.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="\"C:\\Users\\{YOUR_WINDOWS_USERNAME}\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe\""
  • Replace {YOUR_WINDOWS_USERNAME} with your Windows username.
  • Create an icon folder, put the icon there and replace {YOUR_ICONS_FOLDER} with your icon folder.
  • Save this in a .reg file and run it.

answered Sep 20, 2019 at 11:46

Altin's user avatar

AltinAltin

2,1754 gold badges25 silver badges47 bronze badges

16

It’s Sept 2021, thankfully the latest Git Installation installer for Windows (mine was using 2.33.0.2) already has this option covered for us, for the sake of our laziness (and convenience, of course!)

Please install the Windows Terminal first before installing Git, although I haven’t try the otherway around, but better follow the sensible order. If the installation order is not the case, please let me know to update this answer.

You may find this handful checkbox at the bottom within the installation stage Select Components, just tick the box there and you’re good to go.
enter image description here

The settings.json file will be added the Git Bash profile automatically with correct Git Bash icon. My generated Git Bash profile is pretty standard and minimal.

{
    "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
    "hidden": false,
    "name": "Git Bash",
    "source": "Git"
}

If Windows Terminal is running, close and launch again for the Git Bash option to be visible.

iron9's user avatar

iron9

4273 silver badges12 bronze badges

answered Sep 7, 2021 at 18:51

ThangLeQuoc's user avatar

ThangLeQuocThangLeQuoc

2,3022 gold badges20 silver badges30 bronze badges

1

Because most answers either show a lot of unrelated configuration or don’t show the configuration, I created my own answer that tries to be more focused. It is mainly based on the profile settings reference and Archimedes Trajano’s answer.

Steps

  1. Open PowerShell and enter [guid]::NewGuid() to generate a new GUID. We will use it at step 3.

    > [guid]::NewGuid()
    
    Guid
    ----
    a3da8d92-2f3f-4e36-9714-98876b6cb480
    
  2. Open the settings of Windows Terminal. (CTRL+,)

  3. Add the following JSON object to profiles.list. Replace guid with the one you generated at step 1.

    {
      "guid": "{a3da8d92-2f3f-4e36-9714-98876b6cb480}",
      "name": "Git Bash",
      "commandline": "\"%PROGRAMFILES%\\Git\\usr\\bin\\bash.exe\" -i -l",
      "icon": "%PROGRAMFILES%\\Git\\mingw64\\share\\git\\git-for-windows.ico",
      "startingDirectory" : "%USERPROFILE%"
    },
    

Notes

  • There is currently an issue that you cannot use your arrow keys (and some other keys). It seems to work with the latest preview version, though. (issue #6859)

  • Specifying "startingDirectory" : "%USERPROFILE%" shouldn’t be necessary according to the reference. However, if I don’t specify it, the starting directory was different depending on how I started the terminal initially.

  • Settings that shall apply to all terminals can be specified in profiles.defaults.

  • I recommend to set "antialiasingMode": "cleartype" in profiles.defaults. You have to remove "useAcrylic" (if you have added it as suggested by some other answers) to make it work. It improves the quality of text rendering. However, you cannot have transparent background without useAcrylic. See issue #1298.

  • If you have problems with the cursor, you can try another shape like "cursorShape": "filledBox". See cursor settings for more information.

answered Jul 7, 2020 at 22:43

JojOatXGME's user avatar

JojOatXGMEJojOatXGME

3,0342 gold badges25 silver badges41 bronze badges

0

That’s how I’ve added mine in profiles json table,

{
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    "name": "Git",
    "commandline": "C:/Program Files/Git/bin/bash.exe --login",
    "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
    "startingDirectory": "%USERPROFILE%",
    "hidden": false
}

Martin Brisiak's user avatar

answered Jan 25, 2021 at 10:27

Ayoub EL ABOUSSI's user avatar

2

In case anyone is looking for a UI-Based solution. Here it is:

  1. Go to the Terminal’s settings.

  2. At the Right buttom side, look for the «Add new profile» option.
    Screenshot for the Terminal’s settings.

  3. Select «New Empty Profile»

  4. Now complete the fields with the information about your bash. If your installation locations are the default ones, you could use these:

  • Name: Git-Bash
  • Command line: C:\Program Files\Git\bin\bash.exe
  • Startin directory: [Leave as default]
  • Icon: C:\Program Files\Git\mingw64\share\git\git-for-windows.ico
  • Tab title: Git-Bash
    Temrinal Settings completed
    You could also browse for the right files in case you need to.
  1. Hit Save button.

Final Result

Final Result. Bash terminal

answered Jan 13, 2022 at 15:23

Pedro Lebron's user avatar

2

Another item to note — in settings.json
I discovered if you don’t use
«commandline»: «C:/Program Files/Git/bin/bash.exe»

and instead use:
«commandline»: «C:/Program Files/Git/git-bash.exe»

the Git shell will open up in an independent window outside of Windows Terminal instead of on a tab — which is not the desired behavior.
In addition, the tab in Windows Terminal that opens will also need to be closed manually as it will display process exited information — [process exited with code 3221225786] etc.

Might save someone some headache

answered Jun 11, 2020 at 18:30

AB1's user avatar

AB1AB1

1611 silver badge6 bronze badges

4

Change the profiles parameter to "commandline": "%PROGRAMFILES%\\Git\\bin\\bash.exe -l -i"

This works for me and allows for my .bash_profile alias autocomplete scripts to run.

answered Jul 3, 2019 at 9:55

Orbittman's user avatar

OrbittmanOrbittman

3061 silver badge6 bronze badges

0

The new version of windows terminal can be configured through its GUI.

Setting -> Add new
Under "command line" add the path -> path/to/Git/bin/bash.exe

Mendy's user avatar

Mendy

7,6725 gold badges29 silver badges42 bronze badges

answered May 11, 2021 at 12:08

saveearth's user avatar

saveearthsaveearth

1811 silver badge4 bronze badges

1

If you want to display an icon and are using a dark theme. Which means the icon provided above doesn’t look that great. Then you can find the icon here

C:\Program Files\Git\mingw64\share\git\git-for-windows I copied it into.

%LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState

and named it git-bash_32px as suggested above.

Control the opacity with CTRL + SHIFT + scrolling.

        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{73225108-7633-47ae-80c1-5d00111ef646}",
            "historySize" : 9001,
            "icon" : "ms-appdata:///roaming/git-bash_32px.ico",
            "name" : "Bash",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : true
        },

answered Aug 12, 2019 at 11:57

Sigex's user avatar

SigexSigex

2,8422 gold badges24 silver badges25 bronze badges

As far as I know from my current windows terminal version 1.15.2874.0, you can get what you want with a simple manual click to configure it.
The prerequisites are

  1. your git bash client is installed.
  2. at least windows terminal version 1.15.2874.0 or higher.

Then complete the setup by following these steps.

  1. Open windows terminal and find «Settings» in the drop-down list in the top right corner of the menu bar (or use the shortcut ctrl+,);
  2. Click on «Add new profile» at the bottom of the left hand column, then the settings template screen will pop up automatically.
  3. interactive mouse click you want to set the «name», «executable path command line», «startup directory», «icon» value. For example, I set mine to "gitBash", "C:\Program Files\Git\bin\bash.exe", "%USERPROFILE%", and «%USERPROFILE%» in order of customisation. "C:\Program Files\Git\mingw64\share\git\git-for-windows.ico".
  4. save.

The following screenshots are for reference.
enter image description here

enter image description here

answered Dec 4, 2022 at 5:50

cui xingxing's user avatar

Linux guy, here, sorry I am late; I am just installing git-bash for the first time and looking into what its command should be in Windows Terminal.

As far as I know

  • Cygwin is not Windows, but it provides a POSIX translation layer (cygwin*.dll) so that all those non-Windows executables can run. Even when a new computer program is compiled and built with cygwin, it still turns out a non-Windows executable and it still needs cygwin*.dll to run.
  • MSYS2 is mostly Windows with only a few tools that are probably difficult to port remaining non-Windows and requiring a POSIX translation layer to run (msys*.dll); but, most programs are actually Windows native executables. Even when a new computer program is compiled and built, it is my understanding that turns out a Windows native *.exe.

But I still don’t know how important it is that some of these MSYSTEM* and MINGW* environment variables be set or not, when I am going to be using MINGW compiler, anyway.

I did notice that, throughout this thread, both command lines keep showing up, namely, ./bin/bash and ./usr/bin/bash; so, I went ahead and launched them to compare their environments…they can turn out rather different.

Let it be known that, PREVIOUS to launching any of the shells below, I already have C:\Git\mingw64\bin and C:\Git\usr\bin as part of System variable PATH; I do this because I want to have the ability to use bash commands directly from CMD. But I don’t think this does anything to the results below.

                                        c:\Git\bin\bash.exe --login     c:\Git\usr\bin\bash.exe --login
Environment Variable    c:\Git\bin\bash.exe                     c:\Git\usr\bin\bash.exe
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EXEPATH                 c:\git\bin      c:\git\bin              n       n
HOSTNAME                n               MDXXXXXX                n       MDXXXXXX
MINGW_CHOST             n               x86_64-w64-mingw32      n       n
MINGW_PACKAGE_PREFIX    n               mingw-w64-x86_64        n       n
MINGW_PREFIX            n               /mingw64                n       n
MSYSTEM_CARCH           n               x86_64                  n       x86_64
MSYSTEM_CHOST           n               x86_64-w64-mingw32      n       x86_64-pc-msys
MSYSTEM_PREFIX          n               /mingw64                n       /usr
MSYSTEM                 MINGW64         MINGW64                 n       MSYS
PLINK_PROTOCOL          ssh             ssh                     n       n
SHELL                   n               /usr/bin/bash           n       /usr/bin/bash
TMPDIR                  n               /tmp                    n       /tmp

ORIGINAL_PATH           n               y                       n       y
ORIGINAL_TEMP           n               y                       n       y
ORIGINAL_TMP            n               y                       n       y
PATH                    /mingw64/bin:/usr/bin:$HOME/bin:$PATH
PATH                                    $HOME/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:$HOME/bin:$PATH
PATh                                                            $PATH
PATH                                                                    $HOME/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:$PATH

So, for good measure, it looks to me as if the more correct thing would be to use ./bin/bash --login; but I at this very moment, I am not sure what the difference will be, say, when it comes to actually compiling a brand new program with MINGW64/GCC; we shall see.

answered Oct 15, 2022 at 6:24

gsal's user avatar

gsalgsal

395 bronze badges

Now Terminal has the option to add a new profile, without modifying the settings JSON.

Go to «Settings» from the dropdown menu as shown below.

enter image description here

Under the «Profiles» section in the sidebar, select «Add a new profile». Click on «+New empty profile». The following screen opens up.

enter image description here

Add the details as shown in the below screen for git bash or any other bash.

enter image description here

Thats all!

answered Aug 1 at 8:54

Tmh's user avatar

TmhTmh

1,33114 silver badges27 bronze badges

As of Git For Windows 2.42.0 or later, which came out in Aug. 2023 I believe, you can now just re-run the installer and check the box for (NEW!) Add a Git Bash Profile to Windows Terminal, as shown in blue here in the Git 2.42.0 setup:

enter image description here

That’s it!

I first documented that in my instructions here: for other recommended settings to choose while installing Git for Windows, see my personal installation instructions here: Installing Git For Windows.

At the bottom of that, I have a section titled Fix the ~ (HOME) dir in Git Bash, if necessary, which you may need too if echo ~ doesn’t show your proper HOME directory.

answered Aug 22 at 6:38

Gabriel Staples's user avatar

Gabriel StaplesGabriel Staples

37.7k15 gold badges198 silver badges269 bronze badges

I did as follows:

  1. Add «%programfiles%\Git\Bin» to your PATH
  2. On the profiles.json, set the desired command-line as «commandline» : «sh —cd-to-home»
  3. Restart the Windows Terminal

It worked for me.

answered Jul 4, 2019 at 11:54

LFrigoDeSouza's user avatar

Adding "%PROGRAMFILES%\\Git\\bin\\bash.exe -l -i" doesn’t work for me. Because of space symbol (which is separator in cmd) in %PROGRAMFILES% terminal executes command "C:\Program" instead of "C:\Program Files\Git\bin\bash.exe -l -i". The solution should be something like adding quotation marks in json file, but I didn’t figure out how.
The only solution is to add «C:\Program Files\Git\bin» to %PATH% and write "commandline": "bash.exe" in profiles.json

answered Jul 17, 2019 at 7:32

Grigoriy's user avatar

4

To anyone who may suffer from missing bash history:
in already opened git bash, try initiate another bash — that supposed to load your profile if env vars are properly configured

If this is your case, you can automate it by adding following command line on startup:

C:\progra~1\git\usr\bin\bash.exe --login -l -i -c /c/progra~1/git/usr/bin/bash.exe

answered Jan 24, 2022 at 18:29

Lok Lokaj's user avatar

Adding the bellow code to the setting.json will solve the problem.

If you have checked the add to windows terminal option when installing the git and you can see the git bash option in the «duplicate a profile» options.

It will work as I was also facing a similar problem.

{
    "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
    "hidden": false,
    "name": "Git Bash",
    "source": "Git"
}

answered Jul 22 at 16:00

Zarof's user avatar

ZarofZarof

11 bronze badge

1

In this blog post, we will learn how to install Git-SCM and add Git Bash to Windows Terminal profile. If you are completely new to Windows Terminal, then I would highly recommend you to go through the introductory post of installing and understanding Windows Terminal. At the time of writing the current version of Windows Terminal is 1.0

Windows Terminal is a modern terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and Windows Subsystem for Linux (WSL). Its main features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and the ability to create your own themes and customize text, colors, backgrounds, and shortcut key bindings“. [source: Microsoft Docs]

Prerequisite

  • Window Terminal – Should be installed [How to install Windows Terminal]

Install Git-SCM

If Git is already installed on the machine, then this step can be completely be skipped and you can move directly to the next section. Add Git Bash to WindowTerminal profile.

Download Git-SCM

First, we will download and install the Git-SCM from the following link https://git-scm.com/downloads. Here we are using Window Terminal so we will download Git-SCM for Windows and at the time of writing the current version of Git-SCM is 2.27.0

Add Git Bash to Windows Terminal - Download Git-SCM

Add Git Bash to Windows Terminal – Download Git-SCM for Windows

Install Git-SCM

After downloading, we will start the installation process, here while installing we will keep everything as default and install the Git-SCM.

add Git Bash to Windows Terminal - Install Git
Add Git Bash to Windows Terminal – Install Git-SCM

Verify Installation

The installation process will create a git directory inside the %programfiles% folder.

Add Git Bash to Windows Terminal Git Directory

Git Installation Directory

Next, to verify the installation, let us run the git –version command in the terminal. This step assumes the Git path is not yet configured in the Environment variable and it is not required as we are going to point to the bash.exe in the terminal profile.

First, we will open the terminal application and then open the Git’s bin directory, [on my machine, it is C:\Program Files\Git\bin], and executes the command. On successful execution, this will display the git version installed on the machine.

add Git Bash to Windows Terminal Git Version Check
Git version check

Now we are ready to add the git-bash to Window Terminal Profile, so we will move to the next step.

Now we have Git-SCM installed on our machine, the next step is to add its bash.exe in a new Windows Terminal profile, for this, we will perform the following step.

Add New Profile in settings.json

The first step is to open the settings.json file, and then add a new profile into the profiles list. To open the settings.json file user the “Ctrl + ,” shortcut, or select the Settings menu item from the drop-down. The settings.json file will be opened in your configured JSON editor.

Add Git Bash to Windows Terminal Open Settings.json

Open Settings.json

Now, we will add the following JSON into the profiles list. This is the minimum JSON required to add the profile. Later we will add new value to add further customization configurations. The below code practically does nothing, and we need to provide proper values to every JSON key.

 
{
     // Git-Bash profile
    "guid": "{NEW GUID}",
    "name": "profile-name",
    "commandline": "PATH TO BASH.exe"
},

Configure Key-Value for Profile

Here we provide proper values to each of the key’s in the profile object.

Configure GUID: We require a unique GUID value, for this, we will use the online tool to get a new GUID and paste the same inside the curly braces. When I generated the GUID I got the following value, so my key-value looks like this.

“guid”: “{3b433b11-c393-47ed-9421-bafebb058f6c}”

Configure Name: We can choose any name as per our choice, this is the name of the profile. I will pick Git-Bash as my profile name.

“name”: “Git-Bash”

Configure Bash Path: In the commandline key, we will provide the path of bash.exe. For me, the path for bash.exe is C:\Program Files\Git\bin\bash.exe, so the key-value looks like this. Please note the escape the backslash in the path.

“commandline”: “C:\\Program Files\\Git\\bin\\bash.exe”

So the complete JSON for our new Git-Bash profile looks like this. Save the settings.json file.

{
     // Git-Bash profile
    "guid": "{3b433b11-c393-47ed-9421-bafebb058f6c}",
    "name": "Git-Bash",
    "commandline": "C:\\Program Files\\Git\\bin\\bash.exe"
},

Execute the Git-Bash Profile

Open the Git-Bash profile the drop-down list.

Add Git Bash to Windows Terminal new Profile

Git-Bash Profile Added to Drop-Down Menu
Add Git Bash to Windows Terminal Executing Git Bash
Successfully execution of Git-Bash in Windows Terminal

Optional Configurations

Add Icon

Let us download the git-icon from the Git-SCM official page and place the icon inside the installation folder (C:\\Program Files\\Git\\mingw64\\share\\git\\). Now the next thing is to add the following JSON string. This will add the icon on the profile tab as well as in the profile list in the drop-down menu.

“icon”: “C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico”

Add Git Bash to Windows Terminal Add icon

Git icon added

Change Cursor Shape and Color

Let us change the cursor shape to filledBox and its color to yellow, for this we are going to add the following to key-value pair to the profile.

“cursorShape”: “filledBox”,
“cursorColor”: “#FFFF00”

Filled Box Yellow Color Cursor

The complete JSON for the Git-Bash is as follows:

{
        "guid": "{3b433b11-c393-47ed-9421-bafebb058f6c}",      
        "name": "Git-Bash",
        "commandline": "C:\\Program Files\\Git\\bin\\bash.exe",
        "icon": "C:\\git-icon.png",
        "cursorShape": "filledBox",
        "cursorColor": "#FFFF00"
} 

Window Terminal can be customized as per your need, the terminal allows you to customize its color, background image, themes, cursor, tabs, panes, etc. If you want to customize further you can have a look at How to customize Windows Terminal Application post. All in all, it a great tool to manage different shells all in one place.

I hope you find the post on how to add Git Bash to Windows Terminal helpful. Thanks for visiting, Cheers!!!

[Further Readings: How to customize Windows Terminal Application |  How to customize Windows Terminal Key Bindings |  How to Install Windows Terminal in Windows 10 |  Important Debugging Shortcuts of Visual Studio 2019 |  How to publish a Blazor Server Application to IIS |  Top 7 Visual Studio 2019 extensions for Web Projects |  The difference in Blazor Server and WebAssembly Application |  Exploring Blazor WebAssembly App Project Structure |  Top 10 Productivity Tips and Tricks in Visual Studio 2019 |  CRUD Operations in WPF using EntityFrameworkCore and SQLite |  How to implement Dependency Injection in WPF |  How to use External Tool in Visual Studio 2019  ]  

I just saw a tweet saying that Windows terminal is now generally available, so I had to give it a try.

After downloading from the store and booting up I realized that only powershell, cmd and wsl are listed by default (and also Azure which I don’t really care about).

Clicking around the UI a little there is a settings menu item that opens a JSON configuration file in notepad. This configuration file defines the behaviours of the terminal including the profiles that can be loaded.

After a bit of searching and documentation reading I came up with this profile which I now use for my git bash installation (I hope it can help you too).

    {
        "guid": "{00000000-0000-0000-ba88-000000000002}",
        "closeOnExit" : "always",
        "commandline" : "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l",
    	"icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
        "name" : "Git Bash",
        "startingDirectory" : "%USERPROFILE%",
        "background": "#012456",
        "acrylicOpacity": 0.8,
        "useAcrylic": true
    }Code language: JSON / JSON with Comments (json)

Some things to note:

  • guid – Randomly generated by me, just needs to be unique in the list of profiles as far as I can tell
  • closeOnExit, always – This needs to be always to actually close git bash panes when multiple panes are displayed side by side. If this is only set to true, on exit, your pane will remain with an exit code which would then need to be closed with another key combination.
  • background, acrylicOpacity, useAcrylic – These all alter the background appearance. I found these values to be the nice mix of readable, but not just boring black.

If you want to set this as your default profile you can also alter the default profile line near the top.

    "defaultProfile": "{00000000-0000-0000-ba88-000000000002}",Code language: JavaScript (javascript)

This should provide you with a new option to open a “Git bash” terminal tab, nicely displaying the git bash / mingw64 logo.

Observations

There is a bug open for automatically adding a git bash profile if git for windows is installed https://github.com/microsoft/terminal/issues/1394. This issue also includes some alternative defaults with more configured options but they don’t appear to be necessary.

Auto config reload seems to work fairly well for most things. if you change the logo path or some styling options the already opened terminal will automatically update.

%PROGRAMFILES% doesn’t appear to work for the icon value? (Hence why it is hardcoded above).

Why on earth are we being forced to edit json in notepad? I’m sure Microsoft could have come up with a pretty little JSON editor? Or at least some validation in the editor?

There are many other profile tweaks that can be done https://docs.microsoft.com/en-gb/windows/terminal/customize-settings/profile-settings

I really miss the “Quake style” that I could use win ConEmu. There is already a task for this too.

  • Add pssnapin отсутствуют оснастки зарегистрированные для windows powershell версии 5
  • Add directory to path windows
  • Add program remove windows 10
  • Add pip to path windows
  • Adbappcontrol exe скачать бесплатно для windows