Git-Bash: Difference between revisions

From Omnia
Jump to navigation Jump to search
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 11: Line 11:
</pre>
</pre>


== Bashrc
settings.json : C:\Users\USERNAME\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
%USERPROFILE%\AppData\Local\...\...
%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json


<pre>
    "profiles":
    {
        "defaults":
        {
            "historySize": 10000
        },
        "list":
        [
...
            {
                "commandline": "\"C:\\Program Files\\Git\\bin\\bash.exe\" --login -i",
                "foreground": "#13A10E",
                "guid": "{abc00000-0000-0000-0000-000000000000}",
                "hidden": false,
                "icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
                "name": "Git Bash",
                "startingDirectory": "%HOMEDRIVE%%HOMEPATH%",
                "tabTitle": "Git Bash"
            },
</pre>
GUID anything <ref>https://www.timschaeps.be/post/adding-git-bash-to-windows-terminal/</ref>
== Bashrc ==
Prompt that will update the window title with the path:
<pre>
<pre>
$ cat .bashrc
$ cat .bashrc
PS1="\w\[\033[36m\]`__git_ps1`\[\033[0m\]$ "
# PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
PS1='\[\033]0;GB:$PWD\007\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]$ '
</pre>
 
<pre>
# PS1='\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
# PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
</pre>
</pre>


Default PS1 is:
Default PS1 is:
<pre>
<pre>
\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$
PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
</pre>
 
== Bash Profile ==
 
<pre>
$ cat .bash_profile
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
</pre>
 
If you create a .bashrc without there being a .bash_profile the above .bash_profile will be auto created^:
<pre>
WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.
 
This looks like an incorrect setup.
A ~/.bash_profile that loads ~/.bashrc will be created for you.
</pre>
</pre>



Latest revision as of 21:58, 18 January 2026

Windows Terminal Profile

Name:  Git Bash
Command Line:  "C:\Program Files\Git\bin\bash.exe" --login -i
Starting Directory:  %HOMEDRIVE%%HOMEPATH%
Icon (file):  C:\Program Files\Git\mingw64\share\git\git-for-windows.ico
Tab Tile:  Git Bash

Appearace - Text - Color Scheme - Foreground - Green #13A10E

settings.json : C:\Users\USERNAME\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

%USERPROFILE%\AppData\Local\...\...
%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
    "profiles": 
    {
        "defaults": 
        {
            "historySize": 10000
        },
        "list": 
        [
...
            {
                "commandline": "\"C:\\Program Files\\Git\\bin\\bash.exe\" --login -i",
                "foreground": "#13A10E",
                "guid": "{abc00000-0000-0000-0000-000000000000}",
                "hidden": false,
                "icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
                "name": "Git Bash",
                "startingDirectory": "%HOMEDRIVE%%HOMEPATH%",
                "tabTitle": "Git Bash"
            },

GUID anything [1]

Bashrc

Prompt that will update the window title with the path:

$ cat .bashrc
# PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
PS1='\[\033]0;GB:$PWD\007\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]$ '
# PS1='\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '
# PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '

Default PS1 is:

PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ '

Bash Profile

$ cat .bash_profile
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc

If you create a .bashrc without there being a .bash_profile the above .bash_profile will be auto created^:

WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.

This looks like an incorrect setup.
A ~/.bash_profile that loads ~/.bashrc will be created for you.

Symbolic Links

Requires Elevated Privileges: (or UAC turned off) [2]

export MSYS=winsymlinks:nativestrict
ln -s <target_path> <link_name>

Requires Elevated Privileges:

 cmd /c "mklink /D <link_name> <target_directory>" # For directory symlinks
 cmd /c "mklink <link_name> <target_file>" # For file symlinks

Turn on in Git:

git config --global core.symlinks true
# local only
git config core.symlinks true

---

CqSI8kO.png

ref: https://github.com/orgs/community/discussions/23591