2021-07-29 00:37:35 -07:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
# YES_ZSH
|
|
|
|
|
2021-07-30 19:41:16 -07:00
|
|
|
baknow() { ### @-
|
2021-08-01 07:58:21 -07:00
|
|
|
### backup a single file by appending its timestamp given by [`now`.](#now)
|
|
|
|
###
|
|
|
|
### ```
|
|
|
|
### $ touch -d '2001-12-25 16:30:00' butts
|
|
|
|
### $ baknow butts
|
|
|
|
### $ baknow butts
|
|
|
|
### cp: overwrite 'butts.2001-12-26_01800000.bak'? n
|
|
|
|
### $ ls -l
|
|
|
|
### total 0
|
|
|
|
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts
|
|
|
|
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.2001-12-26_01800000.bak
|
|
|
|
### ```
|
|
|
|
###
|
|
|
|
### **TODO:** support multiple files at once.
|
2021-07-29 00:37:35 -07:00
|
|
|
cp -ip "${1:?missing file argument}" "$1.$(now "$1").bak"
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "${SOURCING:-0}" -gt 0 ] || baknow "$@"
|