config/shell: improve cleaning & adjust utilities
This commit is contained in:
parent
5c32cd94fc
commit
e976a88ca0
|
@ -1,7 +1,7 @@
|
||||||
# Utilities regarding file system navigation
|
# Utilities regarding file system navigation
|
||||||
|
|
||||||
# Useful when the current directory was recreated
|
# Useful when the current directory was recreated
|
||||||
alias rcd="cd $PWD"
|
alias recd='cd $PWD'
|
||||||
# cd into the parent if arg is a file
|
# cd into the parent if arg is a file
|
||||||
cdd() { cd "$@" 2>/dev/null || cd "$(dirname "$1")" "${@:2}" }
|
cdd() { cd "$@" 2>/dev/null || cd "$(dirname "$1")" "${@:2}" }
|
||||||
|
|
||||||
|
|
|
@ -300,6 +300,7 @@ which perl-rename >/dev/null &&
|
||||||
|
|
||||||
# rsync directory properly - suffix both dirs with / to act on contents
|
# rsync directory properly - suffix both dirs with / to act on contents
|
||||||
alias rcn='rsync -v --recursive --human-readable --links --dry-run'
|
alias rcn='rsync -v --recursive --human-readable --links --dry-run'
|
||||||
|
rcd() { rcn --size-only "$@" | tail +2 | tree --fromfile . | less -F; }
|
||||||
alias rc='rcs --links --times'
|
alias rc='rcs --links --times'
|
||||||
alias rcu='rc --existing --size-only'
|
alias rcu='rc --existing --size-only'
|
||||||
alias rcs='rsync --recursive --info=progress2,remove,symsafe,flist,del --human-readable'
|
alias rcs='rsync --recursive --info=progress2,remove,symsafe,flist,del --human-readable'
|
||||||
|
|
|
@ -20,28 +20,31 @@ do "$local" >/dev/null 2>&1 && f="$(echo "$f" | sed "s|$HOME|$($loc)|")"
|
||||||
done
|
done
|
||||||
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
||||||
|
|
||||||
highlight "e to recursively remove empty folders and files"
|
highlight "e :: recursively remove empty folders and files"
|
||||||
[[ $1 =~ "e" ]] && find -empty -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
[[ $1 =~ "e" ]] && find -empty -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
||||||
|
|
||||||
for k in "${!_clean_map[@]}"; do
|
for k in "${!_clean_map[@]}"; do
|
||||||
folder="${_clean_map[$k]}"
|
folder="${_clean_map[$k]}"
|
||||||
highlight "$k to delete $folder"
|
highlight "$k :: delete $folder"
|
||||||
[[ $1 =~ "$k" ]] && sudo rm $i -rf "$folder" && echo "Deleted $folder"
|
[[ $1 =~ "$k" ]] && sudo rm $i -rf "$folder" && echo "Deleted $folder"
|
||||||
done
|
done
|
||||||
|
|
||||||
highlight "m to recursively remove mac-files"
|
highlight "s :: recursively remove logs"
|
||||||
|
[[ $1 =~ "s" ]] && find \( -name "logs" -prune -o -name "crash-reports" -prune -o -iname "*log.txt" -o -name "*.log.*" -o -iname "*.log" \) -print -exec rm -rI {} +
|
||||||
|
|
||||||
|
highlight "m :: recursively remove mac-files"
|
||||||
if [[ $1 =~ "m" ]]; then
|
if [[ $1 =~ "m" ]]; then
|
||||||
find -iname '.spotlight*' -exec rm -rI {} +
|
find -iname '.spotlight*' -exec rm -rI {} +
|
||||||
find -name '*.DS_Store' -delete
|
find -name '*.DS_Store' -delete
|
||||||
fi
|
fi
|
||||||
|
|
||||||
highlight "g to clean gradle"
|
highlight "g :: clean gradle"
|
||||||
if [[ $1 =~ "g" ]]; then
|
if [[ $1 =~ "g" ]]; then
|
||||||
find "${GRADLE_USER_HOME:-$HOME/.gradle}" -mindepth 1 -maxdepth 1 -type d -print -exec rm $i -r {} +
|
find "${GRADLE_USER_HOME:-$HOME/.gradle}" -mindepth 1 -maxdepth 1 -type d -print -exec rm $i -r {} +
|
||||||
find $PROJECTS -name .gradle -print -exec rm $i -r {} +
|
find $PROJECTS -name .gradle -print -exec rm $i -r {} +
|
||||||
fi
|
fi
|
||||||
|
|
||||||
highlight "c to clean electron caches"
|
highlight "c :: clean electron caches"
|
||||||
[[ $1 =~ "c" ]] && find "$dir$(expr "${XDG_CONFIG_HOME/$HOME}" \| "/.config")" \
|
[[ $1 =~ "c" ]] && find "$dir$(expr "${XDG_CONFIG_HOME/$HOME}" \| "/.config")" \
|
||||||
-type d -name "*Cache" -print -exec rm $i -r {} + -prune
|
-type d -name "*Cache" -print -exec rm $i -r {} + -prune
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ if test -f "/var/log/apt/history.log"; then
|
||||||
export aptclean_last=$aptclean_cur
|
export aptclean_last=$aptclean_cur
|
||||||
fi
|
fi
|
||||||
|
|
||||||
highlight "d to recursively remove development caches"
|
highlight "d :: recursively remove development caches"
|
||||||
if [[ $1 =~ "d" ]]; then
|
if [[ $1 =~ "d" ]]; then
|
||||||
find -name "src" -prune -o \
|
find -name "src" -prune -o \
|
||||||
-type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \
|
-type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \
|
||||||
|
@ -64,7 +67,7 @@ if [[ $1 =~ "d" ]]; then
|
||||||
-print -exec rm -rI {} + -prune
|
-print -exec rm -rI {} + -prune
|
||||||
fi
|
fi
|
||||||
|
|
||||||
highlight "o to optimize space extensively"
|
highlight "o :: 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
|
||||||
nix-collect-garbage -d
|
nix-collect-garbage -d
|
||||||
|
|
|
@ -26,6 +26,8 @@ for arg do
|
||||||
(*.Z) uncompress "$path";;
|
(*.Z) uncompress "$path";;
|
||||||
(*) echo "'$arg' cannot be extracted by ex" >&2;;
|
(*) echo "'$arg' cannot be extracted by ex" >&2;;
|
||||||
esac
|
esac
|
||||||
|
test "$(ls -U | wc -l)" -lt 3 &&
|
||||||
|
mv */* . && find -empty -delete
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
echo "'$1' is not a readable file"
|
echo "'$1' is not a readable file"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
# Displays the latest files in the given directory or pwd
|
# Displays the latest files in the given directory or pwd
|
||||||
test "$1" = "-a" && all=true && shift
|
test "$1" = "-a" && all=true && shift
|
||||||
find "${1:-$PWD}" -maxdepth 4 -type f -printf '%.16T+ %P\n' |
|
for f in "${@:-PWD}"
|
||||||
|
do test $# -gt 1 && highlight "$f"
|
||||||
|
find "$f" -maxdepth 4 -type f -printf '%.16T+ %P\n' |
|
||||||
sort -r | $(test "$all" && echo "less" || echo "head")
|
sort -r | $(test "$all" && echo "less" || echo "head")
|
||||||
|
done
|
||||||
|
|
|
@ -114,7 +114,7 @@ export CTEST_OUTPUT_ON_FAILURE=1
|
||||||
export CTEST_PARALLEL_LEVEL=3
|
export CTEST_PARALLEL_LEVEL=3
|
||||||
|
|
||||||
if test -z "$DISPLAY" && test "$XDG_VTNR" -eq 1 && test -e "$JOURNAL"; then
|
if test -z "$DISPLAY" && test "$XDG_VTNR" -eq 1 && test -e "$JOURNAL"; then
|
||||||
echo "What do you want to do?"
|
echo "What do you want to do? Check your planner!"
|
||||||
while test $(echo "$intention" | wc -c) -lt 6
|
while test $(echo "$intention" | wc -c) -lt 6
|
||||||
do read intention
|
do read intention
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue