Last active
November 18, 2023 01:35
-
-
Save gogromat/057f60385e145d8e365691ebb859deac to your computer and use it in GitHub Desktop.
Record bash command history `keepy`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 ${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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