43 lines
1.0 KiB
Bash
Executable File
43 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
on_exit() {
|
|
(ccrypt -K "$now" -d "$file.cpt")
|
|
|
|
# prepare regex pattern
|
|
shopt -s extglob
|
|
readarray -t removeArray < <(grep -ve '^$\|^#' "$file")
|
|
IFS='|' eval 'PATTERN="(${removeArray[*]})"'
|
|
PATTERN="(^|[^a-zA-Z])$PATTERN([^a-zA-Z]|$)"
|
|
|
|
case $shell in
|
|
*fish)
|
|
printf "sanitizing fish history!\n"
|
|
"$(dirname "$0")/sanitize_hist.fish" "$PATTERN" "/home/$(whoami)/.local/share/fish/fish_history"
|
|
;;
|
|
*bash)
|
|
printf "sanitizing bash history!\n"
|
|
"$(dirname "$0")/sanitize.sh" "$PATTERN" "/home/$(whoami)/.bash_history" 1
|
|
;;
|
|
*)
|
|
printf "autosanitize has no implementation for %s\n" "$shell"
|
|
;;
|
|
esac
|
|
|
|
rm -r ~/.cache/thumbnails/*
|
|
rm "$file"
|
|
}
|
|
|
|
trap 'on_exit' EXIT
|
|
now=$(date +%s.%N)
|
|
folder=/run/media/$(whoami)/P/Scripts
|
|
file=/tmp/tags
|
|
shell=$(grep "$(whoami)" < /etc/passwd | awk -F':' '{print $NF}' )
|
|
|
|
echo "copying tags to temp file..."
|
|
cat "$folder/tags2" "$folder/tags" > "$file"
|
|
(sed -i '/^$/d;/^\#.*$/d' "$file")
|
|
(ccrypt -K "$now" "$file")
|
|
while :; do
|
|
sleep 600
|
|
done
|