Last active
December 29, 2017 16:37
-
-
Save joshschmelzle/bf5c92d39c91aace7afadd2149d7cb12 to your computer and use it in GitHub Desktop.
doskey macro loader for win32 systems
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 | |
cd C:\ | |
REM This batch file loads up doskey macros from a file. | |
REM Additionally it displays a random quote from a file to inspire the reader. | |
REM ::: MACROS START ::: | |
title Free Your Mind %1 | |
REM Create a .bat or .cmd file with your DOSKEY commands. | |
REM Run regedit and go to HKEY_CURRENT_USER > Software > Microsoft > Command Processor. | |
REM Add String Value entry with the name AutoRun and the full path of your .bat/.cmd file. | |
REM For speed, load macros from another file rather than using DOSKEY | |
echo started loading macros at %time%. | |
REM Load the macros | |
doskey /macrofile=C:\Josh\dev\bin\doskey_macros.txt | |
echo finished loading macros at %time%. | |
echo construct ready. | |
REM ::: MACROS END ::: | |
REM ::: RANDOM QUOTE START ::: | |
echo digging up a quote. | |
setlocal EnableDelayedExpansion | |
set "file=C:\Josh\dev\bin\doskey_quotes.txt" | |
set /A i=0 | |
for /F "usebackq delims=" %%a in ("%file%") do ( | |
set /A i+=1 | |
rem call echo %%i%% | |
call set quote[%%i%%]=%%a | |
call set n=%%i%% | |
) | |
rem Get the index of a random element | |
call :getRandomElem r= | |
REM Check if a variable is defined and echo output | |
REM IF DEFINED r (ECHO r IS defined) ELSE (ECHO r is NOT defined) | |
REM IF DEFINED n (ECHO n IS defined) ELSE (ECHO n is NOT defined) | |
REM Display every element in the array | |
REM for /L %%i in (1,1,%n%) do (call echo %%quote[%%i]%%) | |
REM Selecting a single element | |
REM call echo(%%quote[7]%% | |
REM Select a "random" element | |
call echo(%%quote[!r!]%% | |
REM ::: RANDOM QUOTE END ::: | |
REM ^ is the escape character. e.g. ^\ ^& ^| ^> ^< ^^ | |
REM ASCII art | |
echo __ _ | |
echo / _^| (_) | |
echo ^| ^|_ ___ _ __ ___ ___ _ ___ _ __ ___ ___ | |
echo ^| _/ _ \^| '__^| / __^|/ __^| ^|/ _ \ '_ \ / __/ _ \ | |
echo ^| ^|^| (_) ^| ^| \__ \ (__^| ^| __/ ^| ^| ^| (_^| __/_ | |
echo ^|_^| \___/^|_^| ^|___/\___^|_^|\___^|_^| ^|_^|\___\___(_) | |
goto :EOF | |
rem Get the index of a random element greater than 0 from gameID array | |
:getRandomElem r= | |
rem I have no idea why, but duplicating this line gets me the result I want. | |
set /A r = n * %random% / 32768 + 1 | |
set /A r = n * %random% / 32768 + 1 | |
if !quote[%r%]! equ 0 goto getRandomElem | |
exit /B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample quotes: