Skip to content

Instantly share code, notes, and snippets.

@gogromat
Last active November 18, 2023 01:35
Show Gist options
  • Save gogromat/057f60385e145d8e365691ebb859deac to your computer and use it in GitHub Desktop.
Save gogromat/057f60385e145d8e365691ebb859deac to your computer and use it in GitHub Desktop.
Record bash command history `keepy`
# todo: sed this where `alias keepy=` or append to end of ~/.bashrc
cp keepy.sh ~/
chmod +x ~/.keepy.sh
# append to end of ~/.bashrc:
alias keepy="~/.keepy.sh ${@}"
#!/usr/bin/env bash
RAN_AT=$(date +%c)
# log time
echo -e "${RAN_AT}:" | tee -a ~/.keepy.0in.log ~/.keepy.1out.log ~/.keepy.2err.log >-
# log command
echo "$@" | tee -a ~/.keepy.0in.log ~/.keepy.1out.log ~/.keepy.2err.log >- >-
# run command
# + write to out,err logs + stdout
$@ 2> >(tee -a ~/.keepy.2err.log) 1> >(tee -a ~/.keepy.1out.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment