Reputation: 897
I have the portable Git for Windows version and run it from a USB stick on different machines. I noticed that when I use the Git Bash, it saves the bash history in the default user folder i.e. C:/Users/[username]/.bash_history
. This is no good for me. I would like to set it to a custom directory (on the USB stick).
(How) Can I do this?
Upvotes: 5
Views: 8769
Reputation: 1
When updating GitBash, all modified files are restored to their defaults. Therefore, instead of adding the customize option directly, I recommend putting the customization in a new .sh file and then only adding this line to the end of /etc/profile
...
source /path/to/customization_file.sh
Put the changes you want to implement into customization_file.sh
. After updating GitBash, you will simply have to add that single line once again and all your options will return. It also helps keep you more organized and not have to remember what your commands are or to back them up before an update.
---EDIT---
A more thorough solution is to change the location of the home folder (~) itself. This will affect not only the .bash_history, but also all the programs that would write to your C:\Users\USERNAME folder
Upvotes: 0
Reputation: 897
In the file /etc/profile
just add the line HISTFILE="/folder/of/your/choice/.bash_history"
. Works like a charm.
Inspired by this. (More options to customize)
.
(Also by the way, if you want to set your default home directory to a custom location as well, you just add the line HOME="/your/new/home/folder"
to the same /etc/profile
-file.)
Upvotes: 5