Created
June 19, 2023 02:22
-
-
Save DanEdens/efbc1d5aa9f2135bac14d9971ef7ebe4 to your computer and use it in GitHub Desktop.
Windows persistent aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
@REM autorun.reg | |
@prompt $m$p$g | |
@REM Windows Registry Editor Version 5.00 | |
@REM [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] | |
@REM "Autorun"="%sourcefile%" | |
@REM or in 1 line | |
@REM reg add "HKCU\Software\Microsoft\Command Processor" /v Autorun /d ^%sourcefile^% /f | |
@REM setx sourcefile %userprofile%/.rc.cmd | |
@echo OFF | |
goto:load | |
goto:EOF | |
@REM terminal update and now if running as terminal, doesnt load macros to the correct shell. rip. Hardcoded skip check and run load than eof above. | |
IF /I "%macrosloaded%" EQU "1" ( | |
set _tail=%* | |
call set _tail=%%_tail:*%1 =%% | |
IF "%~1" == "" ( | |
goto:eof | |
) ELSE IF "%~1" == "add" ( | |
goto:add | |
) ELSE IF "%~1" == "grep" ( | |
GOTO:grep | |
) ELSE IF "%~1" == "edit" ( | |
GOTO:edit | |
) | |
) ELSE ( | |
goto:load | |
) | |
:add | |
echo "%_tail%" appended to doskey. | |
echo This method is subject to delimitor conflicts | |
echo "%_tail%" >> "%userprofile%/.doskey" | |
goto:eof | |
:grep | |
doskey /macros:all|grep -i %_tail% | |
goto:eof | |
:edit | |
call %editor% "%sourcefile%" | |
goto:eof | |
:load | |
Doskey /macrofile="%userprofile%\.doskey" | |
set macrosloaded=0 | |
goto:eof | |
:new | |
echo Opening doskey file in %editor% | |
%editor% -w "%userprofile%\.doskey" && goto:load || goto:eof | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment