Skip to content

Commit

Permalink
Add record-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
za3k committed Aug 16, 2022
1 parent 6dfb585 commit 441dff9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ random
---
Print a random line out of a file

record-shell
---
Records all interactive shells using [script](https://en.wikipedia.org/wiki/Script_(Unix)). To use, add the magic line given to the top of your .bashrc (record-shell works on all shells, but the invocation line may need to be changed slightly for each shell)

Note that this can record SSH sessions, sudo session etc fine. However by default it does not include input (typed passwords etc).

Records to /var/log/console-recording/$USER/$DATE.log

retry
---
Retry a command 5 times or until it succeeds
Expand All @@ -335,10 +343,14 @@ Rolls D&D dice.
Usage:

roll "d6 + 4"
roll d6 + 4
roll 2d10

Output:

1d6+4 = 8
1d6+4 = 6
2d10+0 = 19

rtmux
---
Expand Down
13 changes: 13 additions & 0 deletions record-shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Add the following line to .bashrc, etc
# if [[ -f /bin/record-shell && -z "$RECORDING" && $- == *i* ]]; then if shopt -q login_shell; then :; else exec /bin/record-shell; fi; fi
DATE_FORMAT="+%Y-%m-%dT%H:%M:%S"
DATE=`/usr/bin/date "$DATE_FORMAT"`
FILE="/var/log/console-recording/$USER/$DATE.log"
FILE_TIMING="/var/log/console-recording/$USER/$DATE.timing-log"
# echo "To replay: scriptreplay -O $FILE -t $FILE_TIMING"
[ -z "$SHELL" ] && SHELL=/bin/sh
if [ -f /usr/bin/script]; then
exec /usr/bin/env RECORDING=yes /usr/bin/script -q -m advanced --log-timing $FILE_TIMING --log-out "$FILE" -e -c $SHELL "$@"
else
exec /usr/bin/env RECORDING=no $SHELL "$@"
fi

0 comments on commit 441dff9

Please sign in to comment.