Last active
December 26, 2016 13:14
-
-
Save ianchanning/c9343a6df917ee36313a to your computer and use it in GitHub Desktop.
Basic windows history and bang commands (assuming Git installed)
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 simple replacement for linux ! syntax e.g. !591 | |
rem usage: ! N (executes line N of history.log) | |
rem @link http://ianchanning.wordpress.com/2014/10/29/dos-command-history/ | |
if "%1"=="" goto Syntax | |
if "%1"=="/?" goto Syntax | |
for /f "tokens=*" %%x in ('sed -n "%1{p;q}" %USERPROFILE%\history.log') do echo %%x & cmd /c %%x | |
goto End | |
:Syntax | |
echo usage: ! N | |
:End |
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 replacement for linux `history` command | |
rem usage: history | |
rem @link http://ianchanning.wordpress.com/2014/10/29/dos-command-history/ | |
set history_file=%USERPROFILE%\history.log | |
rem For if you are using Martin Ridgers 'clink' | |
rem @link http://mridgers.github.io/clink/ | |
rem set history_file=%localappdata%\clink\.history | |
rem this doesn't require GNU Tools, but doesn't have line numbers | |
rem type history_file | |
rem requires GNU Tools installation (e.g. Git SCM) | |
cat -n %history_file% |
I recommend putting these files in the Git bin folder e.g. C:\Program Files\Git\bin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is assuming that you've read my DOS command history post on outputting the DOS commands to
%USERPROFILE%