bin: now / timestamp
This commit is contained in:
parent
5bebfbcbde
commit
d82fe28a77
2 changed files with 30 additions and 8 deletions
28
bin/now
Executable file
28
bin/now
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
style="${1:-iso}"
|
||||
flags=()
|
||||
if [[ "${style}" =~ -utc ]]; then
|
||||
style="${style%-utc}"
|
||||
flags+=('--utc')
|
||||
fi
|
||||
|
||||
format=''
|
||||
case "${style}" in
|
||||
iso) format='--iso-8601=seconds' ;;
|
||||
date) format='+%Y-%m-%d' ;;
|
||||
human) format='+%Y-%m-%d %H:%M %z' ;;
|
||||
unix) format='+%s' ;;
|
||||
js) format='+%s%3N' ;;
|
||||
fs) format='+%Y%m%d_%H%M%S' ;;
|
||||
zone) format='+%z' ;;
|
||||
|
||||
*)
|
||||
>&2 echo "Unknown format: ${style}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exec date "${flags[@]}" "${format}"
|
||||
10
zsh/aliases
10
zsh/aliases
|
|
@ -9,6 +9,8 @@ alias g='git'
|
|||
alias rg='rg -S'
|
||||
alias sg='ast-grep'
|
||||
|
||||
alias timestamp='now'
|
||||
|
||||
# I have never actually meant to start Ghostscript, but I'm sure that I'll want
|
||||
# to be able to someday.
|
||||
alias gs='git status'
|
||||
|
|
@ -16,14 +18,6 @@ alias ghostscript="command gs"
|
|||
|
||||
alias tf='terraform'
|
||||
|
||||
alias timestamp='date "+%Y-%m-%d_%H-%M-%S"'
|
||||
alias datestamp='date "+%Y-%m-%d"'
|
||||
alias humantime='date "+%Y-%m-%d %H:%M %z"'
|
||||
alias unixstamp='date "+%s"'
|
||||
alias jsstamp='date "+%s%3N"'
|
||||
alias isostamp='date --iso-8601=seconds'
|
||||
alias filestamp='date --utc "+%Y%m%dT%H%M%S"'
|
||||
|
||||
alias see='pee "cat >&2"'
|
||||
|
||||
alias psql-ro='PSQLRC=~/.psqlrc-readonly psql'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue