Created
April 7, 2020 15:55
-
-
Save Aura7988/80ee512384cbb8bdeddf856679ed8773 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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