Git 2.5.1’s bash console doesn’t open python interpreter

The MinTTY terminal that is the new default terminal for Git simply doesn’t support Windows console programs. I don’t know why the decision was made to change the default terminal, but I know a few ways to work around this:

  1. Write a Bash alias to launch python with winpty

Bash Alias (put in your .bashrc):

alias python=winpty py.exe

Note: As of Git for Windows 2.7.1, Winpty is included out of the box. winpty can be found installed at Git\usr\bin.


  1. Write a Bash alias to launch python in interactive mode if there are no arguments:

Bash Alias (put in your .bashrc):

function maybe_py() {
    if [ $# -eq 0 ]; then
        /c/Windows/py.exe -i
    else
       /c/Windows/py.exe $@
    fi
}

alias python=maybe_py

  1. Launch python in interactive mode explicitly

Note that this may not work correctly using arrow keys to browse command history:

py -i

Or for scripts:

py script.py

What Is py.exe?

In case you are wondering why I’m referencing C:\Windows\py.exe instead of a particular python.exe installation, I wanted to explain a few benefits of using it (the Python Launcher for Windows:

  • It’s installed with newer installations of Python (Python 3.3+)
  • It understands and attempts to use the specified installation of python in shebang lines
  • It works with Virtual Environments (shebang line example for venv)

For changing your preferred/system installation (e.g. for interactive mode), see this answer.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)