1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get current dir into dirhistory?

Discussion in 'TCC/LE Support' started by gerhard, Jun 4, 2011.

  1. gerhard

    Joined:
    May 18, 2011
    Messages:
    7
    Likes Received:
    0
    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.
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,352
    Likes Received:
    39
    How about
    Code:
    CD .
    ?
     
  3. gerhard

    Joined:
    May 18, 2011
    Messages:
    7
    Likes Received:
    0
    Good idea! I added aliases similar to
    Code:
    cd=*cd %$ & *cd .
    for cd, cdd, pushd.

    Thanks!
     
  4. Rod Savard

    Joined:
    May 26, 2008
    Messages:
    481
    Likes Received:
    3
    Why not just set "DirHistoryOnEntry=Yes" in your INI file?
     
  5. Rod Savard

    Joined:
    May 26, 2008
    Messages:
    481
    Likes Received:
    3
    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
     
  6. gerhard

    Joined:
    May 18, 2011
    Messages:
    7
    Likes Received:
    0
    Yes it does; thanks for the hint. I still have 11.0; maybe it's time to update.

    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.
     
  7. Rod Savard

    Joined:
    May 26, 2008
    Messages:
    481
    Likes Received:
    3
    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. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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
     

Share This Page