A more powerful console on Windows


Gitportable

For the techies who like working (or have/need to work) on both Windows and GNU Linux, it's often a challenge to find tools that are available on both platforms or to even find a similar tool. It helps carrying over the work flow you are used to between different platforms.

Consoles on GNU Linux are commonly available. But what about Windows? And no, who cares is not the right answer fa-smile fa-2x green

There are more options then presented here, but I will only write about those I have experience with.

cmd

The Windows command line is limited but does allow you to customize its look and feel a bit. Changing fonts, font-size, background and text colour, window dimensions and buffer size are the most commonly changed settings.

Windows cmd

Changing the font

Go to Settings > Font to choose a new font. I find that a good console font is one that has even width for all the characters. Such a font is called a MonoSpace font. By default Windows comes with only 2 such fonts: Courier New (as of Windows 3.1) and Lucida Sans Typewriter.

Windows cmd - Font

To add more and better Monospace fonts, see this section adding-fonts Since I write a lot of documentation in rst format, a Monospace font is necessary to prevent errors in underlining etc..

Width and buffer

The buffer is used to remember a number of lines displayed in the console. Very useful when you have commands that produce a lot of output.

Further, you can increase the dimensions of the console window.

Windows cmd - Width and buffer

Colours

The final settings have to do with the background and text color. Set them and see what you end up with.

Windows cmd - Colours

The end result is a basic console, with a new font and colours.

Windows cmd - Final result

While slightly more fun than a standard console, you still don't have a lot of possibilities.

mintty

GitPortable - Standard view
One of the tools I often use when on Windows is GitPortable. It allows the use of Git from a command line on Windows. However, the console is also nice to use. If you dig deeper, you'll see it's a console program called "mintty". According to the site "Mintty is a terminal emulator for Cygwin, MSYS or Msys2, and derived projects, and for WSL.".


GitPortable - Standard view

To make it work on Windows, GitPortable uses the MinGW environment and MSYS. MinGW stands for "Minimalist GNU for Windows". To quote the site: "It is a minimalist development environment for native Microsoft Windows applications. Primarily intended for use by developers working on the native MS-Windows platform, but also available for cross-hosted use." It allows users to use GNU software on the Windows platform.

The 2nd component GitPortable uses to make mintty work, is MSYS. Again, quoting the site: "MSYS, a contraction of 'Minimal SYStem', is a Bourne Shell command line interpreter system. Offered as an alternative to Microsoft's cmd.exe, this provides a general purpose command line environment, which is particularly suited to use with MinGW, for porting of many Open Source applications to the MS-Windows platform; a light-weight fork of Cygwin-1.3, it includes a small selection of Unix tools, chosen to facilitate that objective."

If you install GitPortable, MSYS, MinGW and mintty will be set-up for you. As with the Windows command line tool, you can also customize some settings.

Looks

In the options, Looks let you customize the background and text colour, as well as the cursor. It has a button colour scheme designer that takes you to a site where you can try out and see the different colour settings.

mintty

Text

The option "Text" allows you to customize the font and font size. As mentioned earlier, I like to use a Monospace fonts but depending on your usage, other fonts will do just fine.

There are more options, try and see what they do.

After customizing mintty, you might wonder where the program keeps these settings. Since GitPortable uses MinGW, you also have a home directory. That directory usually contains the personal settings of the software you use, in this case this could be bash (via .bashrc), git (.gitconfig), mintty (.minttyrc), vim (.vimrc) and more. Opening the .minttyrc file you would see something like this.:

BoldAsFont=no
FontHeight=10
BackgroundColour=38,38,38
ForegroundColour=217,217,217
CursorColour=217,217,217
Black=0,0,0
BoldBlack=38,38,38
Red=184,122,122
BoldRed=219,189,189
Green=122,184,122
BoldGreen=189,219,189
Yellow=184,184,122
BoldYellow=219,219,189
Blue=122,122,184
BoldBlue=189,189,219
Magenta=184,122,184
BoldMagenta=219,189,219
Cyan=122,184,184
BoldCyan=189,219,219
White=217,217,217
BoldWhite=255,255,25

Note

Be careful when dealing with such files with a leading period. On GNU Linux those files are common but when using Windows you want to handle these files through mintty / GitPortable instead of via an Explorer or whatever. If you try to create a dot file on Windows via Explorer, you will get an error. No biggie, just use mintty or another console capable of handling such files.

Now you have a great console in Windows capable of running GNU Tools. But what if you want to manage a Windows console, mintty, Powershell all from the same tool? That's where ConEmu comes in.

ConEmu

ConEmu according to the site: "ConEmu-Maximus5 is a Windows console emulator with tabs, which presents multiple consoles and simple GUI applications as one customizable GUI window with various features."

ConEmu main window

The nice thing about ConEmu is that it allows you to start different consoles and more from 1 interface. If you plan on using mintty, you still need GitPortable or a mintty standalone to do so.

If you have GitPortable installed, you can create a new task in ConEmu. Add a task GitPortable. The console used will be mintty.

Open the settings of ConEmu.

ConEmu settings

On the left, under Startup choose Tasks. Click on the plus sign to create a new task.

ConEmu create task

Give the task a fitting name instead of the "Groupxy" name. Since we are going to create a task for GitPortable I shockingly named the task GitPortable.

Task parameters, where D is the drive I installed GitPortable on:

/dir "D:\Programs\GitPortable\" /icon "D:\Programs\GitPortable\App\Git\usr\share\git\git.ico"

Following command sets some environment variables. I use them to start mintty and use the GitPortable home as home directory. I also have a portable Python installed. Since I want to run Python from there, I also added the path to the Python executable. The command is 1 big line. For display reasons, I've put the command in several lines:

"set PATH=D:\Programs\WinPython\python-3.6.3.amd64;%PATH%" &
"set HOME=Data/home" & "set USERPROFILE=Data/home" & "set HOMEDRIVE=D:" &
"set PYTHONHOME=D:\Programs\WinPython\python-3.6.3.amd64" &
"D:\Programs\GitPortable\App\Git\usr\bin\mintty.exe - -new_console:d:D:\Programs\GitPortable"

Now you can start a GitPortable console in ConEmu by clicking on the dropdown menu next to the plus sign in the main menu.

ConEmu Start Task

If you are running other processes from ConEmu, there is an option to attach the GUI to ConEmu. Afterwards, you can attach the console to ConEmu. (Windows key, Shift - G).

bashrc

If you want to customize the console prompt presented by mintty, you can edit the .bashrc file in the home directory. Since it's on GitPortable, there will already be some customizations for git. Edit the GitPortable .bashrc. I changed the prompt like this:

...
PS1="\[$COLOR_WHITE\]\n[\w]\n"  # full path of pwd
PS1+="\u@\h\n"
PS1+="\[\$(git_color)\]"        # colors git status
PS1+="\$(git_branch)"           # prints current branch
PS1+="\[$COLOR_YELLOW\]\$\[$COLOR_RESET\] "   # '#' for root, else '$'

export PS1

Another nice one to add to .bashrc is a way to set the terminal title. If you want to be able to do this, add this to the end of the file:

...
# XTERM TITLE
export XTERM_TITLE=$USERNAME@$HOSTNAME
PROMPT_COMMAND='echo -ne "\033]0;${XTERM_TITLE}\007"'
function xtitle ()
{
    export XTERM_TITLE="$@"
}

Adding fonts

To add fonts, you need to download the font files. Some fonts I like for use in GitPortable, cmd and Notepad++ (monospaced fonts):

  • PT Mono
  • Consola (console)
  • saxMono
  • Space Mono

Visit the websites in the Links section and download the fontfiles. After unzipping (if necessary) the font files, you need to install them. To do this, right click on the font file and choose install.

Install Fonts