Windows Command Line – Bash History-like Feature for Windows Command Prompt

command linewindows

I'm looking for a Command Prompt alternative that supports handy features of Linux Terminal, like

  • Keeping history of Commands and accessing them using Up-Arrow key.
  • Logging commands in the file (like: .bash_history).
  • Ability to resize command window.
  • Allowing to use Ctrl+C and Ctrl+V to copy/paste content.

I went through Console, but I wonder if it supports anything beyond tweaking its UI. I'm more expecting the prompt to keep history of commands so that I don't have to enter them every time.

Best Answer

the old thing is called 'doskey'. it is in fact quite a familiar sight for us old buddies...

check out its help page:

C:\Users\bubu>doskey /?
Edits command lines, recalls Windows commands, and creates macros.

DOSKEY [/REINSTALL] [/LISTSIZE=size] [/MACROS[:ALL | :exename]]
  [/HISTORY] [/INSERT | /OVERSTRIKE] [/EXENAME=exename] [/MACROFILE=filename]
  [macroname=[text]]

  /REINSTALL          Installs a new copy of Doskey.
  /LISTSIZE=size      Sets size of command history buffer.
  /MACROS             Displays all Doskey macros.
  /MACROS:ALL         Displays all Doskey macros for all executables which have
                      Doskey macros.
  /MACROS:exename     Displays all Doskey macros for the given executable.
  /HISTORY            Displays all commands stored in memory.
  /INSERT             Specifies that new text you type is inserted in old text.
  /OVERSTRIKE         Specifies that new text overwrites old text.
  /EXENAME=exename    Specifies the executable.
  /MACROFILE=filename Specifies a file of macros to install.
  macroname           Specifies a name for a macro you create.
  text                Specifies commands you want to record.

UP and DOWN ARROWS recall commands; ESC clears command line; F7 displays
command history; ALT+F7 clears command history; F8 searches command
history; F9 selects a command by number; ALT+F10 clears macro definitions.

The following are some special codes in Doskey macro definitions:
$T     Command separator.  Allows multiple commands in a macro.
$1-$9  Batch parameters.  Equivalent to %1-%9 in batch programs.
$*     Symbol replaced by everything following macro name on command line.

C:\Users\bubu>

it doesn't keep the history in a file though, you can of course use doskey /history >file and stuff to do that, but it is not as automated as bash. ctrl-c generates interrupt and thus is not used in consoles. even xterm wouldn't allow that. (xterm uses mouse select as copy and right click as paste, for the matter)

alternatively, you can use cygwin and use bash instead... it also runs on windows.

Related Question