From 22f9c077c85a5e7ba8965280f5fbc13f8681aba2 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 11 Nov 2021 19:46:29 +0100 Subject: [PATCH] bin/clean: update ignoredirs spec --- .local/bin/scripts/clean | 39 +++++++++++++++++++-------------------- .zprofile | 2 +- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.local/bin/scripts/clean b/.local/bin/scripts/clean index 987f473..0cf3872 100755 --- a/.local/bin/scripts/clean +++ b/.local/bin/scripts/clean @@ -2,16 +2,30 @@ # Cleans up files according to given parameters 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 _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) - for f in ${_clean_folders[@]} do test -f $f || test -d $f && highlight $f && rm -rf $f 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" if [[ $1 =~ "g" ]]; then @@ -19,14 +33,8 @@ if [[ $1 =~ "g" ]]; then find $projects_dir -name .gradle -print -exec rm -r {} + fi -highlight "e to clean electron caches" -[[ $1 =~ "e" ]] && 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 +highlight "c to clean electron caches" +[[ $1 =~ "c" ]] && find "$XDG_CONFIG_HOME" -type d -name "*Cache" -exec rm -r {} + -prune if test -f "/var/log/apt/history.log"; then aptclean_cur=$(cat "/var/log/apt/history.log" | wc -l) @@ -48,15 +56,6 @@ if [[ $1 =~ "d" ]]; then -print -exec rm -rI {} + -prune 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" if [[ $1 =~ "o" ]]; then which yay &>/dev/null && yay -Sc --noconfirm diff --git a/.zprofile b/.zprofile index 50ab669..c0e3ad2 100644 --- a/.zprofile +++ b/.zprofile @@ -57,7 +57,7 @@ export CONFIG_SHELLS="$XDG_CONFIG_HOME/shell" # environment 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 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" # red stderr test -f "/usr/lib/libstderred.so" && export LD_PRELOAD="/usr/lib/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"