Skip to content

Instantly share code, notes, and snippets.

@scriptnull
Last active December 18, 2025 07:02
Show Gist options
  • Select an option

  • Save scriptnull/2048556883f9aade1b2714ce08c92e1e to your computer and use it in GitHub Desktop.

Select an option

Save scriptnull/2048556883f9aade1b2714ce08c92e1e to your computer and use it in GitHub Desktop.
My usual bashrc stuff
export PATH="$PATH:$HOME/s"
export PATH="$PATH:/usr/local/go/bin"
export PATH="$PATH:$HOME/go/bin"
b() {
git rev-parse --abbrev-ref HEAD
}
export -f b
c() {
git checkout $@
}
export -f c
f() {
git fetch origin $@
}
export -f f
p() {
git push origin $@
}
export -f p
fb() {
f $(b)
}
export -f fb
pb() {
p $(b)
}
export -f pb
fr() {
fb && git reset origin/$(b) --hard
}
export -f fr
t() {
local tz="local"
while [[ $# -gt 0 ]]; do
case $1 in
-utc)
tz="UTC"
shift
;;
*)
break
;;
esac
done
if [[ -t 0 ]]; then
# No pipe - print single timestamp
if [[ $tz == "UTC" ]]; then
TZ=UTC date '+%Y-%m-%d %H:%M:%S UTC'
else
date '+%Y-%m-%d %H:%M:%S'
fi
else
# Pipe input - prefix each line
while IFS= read -r line; do
if [[ $tz == "UTC" ]]; then
printf '%s %s\n' "$(TZ=UTC date '+%Y-%m-%d %H:%M:%S UTC')" "$line"
else
printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line"
fi
done
fi
}
export -f t
alias s="git status"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment