MS-DOS Commands :: doskey
Displays a history of previously entered commands (similar to the history command in Linux). It also enables you to create command macros.
Press the following keys to navigate the history:
- Up arrow: Recall older commands.
- Down arrow: Recall newer commands.
- Esc: Stop recalling and clear the command line.
- F7: Display history in popup. Arrow keys to scroll; Enter to select
- Alt-F7: Immediately erases command history.
- F8: Search history (e.g.: type copy then F8 for commands starting with copy). F8 again to find next.
doskey macro = text
Creates a command macro named macro and sets its value to text. After the macro is defined, you can run that macro simply by typing its name at the command prompt and pressing Enter. Note: Spaces before/after the = character are optional.
The text can contain the following special meaning characters:
- $* : Equals verything on the command line after the macro name.
- $1, $2, ... $9 : Batch parameters. Similar to %1-%9 in batch files.
- $T : Command separate to allow multiple commands in one macro.
doskey ls = dir /w /o:ne $*
Creates a macro command named ls that displays a wide directory listing sorted by filename and filename extension (this is similar to the Linux ls directory listing command). If you type ls then a listing of the current directory is display; if you type
ls directorythen a listing of the specified directoy is displayed; if you type ls *.txtthen a listing of all .txt files in the current directory is displayed.
doskey = dir /w /o:ne $*
The following examples demonstrate some of the more useful options of the doskey command. For the complet list of options, type
doskey /?or help doskey
Displays the history.
Displays the defined macros.
Restarts the doskey program. As a sideeffect, erases the command history as well as the defined macros. If you find that doskey has stopped responding to history keys (e.g.: up/down arrow keys) then simply restart it with this command option.
Edits command lines, recalls Windows XP 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.
(Enlarge: help doskey)