From 9ac115e05f82ebb2a8998f91a32d8efdac6c659d Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Sun, 6 Jul 2025 18:09:06 +0200 Subject: update --- .bashrc | 9 ++++++--- .bkignore | 1 + .vimrc | 1 + bin/bk | 24 +++++++++++++++--------- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.bashrc b/.bashrc index 317bdb6..68eedfc 100644 --- a/.bashrc +++ b/.bashrc @@ -42,8 +42,10 @@ case $OS in ;; esac -p() { [ -f "$1" -a ! -x "$1" ] && less "$1" || "$@" 2>&1 | less; } -export -f p +# Exported functions +d() { date +%F; } +p() { [ -f "$1" -a ! -x "$1" ] && less "$1" || "$@" 2>&1 | less; } +export -f d p [ "$OS" = alpine ] && export MANPAGER='vim +MANPAGER --not-a-term' @@ -57,7 +59,7 @@ alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date alias apk='doas apk' alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME' alias dy='YAEGI_AST_DOT=1 YAEGI_CFG_DOT=1 ./yaegi' -alias f2fa='2fa -list | fzf | xargs 2fa -clip' +alias 2fz='2fa -list | fzf | xargs 2fa -clip' alias fd='find . -iname' alias gdt='dlv test -- -test.v -test.run' alias gob='go build' @@ -100,6 +102,7 @@ eval "$(fzf --bash)" >/dev/null # Handle missing commands, unless already provided. type -t command_not_found_handle >/dev/null || command_not_found_handle() { + local pkgs case $OS in (alpine) pkgs=$(apk list -Pq "cmd:$1" | awk '{print $2}') ;; (arch) pkgs=$(pkgfile -b "$1") ;; diff --git a/.bkignore b/.bkignore index c630139..a3a55f2 100644 --- a/.bkignore +++ b/.bkignore @@ -1,3 +1,4 @@ +Library/Application Support/Arc/User Data/Safe Browsing Library/AppleMediaServices Library/CloudStorage Library/Containers/com.apple.Batteries.BatteriesAvocadoWidgetExtension diff --git a/.vimrc b/.vimrc index 7348b9c..7351794 100644 --- a/.vimrc +++ b/.vimrc @@ -65,6 +65,7 @@ autocmd BufNewFile,BufRead *.gno setlocal noexpandtab tabstop=4 shiftwidth=4 autocmd BufNewFile,BufRead *.gno set filetype=gno autocmd Filetype go set mp=go\ build +autocmd Filetype sh compiler shellcheck let g:netrw_browsex_viewer = "open" let g:netrw_gx = "" diff --git a/bin/bk b/bin/bk index ed76199..e313962 100755 --- a/bin/bk +++ b/bin/bk @@ -1,15 +1,21 @@ -#!/bin/sh +#!/bin/sh -e -# Daily backup script. +# Daily backup script. Perform once per day with a cron like: +# 55 18 * * * /Users/marc/bin/bk >/tmp/bk.out 2>&1 -dest=${BK:-/Volumes/sandisk4}/backup/$(hostname -s) -day=$(date +%A) +error() { echo "$@" >&2; return 1; } + + +dest="${BK:-/Volumes/sandisk4}/backup/$(hostname -s)" +day="$(date +%A)" + +test -d "$dest" || error "$dest not available" # Clear previous week incremental backup -mkdir $HOME/emptydir -rsync --delete -a $HOME/emptydir/ $dest/$day/ -rmdir $HOME/emptydir +mkdir "$HOME/emptydir" +rsync --delete -a "$HOME/emptydir/" "$dest/$day/" +rmdir "$HOME/emptydir" # Now backup -rsync --delete --delete-excluded --exclude-from=$HOME/.bkignore \ - --backup --backup-dir=${dest#*:}/$(date +%A) -av $HOME $dest/current +rsync --delete --delete-excluded --exclude-from="$HOME/.bkignore" \ + --backup --backup-dir="${dest#*:}/$(date +%A)" -av "$HOME" "$dest/current" -- cgit v1.2.3