Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

Doskey CLI Persistence

If you need to have history and aliases like .bashrc, but on windows terminal, and have it persistent on every shell, and every boot, you can do the following:

  • Create a Registry key that calls a .cmd file every time terminal starts
  • In that .cmd file, add some doskey aliases

AutoRun.reg

You can either right click the HKCU\Software\Microsoft to add a new key and value, or you can save this as a .reg then import it:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"AutoRun"="C:\\Users\\User\\cmdrc.cmd
"

cmdrc.cmd

Notice that special characters like > and & are escaped with a ^, and you can have as many aliases as you like.

@echo off
@REM need cli persistence?  doskey /macros to see all
doskey exit=doskey /history ^>^> %USERPROFILE%\cmdhistory.log $T exit $*
doskey history=type %USERPROFILE%\cmdhistory.log

REM another I use
doskey grim=cd /d D:\sites\site.grimoire.jamesfraze ^&^& hugo server --noHTTPCache --disableFastRender --port=1313