Skip to content
Branch: master
Go to file


cmdEx: Fixes for cmd.exe
Scott Graham <>

cmdEx makes some improvements to cmd.exe. Currently:

- In PROMPT, $M displays git branch information instead of its normal function.
- Suppress "Terminate batch job (Y/N)?" prompt (prompt isn't displayed, and
  the assumed answer is always 'y').
- Improvements to input handling (set CMDEX_NOREADCONSOLE=1 to disable).
    - Alt-Up does "cd ..", maintaining current command.
    - Ctrl-W deletes back a word, Ctrl-Backspace deletes back a path
    - Ctrl-V pastes, with confirmation if there's \n in the text.
    - Alt-Left/Right or browser back/forward navigates like a web browser in
      previously visited directories, maintaining current command.
    - Improved tab completion, in addition to file and directory
      (contextually), built-ins and commands in path are completed, git
      subcommands are completed, and some git subcommands have arguments and
      context-sensitive completion (e.g. "git checkout o<TAB>" might complete
      to "git checkout origin/master"). Target names are also completed for
      the ninja build tool. Environment variables are completed after "set".
    - Ctrl-Enter opens an Explorer window in the current directory.
    - Ctrl-L clears the console and puts the current command at the top of the
    - Ctrl-D at an empty prompt exits the shell.
    - Escape clears the current line
    - Ctrl-A/Ctrl-E are the same as Home/End.
    - Ctrl-Left/Right jump by word
    - Last 1000 commands are saved to %USERPROFILE%\_cmdex_history on 'exit',
      and loaded on startup.
    - Up, Down to move through history, PgUp/F8, PgDown to complete from
      history based on current prefix.
    - Ctrl-U/Ctrl-Home delete to beginning of line, Ctrl-K/Ctrl-End delete to
      end of line.
- Can be added to
    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
  to have it inject into all cmd.exe's. This makes the "Terminate batch job"
  prompt work. (This isn't recommended yet because startup is too slow to have
  it added to every cmd that's run from scripts, etc.)


- There's a crash in Alt-Right sometimes. :( Not sure of repro.
- ninja && somethi<TAB> tries to complete targets, instead of commands.
- Ctrl-V multiline doesn't work properly, and needs tests.
- I keep wanting Ctrl-Del to do something, but I'm not sure what. I think
  delete word to the right.
- Save history more often, and maybe share between instances somehow.
- Ctrl-C should do something for when killing didn't end up at a clean line.
  _CtrlCAbort@0 in cmd traps Ctrl-C right now I think, so we don't get it in
  line editor.
- Dir completion not excluding files?
- Some of the completer code in can move to the lib and be tested.
- Make x64 work (injection, patching, etc.)
- Add an option to automate adding/removing registry entry, and speed up
  startup so that it's fast enough to be reasonable to do so.

cmdEx is currently only known to work on Windows 7, 8, and 8.1, and only when
using the x86 cmd.exe.




Requires: git, cmake, devenv, python in path.

With VS2013 vars:
C:\...\cmdEx>python -u           # -u pulls third_party dependencies


[master]C:\...\cmdEx>type colours.ans
  <confirm you see 16 glorious colours>


- src/cmdEx/subprocess* adapted from

- Integrates ansi32.dll (unmodified) by Jason Hood from

- Similar project, but readline based: Some
  of cmdEx's injection code is based on Clink's.


git branch name in cmd.exe on Windows, and some other enhancements




No releases published
You can’t perform that action at this time.