Get current dir into dirhistory?

May 18, 2011
7
0
#1
After I've now history in general working (with the kind help of Steve Fabian and David Marcus), there's one last nit with the dirhistory: it doesn't store the current directory, so when closing a shell, the last directory visited is not in the history.

Is there a way to store the a directory into the dirhistory as soon as it is hit (typically through cd or cdd)? This would make such a directory available to all other concurrently open shells, similar to how the command history works.

The next best workaround that I can think of is a "cdd d:\" (that's my "base directory") in TCEXIT. This forces the last used directory into the history, at least post-mortem. This way it is available for the next session, but not for any concurrent sessions.

Any better solutions?

Thanks.
 
May 26, 2008
495
3
#5
By the way, that option requires 12.10, I believe. Before 12.10 I used to have this line in my TCEXIT.BTM file:

dirhistory /a %_cwd
 
May 18, 2011
7
0
#6
By the way, that option requires 12.10, I believe.
Yes it does; thanks for the hint. I still have 11.0; maybe it's time to update.

Before 12.10 I used to have this line in my TCEXIT.BTM file:

dirhistory /a %_cwd
This seems to have the same effect as "cd ." (conceptually cleaner but more verbose :) ). However, in TCEXIT, it doesn't put the current directory in the history when you go to it.
 
May 26, 2008
495
3
#7
Another possible solution:

alias PRE_INPUT=dirhistory /a %_cwd

This causes the cwd to be added to the history right before the prompt is displayed.
 
#8
Rod Savard wrote:
| Another possible solution:
|
| alias PRE_INPUT=dirhistory /a %_cwd
|
| This causes the cwd to be added to the history right before the
| prompt is displayed.

I do the same in POST_EXEC, which propagates the information before the next
prompt is displayed. Cf. PRE_INPUT is performed immediately after the next
prompt is displayed, a delay which is most likely insignificant. However, I
already do some other things in PRE_EXEC (to wit, I issue a BEEP if the
command required more than 30s to execute to wake me up), but have no reason
to define PRE_INPUT.
--
Steve