Open biocyberman opened 8 years ago
The history file for the current directory is defined as $HISTORY_BASE${PWD:A}/history
.
To make this easy to use you can define a helper function to retrieve the current history file.
history_file() { echo $HISTORY_BASE${PWD:A}/history }
less $(history_file)
@jimhester Thanks for the instruction. Would it break anything if I change
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
to _per_directory_history_directory="${PWD}/.zshhistory"
Here I changed both the path to history file and the filename. I want to explore this possibility so I can write a function for enable writing command log at $PWD
Dear @jimhester and @biocyberman - I agree that per directory history is very helpful and similarly would find it more useful to have the local history in a local file rather than in a shared hierarchy.
This is because I regularly have to move my working dirs between different filesystems (archival, fast shared scratch, local temp). Thus during the course of a project, a specific directory would have been in several different physical locations.
@biocyberman have you tested your proposal succesfully?
Thanks and kind regards, Yannick
@yannickwurm I went ahead and make the changes. Everything works fine, you can check it out here: https://github.com/biocyberman/per-directory-history/tree/dev But there is a drawback with my approach: file may be easily deleted or overwritten (i.e. when copying). Maybe maintaining two copies of this local history, one at the central $HISTORY_BASE, and one at the local $PWD.
Trying to use a file in the current directory will also fail if the user does not have write permissions to the directory (which was the main reason for not doing so).
If you really want to have a file in the current directory I would keep the current history as it is and also create a symbolic link in the current file e.g. ln -s $HISTORY_BASE${PWD:A}/history ${PWD:A}/.zhistory
Wouldn't setting HISTORY_BASE
to an empty string achieve this?
Wouldn't setting
HISTORY_BASE
to an empty string achieve this?
That's equivalent to what I did: remove $HISTORY_BASE
: https://github.com/jimhester/per-directory-history/compare/master...biocyberman:dev
I didn't set HISTORY_BASE
to empty string because that may interfere with other parts.
I like it very much so far. However, I prefer to have the history saved in a file the the current working directory. The use case is like this:
I am aware that this gives no merit to security and we may have tons of 'history' files lying all over the places. So it is nice to have an option to turn off by default and turn on history saving to a file by a keyboard shortcut.