Compile All your Bash hisstory in one big history file accesible from every shell
DONT USE THIS THERE IS A SERIOUS BUG IN IT DUE TO A LAST MINUTE ADDITION!!!
THIS CAUSES THE HISTFILE TO GROW EXPONENTIALLYF AND HANG YOUR SYSTEM!!!
i only left this here for educational purposes of how not to do this , working update posted in a new blogpost!
save the following file somewhere and source it in your bashrc or save it directly to /etc/profile.d/bash_history or smth
since it saves the bash history in /var/cache/bash/history/ (in one global and seperate files for each tty)
first time you run it it might ask for a sudo password (or you can create the folder manually by hand :
sudo mkdir -p /var/cache/bash/history/
sudo chmod -R 777 $_
the script: (needs some work, so feel free to contribute, ill put it on github soon aswell if you prefer to contribute that way)
#!/usr/bin/env bash # ############################################################################ # # PATH: /opt/local/config/rc/bash AUTHOR:Hoefkens.j@gmail.com # # FILE: 311_history.conf # ############################################################################ # HISTFOLDER="/var/cache/bash/history" HISTSIZE=-1 HISTFILESIZE=$HISTSIZE HISTCONTROL='' HISTFILE="$HISTFOLDER/history.$$" HISTS="$HISTFOLDER/history.[0-9]*" GLOBHIST="$HISTFOLDER/history.glob" [[ ! -e "$HISTFOLDER" ]] && sudo mkdir -p "$HISTFOLDER" && sudo chmod 777 "$HISTFOLDER" && sudo chown 1:100 "$HISTFOLDER" [[ ! -f "$GLOBHIST" ]] && touch "$GLOBHIST" && chmod 777 "$GLOBHIST" [[ -f "$HISTFILE" ]] && cat "$HISTFILE" >> "$GLOBHIST" && rm -f "$HISTFILE" [[ ! -f "$HISTFILE" ]] && touch "$HISTFILE" && chmod 777 "$HISTFILE" for HIST in $( ls $HISTS) ; do cat "$HIST" >> "$HISTFILE" 2>/dev/null done sudo chmod -R 777 "$HISTFOLDER" && sudo chown -R 1:100 "$HISTFOLDER" _bash_history_sync() { builtin history -a "$HISTFILE" builtin history -a "$GLOBHIST" builtin history -c #3 builtin history -r $GLOBHIST builtin history -r $HISTFILE } history() { #5 _bash_history_sync builtin history "$@" } PROMPT_COMMAND=_bash_history_sync
current status of my bash history: (kindof proof that it works :D))
0 Comments
There are no comments to display.