rui lopes notebook

Sane shell environment on Windows

One thing I really hate on Windows is its horrible shell application window, fortunately there is ConEmu (and Console)! couple it with MinGW and Bash and you’ll have a saner command line environment. Here’s how I do it.

Using the MinGW Installation Manager Setup Tool (get the file named like mingw-get-setup.exe; its normally the first link on the page) install MinGW and MSYS into C:\Dev\MinGW.

You can install MinGW and MSYS by selecting the mingw32-base and msys-base packages, then select Apply Changes from the Installation menu.

NB you only really need to install the mingw32-base package if you need the gcc C/C++ compiler toolchain. And even then, you might be better served by tdm-gcc, which has 64-bit compilers.


ConEmu is what the default Windows Command Prompt window should have been. It has at least on feature that I really like, a resizable window!

Install it, then create a Task on the ConEmu settings:

  • Select ConEmu settings
  • Go to the Startup, Tasks node
  • Click the + button to add a new task
  • Call the task MSYS
  • Set Task parameters to:
    /icon "C:\Dev\MinGW\msys\1.0\msys.ico"
  • Add the command to start bash:
    C:\Dev\MinGW\msys\1.0\bin\bash -c "HOME=/c/Users/rgl exec /c/Dev/MinGW/msys/1.0/bin/bash"

    NB replace /C/Users/rgl with your actual home directory.

    NB I’ve set the HOME environment variable too. You might want to set it to $USERPROFILE instead.

    NB You should use a directory without spaces. You can create it as a link with the command cd /c/Users; junction rgl "Rui Lopes" (you must install junction first).

  • Goto to the Startup node on the ConEmu settings and select the MSYS has the specified named task, so ConEmu uses it by default.


Alternatively to ConEmu, you can use Console. To do that, install it, then edit its settings to use same command to start bash as we did with ConEmu.

While you are at it, change the font to Consolas 11pt too.


Setup Bash by creating the .bashrc file (inside your $HOME directory) with the following contents:

# set the window title to our liking; this is run before the prompt is displayed (PS1).
# See
PROMPT_COMMAND='echo -ne "\033]0;${PWD} - Bash\007"'

# start the shell at home

export EDITOR=vim
export PAGER=less
export PS1='\u@\h \w \$ '
export TERM=cygwin

alias l='ls -lF --color'
alias ll='l -a'
alias h='history 25'
alias j='jobs -l'

# add our own paths before all others defined on the system.

export PATH=""
export PATH="$PATH:/c/Dev/MinGW/bin"
export PATH="$PATH:/c/Dev/MinGW/msys/1.0/bin"
# feel free to add more of these PATH modifications here

# finally add the original PATH contents after our own.

Tidy vim settings by creating the .vimrc file with the following contents:

syntax on
set background=dark
set esckeys
set ruler
set laststatus=2
set nobackup

" Usefull setting for working with Ruby files.
autocmd FileType ruby set tabstop=2 shiftwidth=2 smarttab expandtab softtabstop=2 autoindent
autocmd FileType ruby set smartindent cinwords=if,elsif,else,for,while,try,rescue,ensure,def,class,module

" Usefull setting for working with Python files.
autocmd FileType python set tabstop=4 shiftwidth=4 smarttab expandtab softtabstop=4 autoindent
" Automatically indent a line that starts with the following words (after we press ENTER).
autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class

To easily search the command history using your keyboard cursor keys, create the .inputrc file (inside your home directory) with the following contents:

"\e[A": history-search-backward
"\e[B": history-search-forward

Finally, launch ConEmu and install some useful packages:

mingw-get install msys-vim
mingw-get install msys-unzip
mingw-get install msys-wget

You can also get a list of available package with:

mingw-get list | grep Package:

You can later upgrade all the installed packages:

mingw-get update
mingw-get upgrade

Thats it, enjoy!