Archive : Add touch function.

This commit is contained in:
Dmitry Voronin 2024-02-21 15:39:50 +03:00
parent 09eb0a8be5
commit 4158d8673e
2 changed files with 20 additions and 1 deletions

View file

@ -248,6 +248,22 @@ function unarchive() {
_iterate_targets process ${targets[@]} _iterate_targets process ${targets[@]}
} }
# Change archive's filesystem time to match creation date.
# Usage: archive_touch [FILES]
function archive_touch() {
local IFS=$'\n'
local targets=(${@})
[[ "${targets}" = "" ]] && targets=$(_ls_archive)
process() {
local data=($(_archive_parse "${target}"))
local date=${data[1]}
touch -t ${date} -- ${target}
}
_iterate_targets process ${targets[@]}
}
# Parse archive file name to get: name, date, hash and format. # Parse archive file name to get: name, date, hash and format.
# Usage: _archive_parse <FILENAME> # Usage: _archive_parse <FILENAME>
function _archive_parse() { function _archive_parse() {

View file

@ -29,6 +29,7 @@ Command|Description
`archive_xz [FILES]`|Recompress previously created archive_fast with better compression. `archive_xz [FILES]`|Recompress previously created archive_fast with better compression.
`archive_name [ARCHIVE] [NAME]`|Rename archives. If no name specified, it simplifies archive's name. If no archives specified, apply to all archives. `archive_name [ARCHIVE] [NAME]`|Rename archives. If no name specified, it simplifies archive's name. If no archives specified, apply to all archives.
`unarchive [FILES]`|Extract previously created archive with checksum validation. `unarchive [FILES]`|Extract previously created archive with checksum validation.
`archive_touch [FILES]`|Change archive's filesystem time to match creation date.
## Battery. ## Battery.
@ -43,7 +44,7 @@ Command|Description
---|--- ---|---
`bootstrap_editorconfig`| Install Editorconfig file (with tabs) in current directory. `bootstrap_editorconfig`| Install Editorconfig file (with tabs) in current directory.
`bootstrap_editorconfig_space [AMOUNT]`|Install Editorconfig file (with specified spaces, 8 by default) in current directory. `bootstrap_editorconfig_space [AMOUNT]`|Install Editorconfig file (with specified spaces, 8 by default) in current directory.
`bootstrap_flatpak`| Setup all the flatpak apps on the machine. `bootstrap_nixos <DRIVE> [HOST]`|Install nixos to specified drive. To be run from Live ISO.
## Cd. ## Cd.
@ -211,6 +212,7 @@ Command|Description
`gu [EMAIL]`|Specify git user as Dmitry Voronin with provided email. `gu [EMAIL]`|Specify git user as Dmitry Voronin with provided email.
`gg <REPO>`|Get my git repo. `gg <REPO>`|Get my git repo.
`gdc <COMMITHASH>`|See diff for a specific commit. `gdc <COMMITHASH>`|See diff for a specific commit.
`gv`| Get version number based on commit count.
## Group. ## Group.
@ -271,6 +273,7 @@ Command|Description
`nix_prune`| Free up root space. `nix_prune`| Free up root space.
`nix_shell [NAME]`|Spawn shell with specified nix environment. Uses flake.nix in current dir by default. `nix_shell [NAME]`|Spawn shell with specified nix environment. Uses flake.nix in current dir by default.
`nix_tmpshell <PACKAGES>`|Spawn nix-shell with specified packages. `nix_tmpshell <PACKAGES>`|Spawn nix-shell with specified packages.
`nix_live`| Build live image.
## Notify. ## Notify.