Intro to Cmder

As a Windows user, now and then, I have to use the Windows CMD to run some simple command. Compared to its Linux counterpart (bash, for example), the Windows CMD is totally disaster: it does not support smart TAB completion, it does not support pipes and it has a dumb UI… Fortunately, there is a tool called cmder which tries to enhance our experience of using consoles on Windows systems. It has a decent UI with many different color themes, support for Linux-style tab completion and more… It is far better than windows CMD.

Installation

Cmder is a combination of several good tools: Conemu, clink and git for Windows. In order to use its full functionality, it is better to install the full version. After download, just extract the zip package into your program folder. Then you can lauch cmder using launch tools such as Listary.

How to Use

Start cmder in a particular directory

Sometimes, we want to start cmder in current directory. We can configure this easily: 1. Open the cmder exectuable as an Administrator 2. Go the directory where cmder is extracted, e.g., D:\Program Files\cmder 3. Execute .\cmder.exe /REGISTER ALL command

Then go to a directory and right click, you will see a contextual menu option Cmder Here (See image below).

keyboard shortcut

Shortcut Description
Ctrl+T or Ctrl+Shift+1 start a new console tab
Ctrl+W close a console tab
Ctrl+R search command history
Win+Alt+P open settings page

Fore more keyborad shortcut, see here.

In order to show Chinese characters properly, we need to set up console to use UTF-8 decoding. Also the font used should support Chinese characters. First we need to set up the font options, as shown below:

Show directories with Chinese characters in their names

In its default setting, cmder can not display directories with Chinese characters in their names as shown below.

This can be easily fixed. Open the setting page, and go to Startup -> Environment, in the text box, use the following setting:

set LANG=zh_CN.utf8

Error message containing Chinese characters

When we are executing some command, the error message from the command may contains Chinese characters, which are not displayed properly: >$ pandoc –pdf-engine=xelatex -V CJKmainfont=KaiTi test.md -o test.pdf
>Error producing PDF.
>! Undefined control sequence.
>l.67 …锟斤拷搴︽湁闂锛屽簲璇ユ妸\textwidth鎹㈡垚

This can be fixed by adding chcp utf-8 or chcp 65001 in the environment settings (see the above setting image). After applying this change, restart cmder and rerun the command, we find that the error message is correctly displayed now: >$ pandoc –pdf-engine=xelatex -V CJKmainfont=KaiTi test.md -o test.pdf
>Error producing PDF.
>! Undefined control sequence.
>l.67 …��度有问题,应该把\textwidth换成

Spurious character is inserted in command prompt when we press up arrow

When we press up arrow “↑” to bring up the history command, then delete the command, we may find that spurious character is inserted at command prompt. This issue is explained more thoroughly here, here and here.

In order to fix it, go to the cmder installation folder, the edit the file vendor\clink.lua.

For older versions of Cmder

Replace the following snippet

if env == nil then
    lambda = "λ"
else
    lambda = "("..env..") λ"
end

with

if env == nil then
    lambda = "$"
else
    lambda = "("..env..") $"
end

For latest versions of Cmder

For the latest version of cmder (version 1.3.8), it seems that this old issue still persists. The clink.lua file have changed. Find the line

local lambda = "λ"

and replace it with

local lambda = "$"

Restart cmder and the problem should disappear.

References