bin/clean: update ignoredirs spec

This commit is contained in:
xeruf 2021-11-11 19:46:29 +01:00
parent 2c63a34c7f
commit 22f9c077c8
2 changed files with 20 additions and 21 deletions

View File

@ -2,16 +2,30 @@
# Cleans up files according to given parameters # Cleans up files according to given parameters
typeset -A _clean_map typeset -A _clean_map
_clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [c]=/var/cache) _clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [v]=/var/cache)
# Directories to always clean # Directories to always clean
_clean_folders=(~/.ant ~/.autopsy ~/.bundle ~/.cache ~/.cargo ~/.cpanm ~/.docker ~/.electron ~/.electron-gyp ~/.gradle ~/.gradle-kotlin-dsl ~/.hex ~/.java ~/.kscript ~/.konan ~/.m2 ~/.mix ~/.nix-defexpr ~/.node-gyp ~/.npm ~/.nv ~/.openjfx ~/.parallel ~/.stack ~/.surf ~/.texlive ~/.yarn luametatex-cache _clean_folders=(~/.ant ~/.autopsy ~/.bundle ~/.cache ~/.cargo ~/.cpanm ~/.docker ~/.electron ~/.electron-gyp ~/.gradle ~/.gradle-kotlin-dsl ~/.hex ~/.java ~/.kscript ~/.konan ~/.m2 ~/.mix ~/.nix-defexpr ~/.node-gyp ~/.npm ~/.nv ~/.openjfx ~/.parallel ~/.stack ~/.surf ~/.texlive ~/.yarn luametatex-cache
~/.lesshst ~/.rubberband.wisdom.d ~/.yarnrc) ~/.lesshst ~/.rubberband.wisdom.d ~/.yarnrc)
for f in ${_clean_folders[@]} for f in ${_clean_folders[@]}
do test -f $f || test -d $f && highlight $f && rm -rf $f do test -f $f || test -d $f && highlight $f && rm -rf $f
done done
find $HOME -maxdepth 2 -not -name ".stfolder" -type d -empty -exec rm -vd {} + find $HOME -maxdepth 2 -not -name ".stfolder" -empty -exec rm -vd {} +
highlight "e to recursively remove empty folders and files"
[[ $1 =~ "e" ]] && find -empty -type d -exec rm -vd {} +
for k in "${!_clean_map[@]}"; do
folder="${_clean_map[$k]}"
highlight "$k to delete $folder"
[[ $1 =~ "$k" ]] && sudo rm -rf "$folder" && echo "Deleted $folder"
done
highlight "m to recursively remove mac-files"
if [[ $1 =~ "m" ]]; then
find -iname '.spotlight*' -exec rm -rI {} +
find -name '*.DS_Store' -delete
fi
highlight "g to clean gradle" highlight "g to clean gradle"
if [[ $1 =~ "g" ]]; then if [[ $1 =~ "g" ]]; then
@ -19,14 +33,8 @@ if [[ $1 =~ "g" ]]; then
find $projects_dir -name .gradle -print -exec rm -r {} + find $projects_dir -name .gradle -print -exec rm -r {} +
fi fi
highlight "e to clean electron caches" highlight "c to clean electron caches"
[[ $1 =~ "e" ]] && find "$XDG_CONFIG_HOME" -type d -name "*Cache" -exec rm -r {} + -prune [[ $1 =~ "c" ]] && find "$XDG_CONFIG_HOME" -type d -name "*Cache" -exec rm -r {} + -prune
for k in "${!_clean_map[@]}"; do
folder="${_clean_map[$k]}"
highlight "$k to delete $folder"
[[ $1 =~ "$k" ]] && sudo rm -rf "$folder" && echo "Deleted $folder"
done
if test -f "/var/log/apt/history.log"; then if test -f "/var/log/apt/history.log"; then
aptclean_cur=$(cat "/var/log/apt/history.log" | wc -l) aptclean_cur=$(cat "/var/log/apt/history.log" | wc -l)
@ -48,15 +56,6 @@ if [[ $1 =~ "d" ]]; then
-print -exec rm -rI {} + -prune -print -exec rm -rI {} + -prune
fi fi
highlight "m to recursively remove mac-files"
if [[ $1 =~ "m" ]]; then
find -iname '.spotlight*' -exec rm -rI {} +
find -name '*.DS_Store' -delete
fi
highlight "f to recursively remove empty folders"
[[ $1 =~ "f" ]] && find -empty -type d -delete -print
highlight "o to optimize space extensively" highlight "o to optimize space extensively"
if [[ $1 =~ "o" ]]; then if [[ $1 =~ "o" ]]; then
which yay &>/dev/null && yay -Sc --noconfirm which yay &>/dev/null && yay -Sc --noconfirm

View File

@ -57,7 +57,7 @@ export CONFIG_SHELLS="$XDG_CONFIG_HOME/shell"
# environment # environment
which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim' which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim'
export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)" export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
export IGNOREDIRS_PURE="-x .sync -x .stfolder -x .gradle -x dist_newstyle -x node_modules -x generated -x .cache -x *Cache -x .local/cache -x .local/state -x share/JetBrains -x share/Zeal -x share/syncthing -x .cpan -x .cpanm" export IGNOREDIRS_PURE="-x .sync -x .stfolder -x .gradle -x dist_newstyle -x node_modules -x generated -x .cache -x *Cache -x .local/cache -x .local/state -x share/JetBrains -x share/Zeal -x share/syncthing -x .cpan -x .cpanm -x __pycache__"
export IGNOREDIRS="-x *build -x .git -x .idea -x out -x cache -x Partitions $IGNOREDIRS_PURE" export IGNOREDIRS="-x *build -x .git -x .idea -x out -x cache -x Partitions $IGNOREDIRS_PURE"
# red stderr # red stderr
test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}" test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"