Fix history with repeated commands

In regard to the recent issues concerning  MEGA I need to do something D:

When executing the command “history” one hundred and sixty thousand lines are showed!!! really!!, this because of an application in my cellphone know as “home remote control” (I bought it because it works pretty fine) executed lots of commands in order to get control of the mouse.

Screenshot from 2016-04-22 11-55-16

My guess is that this is the reason of why It lags while using the mouse through the Smartphone. The best I could think of was to deactivate the history logging when getting access via SSH

Avoid writing in bash historial when using SSH

As you can see it’s time to use the well-know Who command, and probably many people thinks that it is not commonly , even thought it is. Add the next to ~/.bashrc

whoisme=$(who | tr -s ” ” | cut -d ” ” -f 5 | tail -1 )
#tr and cut will be added to my useful command list 😀

if [ ! “$whoisme” == “(:0)” ] ; then
shopt -u -o history

Now I feel the mouse so swift when I use it with my Smartphone and it’s more comfortable than the mouse is.

Delete Repeated Lines

Here xdotool must be replaced with the repeated command we want to erase

Default History (if unsure use it):

cat ~/.bash_history | sed -e '/xdotool/d' > ~/.bash_history

Custom History with Date and Time settings

cat ~/.bash_history | sed -e ‘/xdotool/,+1d’ > ~/.bash_history

These bottons respect your privacy

Leave a Reply

Your email address will not be published. Required fields are marked *