Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
my doskey macro file (aka alias) for windows (7) command line shell environment
;============================== loading on startup ===============================
;= create a cmd link with the following target :
;= %comspec% /k "(doskey /macrofile=%userprofile%\doskey.mac)"
;============================= File listing enhancements ============================
alias_old=IF ".$*." == ".." (doskey /macros) ELSE (IF /I "$1" == "SAVE" (doskey /macros $g "%USERPROFILE%\doskey.mac" & ECHO Aliases SAVED) ELSE (IF /I "$1"=="LOAD" (doskey /macrofile="%USERPROFILE%\doskey.mac" & ECHO Aliases LOADED & doskey /macros) ELSE (doskey $*)))
alias=IF ".$*." == ".." (doskey /macros) ELSE (IF /I "$1" == "SAVE" (doskey /macros $g "%USERPROFILE%\doskey.mac" & ECHO Aliases SAVED) ELSE (IF /I "$1"=="LOAD" (doskey /macrofile="%USERPROFILE%\doskey.mac" & ECHO Aliases LOADED & doskey /macros) ELSE (IF /I "$1"=="EDIT" (notepad %userprofile%\doskey.mac) ELSE (IF /I "$1"=="EDIT2" (notepad2 %userprofile%\doskey.mac) ELSE (doskey $*)))))
alias_=IF ".$*." == ".." (doskey /macros) ELSE (IF /I "$1" == "SAVE" (doskey /macros $g "%USERPROFILE%\doskey.mac" & ECHO Aliases SAVED) ELSE (IF /I "$1"=="LOAD" (doskey /macrofile="%USERPROFILE%\doskey.mac" & ECHO Aliases LOADED & doskey /macros) ELSE (IF /I "$1"=="EDIT" (notepad2 %userprofile%\doskey.mac) ELSE (IF /I "$1"=="LIST" (type "%USERPROFILE%\doskey.mac") ELSE (doskey $*)))))
;=
;============================= start cl compiler environment ============================
vsx86="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
vsx64="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x64
;=
;============================= media player from command line (yay) ============================
vlc="c:\Program Files (x86)\VideoLAN\VLC\vlc.exe" $*
xmplayadd="C:\programs\xmplay\xmplay.exe" -list $*
xmpc="C:\programs\xmplay\xmpcontrol.exe" $*
;=# rem test=for /f %a in ('dir $* /b') do "C:\programs\xmplay\xmplay.exe" -list %a
;=
;============================= fast access to editors ============================
npp="c:\programs\tools\npp\notepad++.exe" $*
n=notepad $*
n2=notepad2 $*
nc=NotepadCrypt $*
g=gvim $*
pn=C:\programs\tools\programmer.notepad\pn.exe $*
;= guiable diff
wmdiff=c:\programs\tools\WinMerge-2.14.0-exe\WinMergeU.exe $*
;=
;============================= shortcuts and stuff to run from command line ============================
locate="c:\Program Files\Locate\Locate32.exe" $*
torb="%USERPROFILE%\tools\Tor Browser\Start Tor Browser.lnk"
xnview="C:\programs\XnView\xnview.exe" $*
1by1="C:\programs\1by1\1by1.exe" $*
audacity="c:\programs\tools\Audacity\audacity.exe" $*
;============================= fast access to explorer ============================
e=explorer $*
e.=explorer .
eprog=explorer c:\programs
;=
;============================= process thigies like in linux ============================
ps=tasklist $*
kill=taskkill /IM $*
tcpview=C:\programs\system.utils\windows\Tcpview.exe
procexp=C:\programs\system.utils\windows\procexp.exe
;=
;============================= some linux goddies like file ============================
ls=dir /b $*
l=dir /od/p/q/tw $*
mv=move $*
cp=copy $*
rm=del $*
cat=type $*
history=doskey /history
h=IF ".$*." == ".." (doskey /history) ELSE (IF /I "$1" == "SAVE" (doskey/history $g$g %USERPROFILE%\commands.log & ECHO Command history saved) ELSE (IF /I "$1" == "TSAVE" (echo **** %date% %time% **** >> %USERPROFILE%\commands.log & doskey/history $g$g %USERPROFILE%\commands.log & ECHO Command history saved) ELSE (IF /I "$1" == "SHOW" (type %USERPROFILE%\commands.log) ELSE (doskey /history))))
loghistory=doskey /history >> %userprofile%\command_history.log
datime=echo %date:~7,2%-%date:~4,2%_%time:~0,2%-%time:~3,2%
datime2=IF /I %time:~0,1%=="" (echo %date:~7,2%-%date:~4,2%_0%time:~1,1%-%time:~3,2%) ELSE (echo %date:~7,2%-%date:~4,2%_%time:~0,2%-%time:~3,2%)
;=
;============================= map exit to save history ============================
exit=echo **** %date% %time% **** >> %USERPROFILE%\commands.log & doskey/history $g$g %USERPROFILE%\commands.log & ECHO Command history saved, exiting & timeout 3 & exit $*
;=
;============================= some nifty thing got obsolete by internal where cmd ============================
whereis=@for %e in (%PATHEXT%) do @for %i in ($1%e) do @if NOT "%~$PATH:i"=="" echo %~$PATH:i
;=
;============================= open another shell with all the goodies ============================
nifty=start %USERPROFILE%\niftyCMD.lnk
;=
;============================= play a bit with ip stuff ============================
delroute=route delete 0.0.0.0 mask 0.0.0.0 $1
10=c:\programs\bin\setip.cmd $*
dyn=c:\programs\bin\setip.cmd dyn $*
fixroute=IF /I ".$*." == ".." (echo invalid route gw) ELSE (route delete 0.0.0.0 mask 0.0.0.0 & route add 0.0.0.0 mask 0.0.0.0 $1 metric 20)
;=================== get stuff to download ============================
grab=wget -r -np -nc -e robots=off -t 0 -c --timeout 30 --random-wait $*
grabhttps=for /f "delims=: tokens=1,2" %i in ('echo $*') do wget -r -np -nc -e robots=off -t 0 -c --timeout 30 --random-wait http:%j
utubedl=youtube-dl $*
;============================= :end ============================
;= rem ******************************************************************
;= rem * EOF - Don't remove the following line. It clears out the ';'
;= rem * macro. Were using it because there is no support for comments
;= rem * in a DOSKEY macro file.
;= rem ******************************************************************
;=
@ackvf

This comment has been minimized.

Copy link

@ackvf ackvf commented Oct 18, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment