Improving Command Prompt
In the previous chapter we've learned how to enable Unicode characters in the Command Prompt and how to create and change environment variables with the emphasis on the system path. Before we explore all “secrets” of installing Ruby on Windows we will make few more improvements in the Command Prompt.
Every new Command Prompt on Windows is opened as new window. It is quite impractical if you need to open several Command Prompts. Linux and OSX users have benefit because in one terminal window they can open shells as multiple tabs which makes work in the shell much more comfortable.
There are few applications that can help us working same way on Windows. We will skip commercial ones and focus only on the Open Source solution. Throughout this book we will use conemu-maximus5.
ConEmu has a lot of options which help you customize it to your needs. Besides background and foreground colors, fonts and other visual customizations you can define hot keys for opening new tabs, switch between them, activating specific tab and many more which we will not discuss here. But one option deserves more attention. Tasks section under Startup group in Settings dialog is used to define which shell will be opened in tabs. ConEmu comes with number of predefined values, but you can define new to use Cygwin or MSYS bash shells. This will come in handy later when we install Git and DevKit. There is only one more improvement remaining.
Command Prompt on Windows is capable of displaying colored text, but Microsoft's implementation differs from standard used on Linux and Mac OS so ANSI color codes, which are used in all Ruby extensions, are not interpreted correctly. For a long time win32console extension was used on Windows platforms for converting ANSI color codes in the form Command Prompt understands. Although it did great job at the time and most of extensions were able to use win32console, it had one drawback – slowness.
Instead of win32console we will use ANSICON (GitHub Project), application that hooks into cmd.exe
process on Windows, parses ANSI color codes and converts them so Command Prompt can display colored output. ANSICON comes as Zip archive. In order to install it you have to unpack it to some folder on your path. There are few ways ANSICON can be used. If ansicon.exe is just executed, new command processor (typically cmd.exe
) is started. With option -p
ANSICON hooks in the current Command Prompt and recognition of ANSI escape sequences is enabled. If you want ANSICON to be enabled whenever you start new Command Prompt you should invoke it with:
ansicon -i or
ansicon -I
The first command adds ANSICON to the AutoRun
registry value for current user and the second for local machine.