helpThe GNU Bourne-Again SHell - Support: sr #109679, Save current working directory in...


sr #109679: Save current working directory in history

Submitted by:  Steven Willis <onlynone>
Submitted on:  Thu 09 May 2019 05:53:44 PM UTC  
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 09 May 2019 05:53:44 PM UTC, original submission:  

It would be nice if bash could save and display the directory where a command from its history was run.

I have a patch which adds the path as a string in the `HIST_ENTRY` struct and reads and writes it after the timestamp in the comment line in the history file.

The modified history file looks like:

    #1557421027 /Users/me/projects/bash
    cd lib
    #1557421028 /Users/me/projects/bash/lib
    #1557421033 /Users/me/projects/bash/lib
    echo i am in lib
    #1557421034 /Users/me/projects/bash/lib
    #1557421037 /Users/me/projects/bash/lib
    cd readline/
    #1557421038 /Users/me/projects/bash/lib/readline
    #1557421041 /Users/me/projects/bash/lib/readline
    cd ..
    #1557421042 /Users/me/projects/bash/lib
    #1557421043 /Users/me/projects/bash/lib
    cd ..
    #1557421044 /Users/me/projects/bash

The patch doesn't change the output when `history` is run, but having it display the path in parens just before the command would be useful. It also doesn't change any functionality when running a command from the history, but one could imagine having the ability to first change directory of the saved command before re-execution. It also depends on timestamp saving to be turned on as I didn't add a different boolean for cwd path saving. I just wanted to get feedback before going any farther.

Steven Willis <onlynone>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #46890:  add_cwd_to_history.patch added by onlynone (7KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by onlynone (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-09 onlynone Attached File- => Added add_cwd_to_history.patch, #46890

    Back to the top

    Powered by Savane 3.5