.cmd/.bat tools:
wrt.bat
Code: Select all
@echo ctrl+z = save and exit
@echo ctrl+c = just exit
@echo ======================
@echo off
set arg1=%1
copy con %arg1%
ren *. *.txt
-In case you didn't specify a file extension, it will default to .txt.
-Good for making short config files, readmes, batch files, dummies, etc.
-It will always replace existing files, so be careful.
-Name is short for WRiTe, because w,r and t are close on the keyboard
memo.bat
Code: Select all
@echo ctrl+z = save and exit
@echo ctrl+c = just exit
@echo ======================
@echo off
set arg1=%1
copy con %USERPROFILE%\Dropbox\memos\%arg1%
ren *. *.txt
Hotkeying cmd.exe (and other utils)
AFAIK there's no direct hotkey to cmd. However, i've pinned it to my taskbar. All pinned programs (ranging 1-10) are accessible via the windows key. So in my case, i've got cmd on win+1, calc on win+2, notepad on win+3 and so on. That's just that little bit more convenient than accessing it indirectly via win-x or win-r to make me use it more.
Aliasing often-used folders and commands
Windows' inherent type commands for accessing certain folders are awkward. You can for example run cmd.exe, type cd %APPDATA% and hit enter. But that's too slow. Or you could hit win+r, type shell:personal, hit enter to get the document folder of the current user (what an inconsistent mess!). Regardless which way, you'd need to regedit to add custom options, afaik. Boo. Well, you can set up junctions, hardlinks, etc, but i found the following more lean and flexible:
What i use (took up this cue from stack overflow) is having one single main batch file in my dropbox folder (%USERPROFILE%\\Dropbox\\env\\main.bat to be specific)
Then, in regedit \ HKEY_CURRENT_USER \ software \ microsoft \ command processor, create a new string value:
Value: AutoStartRather than keeping all my stuff in a batch folder and adding a path to the %path% variable, this makes my preferences easily portable from account to account, from computer to computer.
Data: %USERPROFILE%\\Dropbox\\env\\main.bat
This is what my main.bat looks like.
Code: Select all
@echo off
:: set start folder
cd c:\
:: =====================
:: set temporary paths for quick-start programs
:: =====================
set PATH=C:\Program Files (x86)\Google\Chrome\Application\;%PATH%
set PATH=C:\Program Files (x86)\Notepad++\;%PATH%
:: =====================
:: quick runs
:: =====================
DOSKEY np=notepad $*
DOSKEY npp=notepad++ $*
:: =====================
:: quick lists
:: =====================
:: ---------------------normal, wide, page view
DOSKEY ls=dir /b $*
DOSKEY lsw=dir /w $*
DOSKEY lsp=dir /b /p $*
:: ---------------------list by date (oldest to newest)
DOSKEY lsd=dir /od $*
:: ---------------------list by extension
DOSKEY lex= dir /b /oe $*
:: =====================
:: filtered ls
:: =====================
:: ---------------------folders only
DOSKEY lsf= dir /b /ad $*
:: ---------------------non-folders only
DOSKEY lsnf= dir /b /a-d $*
:: ---------------------archives only
DOSKEY lsa= dir /b /aa $*
:: =====================
::sorted dirs
:: =====================
:: ---------------------useful for detecting 0 byte files/corrupt files; ignores folders
DOSKEY dir0= dir /a-d /o-s $*
:: ---------------------dir sorted by date (oldest to newest)
DOSKEY dird= dir /od $*
:: =====================
:: change directory, then auto-ls
:: =====================
DOSKEY cdl=%USERPROFILE%\Dropbox\env\cdl.bat $*
:: ---------------------same, but only list directories
DOSKEY cdd=%USERPROFILE%\Dropbox\env\cdd.bat $*
:: ---------------------same, but only list files/nondirectories
DOSKEY cdnf=%USERPROFILE%\Dropbox\env\cdnf.bat $*
:: ---------------------same, but only list archives
DOSKEY cda=%USERPROFILE%\Dropbox\env\cda.bat $
:: =====================
:: various bash substitutes
:: =====================
DOSKEY grep=findstr $*
DOSKEY diff=fc $*
DOSKEY rm=del $*
:: =====================
:: Command line text editor substitute suite
:: =====================
DOSKEY wrt=%USERPROFILE%\Dropbox\env\wrt.bat $*
DOSKEY memo=%USERPROFILE%\Dropbox\env\memo.bat $*
DOSKEY lsmem=%USERPROFILE%\Dropbox\env\lsmem.bat $*
DOSKEY mvmem=%USERPROFILE%\Dropbox\env\mvmem.bat $*
DOSKEY memos=cd %USERPROFILE%\Dropbox\memos\$*
:: =====================
:: Common directories
:: =====================
DOSKEY dropbox=cd %USERPROFILE%\Dropbox\$*
DOSKEY desktop=cd %USERPROFILE%\Desktop\$*
DOSKEY documents=cd %USERPROFILE%\Documents\$*
DOSKEY downloads=cd %USERPROFILE%\Downloads\$*
DOSKEY assembler=cd c:\cc65\$*
DOSKEY nesdev=cd %USERPROFILE%\Documents\NESDEV\$*
:: =====================
:: abbreviations of the former
:: =====================
DOSKEY cdrop=cd %USERPROFILE%\Dropbox\$*
DOSKEY cdesk=cd %USERPROFILE%\Desktop\$*
DOSKEY cdoc=cd %USERPROFILE%\Documents\$*
DOSKEY cdown=cd %USERPROFILE%\Downloads\$*
DOSKEY ccc=cd c:\cc65\$*
DOSKEY cnd=cd %USERPROFILE%\Documents\NESDEV\$*
DOSKEY cenv=cd %USERPROFILE%\Dropbox\env\$*
:: =====================
:: misc
:: =====================
:: ---------------------open current directory in win explorer
DOSKEY open=start .
:: ---------------------edit this batch file.
DOSKEY setalias=notepad %USERPROFILE%\Dropbox\env\main.bat
:: --------------------- playground folder
DOSKEY ctest=cd %USERPROFILE%\Documents\temp\
One caveat is that this .bat runs once every time you'd start a new cmd.exe instance - but with no complex commands being made, it takes no time at all.
Other tips
Working with the cmd.exe has become much more enjoyable and quick this way. Especially with the window size hotkeys:
win+left, win-right (left and right half of screen), win+up (maximize), win+down (minimize).
What's you best tips using cmd.exe, .bat/.cmd files, etc, for making windows usage quicker/more convenient?
(edit: fixed various typos)