config: implement duploc

This commit is contained in:
xeruf 2022-05-19 22:24:44 +02:00
parent e74af0904b
commit dc536f0090
3 changed files with 8 additions and 6 deletions

View File

@ -65,7 +65,7 @@ alias uloc='noglob sudo updatedb && loci'
locei() { locate --all --basename "\\$1" "$@" | fselect } locei() { locate --all --basename "\\$1" "$@" | fselect }
alias loce='noglob locei' alias loce='noglob locei'
# locate all # locate all
alias loca='noglob sudo updatedb -l 0 --prunenames "" --prunefs "tmpfs sysfs debugfs" --prunepaths "/var/cache" --debug-pruning -o /var/cache/locate-all.db && loci --database /var/cache/locate-all.db' alias loca='noglob sudo updatedb -l 0 --prunenames "" --prunefs "tmpfs sysfs debugfs" --prunepaths "" -o /var/cache/locate-all.db && loci --database /var/cache/locate-all.db'
# ZOXIDE {{{1 # ZOXIDE {{{1
alias c=z alias c=z

View File

@ -145,6 +145,7 @@ export KEYTIMEOUT=1
setopt correct setopt correct
CORRECT_IGNORE="[_|.]*" CORRECT_IGNORE="[_|.]*"
# command history - https://unix.stackexchange.com/a/273863 # command history - https://unix.stackexchange.com/a/273863
# TODO always much shorter
HISTSIZE=100000 HISTSIZE=100000
SAVEHIST=$HISTSIZE SAVEHIST=$HISTSIZE
setopt inc_append_history setopt inc_append_history

View File

@ -1,9 +1,10 @@
#!/bin/sh #!/bin/sh
# Delete files under current or given path which exist elsewhere as listed in the locate database # Delete files under current or given path which exist elsewhere as listed in the locate database
# Matches first by name, then by checksum # Matches first by name, then by checksum (currently inefficiently via md5)
# TODO find "$@" -size +50M -type f | while read filepath
find "$@" -size +50M | while read filepath do target="$(basename "$filepath" | synct-unarchive)"
do f="$(basename "$filepath" | synct-unarchive)"
highlight "$filepath" highlight "$filepath"
locate -b "$f" locate -b "$target" | while read existing
do test "$(realpath "$target")" != "$(realpath "$existing")" -a -f "$existing" -a "$(md5sum "$existing" | cut -d\ -f1)" = "$(md5sum "$filepath" | cut -d\ -f1)" && echo "Found duplicate at $existing" && rm -vi "$filepath" && break
done
done done