Git bash notes

From raju

Note:- This page will be migrated to Once that is done, it will be deleted.

install additional software in git bash

install software directly under /

This installs the tree package directly under /.

Download the xz file

    mkdir -p ~/x/software
    cd ~/x/software
    curl --output tree-1.8.0-1-x86_64.pkg.tar.xz

Check the files in the archive

    tar tf tree-1.8.0-1-x86_64.pkg.tar.xz

The next step will copy (and overwrite) these files to /.

    tar xJvf tree-1.8.0-1-x86_64.pkg.tar.xz -C /

To uninstall, get a sense of files that will be deleted

    cd /
    tar tf ~/x/software/tree-1.8.0-1-x86_64.pkg.tar.xz | xargs ls -1d 2> /dev/null

Delete the files

    tar tf ~/x/software/tree-1.8.0-1-x86_64.pkg.tar.xz | xargs rm

Check the files that are not deleted (ex:- directories with files from other packages)

    tar tf ~/x/software/tree-1.8.0-1-x86_64.pkg.tar.xz | xargs ls -1d 2> /dev/null

install rsync 3.1.3-1 into a non standard directory

configure zsh installed in a non standard directory

Prerequisite: Install zsh into /opt/software/zsh by following install software into a non standard directory

Add this to ~/.bashrc so you can start zsh from bash shell

    # For zsh
    export PATH=/opt/software/zsh/usr/bin:$PATH

Add this to ~/.zshenv

    # Ref:-
    export MODULE_PATH=/opt/software/zsh/usr/lib/zsh/5.7.1:$MODULE_PATH
    # You should not export the $FPATH parameter. It is only needed by the
    # current shell process and not by any of its children.
    # Ref:-

Add this to ~/.zshrc

    export PS1="%n@%m:%d $"


default font used by git bash

Lucida Console, 9-point

To use this in gvim

    set guifont=Lucida_Console:h9:cANSI

Note: Previously, I used

    set guifont=Lucida_Console:h9:cANSI:qDRAFT

Afterwards, find out what the :qDRAFT option at the end does.

PS1 in git bash

    # By default git bash sets the bash prompt to
    # $ echo $PS1
    # \[\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$
    # which makes the system very slow. Change it to make it faster.
    export PS1='\[\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[0m\]\n$'


vim and gvim

    # for gvim
    # I want to use gvim custom installed in /c/Program\ Files\ \(x86\)/Vim/vim80/gvim.exe
    # and vim that comes with git bash (/usr/bin/vim).
    # There is no gvim in git bash. The vim in 
    # /c/Program\ Files\ \(x86\)/Vim/vim80/ cannot be run from git bash as it gives
    #   Vim: Error: This version of Vim does not run in a Cygwin terminal
    # As a work around add /c/Program\ Files\ \(x86\)/Vim/vim80 to the end of the
    # path.
    export PATH=$PATH:"/c/Program Files (x86)/Vim/vim80"

always background gvim

By default when gvim is run from git bash, the command prompt does not return. One way around this is to add '&' to background the job. But I always forget to do that. To work around this, I have the following in ~/.bashrc so gvim commands are always backgrounded.

    # Always background gvim
        abs_gvim=`which gvim`
        "$abs_gvim" "$@" &


This will break if gvim were to read from standard input (for example output of svn diff piped to gvim -). For that

    svn diff | "`which gvim`" - &

python setup

To pickup python installed via Anaconda, add the following lines to ~/.bashrc

    # Python setup
    export PATH=/c/ProgramData/Continuum/Anaconda/envs/py36:/c/ProgramData/Continuum/Anaconda/envs/py36/Scripts:$PATH
    alias python='winpty python.exe'
    alias python3="winpty python.exe"
    alias python2="winpty /c/ProgramData/Continuum/Anaconda/python.exe"
    # run programs with winpty
        winpty "$@"

Here conda installed python2 by default and I have a py36 environment for Python 3.6.

/c/ProgramData/Continuum/Anaconda/envs/py36 is used to pick up python 3 executables.

/c/ProgramData/Continuum/Anaconda/envs/py36/Scripts is used to pick up utilities such as csvsql from csvkit package.

See also:


To set it on the command line

    PYTHONPATH='C:/path/to/foo' python -h

To set it in a script

    #! /usr/bin/env bash
    export PYTHONPATH="C:/path/to/foo;$PYTHONPATH"

Sample bash script to run python

    #! /usr/bin/env bash
    export PYTHONPATH="C:/path/to/utils;$PYTHONPATH"
    C:/ProgramData/Continuum/Anaconda/python.exe C:/path/to/ --arg foo

open multiple websites in chrome

launch a git bash session form another git bash session

    $ winpty /c/Program\ Files/Git/Git\ Gui/git-bash.exe

website to download git for windows

debug slowness

    $time echo $(__git_ps1)

git bash terminal as admin

In Windows Server 2012R2

    Start menu -> down arrow button -> scroll to "Git Bash" icon" -> Right click on it -> Run as administrator

download git bash