Open TC72 opened 1 year ago
Where/how would you propose that this info should be shown to the user?
I feel like it would be complex to implement for not too much gain outside of a restricted use case.
If this is something you have to do often, here is a function which can help. Consider putting it in your rc file.
function per-hist-dir-cmd-search() {
find ~/.directory_history -type f -name history -exec grep --color=always "${1}" {} + | sed -E 's/: [0-9:]+;//' | sed 's/\/history:/:/'
}
Here is how you execute it.
per-hist-dir-cmd-search "substring of command you're interested in"
The output will be a grep
-style list of "hits" across all per-directory history files. The "filenames" of this grep
-style output will be the names of the directories from which you ran the command.
I used zsh global history to find a command I've run previously but I realised I didn't remember which directory I ran it. The I realised
per-directory-history
would know which directory I ran it from.I was able to use
rg my-command ~/.directory_history
and it instantly showed me the history file which lead me to the directory it was run in.It would be fantastic if there was an option to
cd
to the directory a command was run in when viewing global history.