Skip to content
/ cmdEx Public

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

License

Notifications You must be signed in to change notification settings

sgraham/cmdEx

Repository files navigation

cmdEx: Fixes for cmd.exe
Scott Graham <[email protected]>
-------------------------------------

cmdEx makes some improvements to cmd.exe. Currently:

- In PROMPT, $M displays git branch information instead of its normal function.
- Improvements to input handling (set CMDEX_NOREADCONSOLE=1 to disable).
  Keybindings:
    - Alt-Up does "cd ..", maintaining current command.
    - Ctrl-W deletes back a word, Ctrl-Backspace deletes back a path
      component.
    - 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/main"). 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
      window.
    - 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.


TODO:

- 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.
- Dir completion not excluding files?
- Some of the completer code in dll.cc can move to the lib and be tested.
- 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 11 and using the x64 cmd.exe.
This is on the "main" branch which is the current development branch.

The last x86 version (any time before 2024) worked on Windows 7, 8, 8.1, and 10,
and only when using the x86 cmd.exe. This is still available on the old
"master" branch.


Run:

C:\...\cmdEx>out\cmdEx
[main]C:\...cmdEx>


Build:

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

With VS2022 vars:
C:\...\cmdEx>python sng.py -u           # -u pulls third_party dependencies
C:\...\cmdEx>third_party\ninja\ninja


Test:

C:\...\cmdEx>out\tests
C:\...\cmdEx>python test.py
C:\...\cmdEx>new
[main]C:\...\cmdEx>exit




Acknowledgements:

- src/cmdEx/subprocess* adapted from http://github.com/martine/ninja/.

- Similar project, but readline based: http://code.google.com/p/clink/. Some
  of cmdEx's injection code is based on Clink's.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published