From c7c3fae834c588fe7686957e25f2adc9911fb9d7 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 27 Jan 2024 19:42:37 +0300 Subject: [PATCH] Group : Add current year collector. --- .config/bash/module/Group.sh | 19 +++++++++++++++++++ .doc/Bash.md | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.config/bash/module/Group.sh b/.config/bash/module/Group.sh index e744cc0..6e65c26 100644 --- a/.config/bash/module/Group.sh +++ b/.config/bash/module/Group.sh @@ -36,3 +36,22 @@ function group_year() { _iterate_targets process ${targets[@]} } + +# Copy files from current year to the named dir. +function group_year_current() { + local IFS=$'\n' + local targets=(${@}) + [[ "${targets}" = "" ]] && targets=($(ls)) + + local today="$(date +%Y)" + mkdir ${today} 2> /dev/null + + process() { + local year=$(stat --format=%y ${target}) + year=${year%%-*} + + [[ "${year}" = "${today}" ]] && cp -- ${target} ./${today}/ + } + + _iterate_targets process ${targets[@]} +} diff --git a/.doc/Bash.md b/.doc/Bash.md index 9f18238..8a96acd 100644 --- a/.doc/Bash.md +++ b/.doc/Bash.md @@ -211,6 +211,7 @@ Command|Description ---|--- `group_ext [FILES]`|Group files by extension. `group_year [FILES]`|Group files and dirs by year. +`group_year_current`|Copy files from current year to the named dir. ## Help. @@ -267,9 +268,10 @@ Command|Description `nix_unstable`|Switch to Unstable branch. `nix_unstable_small`|Switch to Small Unstable branch (for server). `nix_channel`|Display current channel. -`nix_update`|Update system (rebuild). -`nix_upgrade`|Upgrade system. +`nix_update [HOSTNAME]`|Update system (rebuild). Optionally force the hostname. +`nix_upgrade [HOSTNAME]`|Upgrade system. Applies after reboot. Optionally force the hostname. `nix_clean`|Free up root space. +`nix_shell`|Spawn shell with nix environment, like LD support. `shell`|Spawn temporary shell. ## Notify.