clear history from shell

Ralf Mardorf silver.bullet at zoho.com
Thu May 19 07:09:04 UTC 2016


Half-OT:

IMO it's better to keep a long default history and to write a script
that allows to search the history in a way that fit's to an user's
individual work flow and if a command or line of commands should be
used again, to copy and paste. I'm used to this:

$ hg

-rwxr-xr-x 1 root root 378 Jun 15  2015 /usr/local/bin/hg

#!/bin/dash
# History grep   hg version 2015-06-15-rocketmouse

grep="grep -v"
pattern="$2"
case $1 in
  "")
    printf "\n$(ls -l $0)\n\n"; cat $0;;
  *)
    case $2 in
      ""|--)
        grep="grep"
        pattern="";;
    esac;;
esac

grep "$1" ~/.bash_history | $grep "$pattern" | grep "$3" | grep "$4"\
| grep "$5" | grep "$6" | grep "$7" | grep "$8" | grep "$9"

exit


$ grep hgg .bashrc 
alias hgg='hg . --'



Examples:


$ hg man
man getfacl
pacman.conf
[snip]


$ hg man pac
man getfacl
man mount
man chattr
man bash | grep HISTCONTROL 
[snip] 


$ hg man pac bash
man bash | grep HISTCONTROL 


$ hgg man bash
man bash | grep HISTCONTROL





More information about the ubuntu-users mailing list