Re:Ask HN: Is there a way to make bash history dir specific?
by devnonymous on Wednesday May 25, 2016 @05:40AM
(#11768645)
There isn't an builtin way to do this in bash but what you are asking for is 2 things:
* Trigger an action on changing a directory
* That action should be to change your bash history file
The second part is pretty easy to do -- you just change the $HISTFILE environment variable and export it. For the first part though, you can either use a naive little function that replaces bash's builtin `cd`[1] or you can use any one of the many tools specifically created for this sort of a thing:
* Trigger an action on changing a directory
* That action should be to change your bash history file
The second part is pretty easy to do -- you just change the $HISTFILE environment variable and export it. For the first part though, you can either use a naive little function that replaces bash's builtin `cd`[1] or you can use any one of the many tools specifically created for this sort of a thing:
Note however, that most unix tools are angnostic to the current working dir so... ...might all do the same thing but will be saved in different history files if you implement what you need.[1] http://superuser.com/a/296554/267793