Declined History: show in which directory a command has been typed.

May 20, 2009
I would like to see in the history also the directory in which I was working when I typed a command.
For example, now in the history log I can find that I typed a command such as "erase filename".
But it was in the test directory and so I removed just a test file, or it was in a very important directory?

Thank You very much and regards

Rodolfo Giovanninetti

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
And what would you see when you recalled a command with up-arrow?
Just the command.

I don't see any reason why the history mechanism couldn't save the current directory along with each command. I think it would eat memory, though. Users are able to delete history entries, so it wouldn't be as simple as just having a null "ditto" entry for commands where the CWD hasn't changed.
May 20, 2008
Syracuse, NY, USA
I don't remember ever wanting to know the CWD when a command from the past was executed. And I don't want see that every time I open the history popup. It's easy enough to save that info (see below) but I'd expect to have to do a little work to see it. You can ...

Make a history log.

and use
alias pre_exec `echo CWD: %_cwd >> h:\4NTLogs\history.log`

You can always go back and see where you were when you did something.

v:\> tail h:\4NTLogs\history.log
CWD: V:\
cdd g:\tc24
CWD: G:\tc24
cdd c:\
CWD: C:\
CWD: V:\
echo foo
CWD: V:\
tail h:\4NTLogs\history.log
May 20, 2008
Syracuse, NY, USA
And if you really wanted it in the history recall, you could use something like one of these.

alias pre_exec `history /a CWD: %_cwd`

alias pre_exec `if "%_cwd" != "%cwdlast" (history /a CWD: %_cwd & set cwdlast=%_cwd)`
Similar threads
Thread starter Title Forum Replies Date
R Interact with Win 10 ver 1809 Clipboard history Suggestions 1
vefatica Done Reset history search on Esc Suggestions 3
R Done Command History Window: select more than one line. Suggestions 0
S Save/Load history/aliases/settings to/from Cloud services Suggestions 1
M Done Allow a full search in the directory history Suggestions 2
cxxl Done Allow Selection for History/Dirhistory Window Suggestions 4
rps Done Command and directory history pop-up additions Suggestions 2
rps Command History window options Suggestions 0
rps Done Command History edit additions Suggestions 0
C Done history /f string Suggestions 0
S Done Duplicates for Directory History Suggestions 2
vefatica Done REGDIR /T ... show seconds Suggestions 2
vefatica Done DEL - Summary - also show number of directories removed Suggestions 0
J Done Tooltips should show variable value Suggestions 12
R Declined MOUNTISO: show the drive letter assigned. Suggestions 4
R Done Hover mouse to show complete value Suggestions 1
mfarah Done TCEDIT: show the full name (with drive and path) of the active file on the title bar. Suggestions 3
mfarah TCEDIT: show us more stuff in the status bar. Suggestions 1
Charles Dye TASKLIST: Show service names Suggestions 3
Alpengreis Done Show detailed OS build number Suggestions 4
M Done Show Administrator in the window title when launched as ADMIN under Windows7/Vista Suggestions 1
Alpengreis Done Preserves directory attributes for COPYDIR & COPY Suggestions 3
Joe Caverly Done FTP / HTTP URLs in directory aliases Suggestions 2
D Duplicate directory path and copy files and subdirectories. Suggestions 4
D Done bash style directory bookmarks Suggestions 9
mfarah Done TCEDIT: Edit ⇒ Insert Directory, Filename... how about date/time as well? Suggestions 0
D Done @expand should support directory aliases. Suggestions 0
thorntonpg Done Goto folder in file explorer from the current directory in the tcc prompt Suggestions 7
joltcoder Done Support an "up" command to go to parent directory and "up3" to go up 3 directories, etc. Suggestions 4
mfarah Declined (Filename and)Directory completion keystroke: "stop cycling here and cycle through one level deeper" Suggestions 13
JohnQSmith Done Extended Directory Search Suggestions 11
J Directory Aliases and file:// Suggestions 0
Simon Done Natively query active directory Suggestions 3
S Done Extended directory search database Suggestions 2
S Done Automatic quoting of directory and file names Suggestions 0
S Done GLOBAL command start directory Suggestions 1

Similar threads