From 64f6dc952b4612951cf267a65bf3a375a55c7bde Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 9 Nov 2021 05:37:07 +0100 Subject: [PATCH] config: little overall improvements --- .config/git/config | 3 ++- .config/shell/browse | 2 +- .local/bin/scripts/barg | 9 +++++++-- .local/bin/scripts/clean | 2 +- .local/bin/scripts/rd | 1 + .local/bin/scripts/tl | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.config/git/config b/.config/git/config index 909ce3d..857ddca 100644 --- a/.config/git/config +++ b/.config/git/config @@ -86,7 +86,8 @@ sv = --paginate status -v svv = --paginate status -vv - tree = !git ls-tree --full-tree --name-only -r HEAD | tree -C --fromfile . | ${PAGER:-less} + tl = !git ls-tree --full-tree --name-only -r HEAD | tree -C --fromfile . | ${PAGER:-less} + tree = !git ls-tree --name-only -r HEAD | tree -C --fromfile . | ${PAGER:-less} # repo r = remote -v diff --git a/.config/shell/browse b/.config/shell/browse index 63e7077..039753d 100644 --- a/.config/shell/browse +++ b/.config/shell/browse @@ -40,7 +40,7 @@ cd() { } # LOCATE -alias fselect='fzf -0 -1 --reverse --height=30%' +alias fselect='fzf -0 -1 --reverse --height=30% | while read f; do test -d "$f" && cd "$f" || b "$f"; done' loci() { locate --all --ignore-case --basename --existing "$@" | command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') | fselect diff --git a/.local/bin/scripts/barg b/.local/bin/scripts/barg index 224b97a..a149096 100755 --- a/.local/bin/scripts/barg +++ b/.local/bin/scripts/barg @@ -1,6 +1,11 @@ #!/bin/sh # Backup root filesystem with borg -cd / +case "$1" in + (-*) name="${1#-}"; shift;; + (*) test $# -gt 0 || cd /;; +esac +name="/mnt/backup/borg::$(test -n "$name" && echo "$name" || cat /etc/hostname)-${1:-system}-$(date -u +"%y%m%d")" +echo "Backing up as $name" sudo borg create --progress --stats \ $(echo $IGNOREDIRS_PURE -x 'software-challenge/*/build' -x 'emacs/.local' | sed 's|-x \([^ ]\+\)|-e "*/\1" -e \1|g') \ - /mnt/backup/borg::$(cat /etc/hostname)-system-$(date -u +"%y%m%d") etc home root + "$name" $(test $# -eq 0 && echo etc home root || test $# -eq 1 && echo $1) "${@:2}" diff --git a/.local/bin/scripts/clean b/.local/bin/scripts/clean index 6bee3c9..afe00b6 100755 --- a/.local/bin/scripts/clean +++ b/.local/bin/scripts/clean @@ -5,7 +5,7 @@ typeset -A _clean_map _clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [c]=/var/cache) # Directories to always clean _clean_folders=(~/.ant ~/.autopsy ~/.bundle ~/.cache ~/.cargo ~/.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 ~/.yarnrc) + ~/.lesshst ~/.rubberband.wisdom.d ~/.yarnrc) for f in ${_clean_folders[@]} diff --git a/.local/bin/scripts/rd b/.local/bin/scripts/rd index 3d5e44f..317d57c 100755 --- a/.local/bin/scripts/rd +++ b/.local/bin/scripts/rd @@ -1,5 +1,6 @@ #!/bin/sh # Remove recursively safely +case "$1" in ([0-9]) depth=$1; shift;; esac for f in "$@" do test -w "$f" && elevate="" || elevate=sudo diff --git a/.local/bin/scripts/tl b/.local/bin/scripts/tl index d697be3..5e7e4e3 100755 --- a/.local/bin/scripts/tl +++ b/.local/bin/scripts/tl @@ -4,5 +4,5 @@ # with forced [C]olorization and pipe into less # If first arg is a digit, it displaces the default depth of 3 # Any other arguments (usually pathnames) are passed on to the tree command -case "$1" in [0-9]) depth=$1; shift;; esac +case "$1" in ([0-9]) depth=$1; shift;; esac tree -a --dirsfirst -L ${depth:-3} --du -h -C "$@" | ${PAGER:-less}