Wednesday, May 30th, 2007
Today I finally decide to make a script to keep my bash_history synchronized among all the machines I use. It’s a simple script that retrieves all the .bash_history files from all my machines, merges all the files into one, sort it, removes the duplicated lines and write it back to all the machines. The only drawback is that the original ordering of the history files is lost due to the alphabetical sorting step (needed to remove the duplicated lines).
WARNING: Make sure that your history file size limit is big enough to hold all the combined history files. Otherwise you’ll lose some of the entries. You can go to this post for reference on how to change the history file limits
Here’s the script:
echo copying local history file
history -a
cp .bash_history full_history
HOSTS="machine1.example.com machine2.example.com"
for i in $HOSTS; do
echo copying history file from $i
scp $i:~/.bash_history tmp_history.txt
cat tmp_history.txt >>full_history
wc -l tmp_history.txt
wc -l full_history
done
echo sorting the new history file and removing duplicates
sort full_history|uniq >uniq_history
rm full_history
echo replacing history file with the new one
mv uniq_history .bash_history
echo reloading bash history from file
history -c
history -r
wc -l .bash_history
for i in $HOSTS; do
echo backing up .bash_history in $i
DATE=`date '+%Y%m%d%H%M%S'`
ssh $i "cp ~/.bash_history ~/.bash_history$DATE"
echo replacing .bash_history in $i
scp .bash_history $i:~/.bash_history
done
Tags: bash, bashrc, bash_history, history, merge, ssh, sync, synch, synchronize
Posted in linux | No Comments »
Friday, April 20th, 2007
I’m observing an strange firefox behavior when I scroll the page using the mouse wheel. It goes back and forth through search history. So I googled a little bit and found that the KVM switch that I’m using it’s producing bogus key press event that firefox misinterprets. If you are running Linux the solution is simple as you can modify the X server configuration to ignore those events. But I cannot find a suitable solution for Windows.
Disabling history scroll in firefox (Usually triggered with Shift-<Wheel>) in about:config seems to have no effect in stopping this weird mouse wheel behavior.
Theorically changing the value of all mousewheel.horizscroll.with∗.action and mousewheel.with∗.action entries to 0 disables moving back/forward in history using the mouse wheel. Check this to know more about the meaning and purpose of mousewheel.∗ entries. But as I said It seems that doesn’t make any difference.
If you know the solution for this problem post it in the bug report
Tags: back, firefox, forward, history, mouse, scroll, scrolling, wheel
Posted in firefox, linux, windows | 5 Comments »
Monday, January 8th, 2007
After reading the tip I mentioned in my previous post I made some changes to my ~/.bashrc to enable bash history
alias e32="$HOME/eclipse/eclipse321/eclipse"
alias e33="$HOME/eclipse/eclipse33M4/eclipse"
alias nb="$HOME/netbeans-5.5/bin/netbeans"
JAVA_HOME=$HOME/jdk1.6.0
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:
export PATH
HISTFILESIZE=1000000000
HISTSIZE=1000000
HISTCONTROL=ignoredups
shopt -s histappend
INPUTRC=~/.inputrc
and to my ~/.inputrc
# .inputrc
# "\e[A" and "\e[B" being whatever your terminal uses for up & down.
"\e[A": history-search-backward
"\e[B": history-search-forward
And with the following simple command I can see the commands I use most:
cut -f1 -d" " ~/.bash_history | sort | uniq -c | sort -nr | head -n 30
Tags: alias, bash, bashrc, history
Posted in linux | 1 Comment »
Friday, January 5th, 2007
Very useful tip to analyze you bash history.
Tags: analyze, bash, blog, history, onlamp
Posted in linux | 1 Comment »