Skip to content

Instantly share code, notes, and snippets.

@MVoz
Forked from retorillo/history.bat
Created April 1, 2018 17:54
Show Gist options
  • Save MVoz/30c53716970fbdaf0f047a78cf57bca4 to your computer and use it in GitHub Desktop.
Save MVoz/30c53716970fbdaf0f047a78cf57bca4 to your computer and use it in GitHub Desktop.
@echo off
setlocal
for /F %%a IN ('echo %1^|findstr /R ^[0-9][0-9]*$') DO set arg1num=%%a
IF "%1"=="%arg1num%" (
doskey /history | findstr /N /R .* | findstr /B %1: > %TEMP%\__history.tmp
FOR /F "delims=: tokens=1*" %%a IN (%TEMP%\__history.tmp) DO @echo %%b
) ELSE (
IF "%1"=="" (
doskey /history | findstr /N /R .*
) ELSE (
doskey /history | findstr /N /R %1
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment