by devnonymous · 10y ago · 0 comments
* 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:
http://swapoff.org/ondir.html
https://github.com/kennethreitz/autoenv
http://direnv.net/
https://github.com/cxreg/smartcd
Note however, that most unix tools are angnostic to the current working dir so... $ /path/to/cmd /some/other/path/to/argument
$ cd /path/to && ./cmd /some/other/path/to/argument
$ cd /some/other/path/to && /path/to/cmd argument
...might all do the same thing but will be saved in different history files if you implement what you need.No comments yet.