Skip to content

Instantly share code, notes, and snippets.

@Aura7988
Created April 7, 2020 15:55
Show Gist options
  • Save Aura7988/80ee512384cbb8bdeddf856679ed8773 to your computer and use it in GitHub Desktop.
Save Aura7988/80ee512384cbb8bdeddf856679ed8773 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/bash
action() {
src=~/.bash_history
bak=~/Bash/bh.bak
tmp=~/Bash/tmp.txt
p='^cd( | *$)|^vi( | *$|mdiff )|^z |^fg( | *$)|^man |^md5sum |^git diff |^l(a|l|s)( | *$)'
cp $src $bak && sed -E "/$p/d" $bak | tac | awk '!a[$0]++' | tac > $tmp && mv $tmp $src
}
# if ps -ef | grep fswatch | grep -v grep > /dev/null; then
if pgrep fswatch > /dev/null; then
echo 'Already running.'
exit 3
fi
while :; do
fswatch -1 --event Updated ~/.bash_history &> /dev/null && action
sleep 0.5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment