Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Record terminal sessions
# Create a log for the sessions
# Record terminal sessions.
# https://unix.stackexchange.com/questions/25639/how-to-automatically-record-all-your-terminal-sessions-with-script-utility
# https://www.2daygeek.com/automatically-record-all-users-terminal-sessions-activity-linux-script-command/
# TODO When changing tabs does not keep the directory
SESSION_LOGS_DIR="$HOME/.session_logs"
if [ ! -d "${SESSION_LOGS_DIR}" ]; then
mkdir -p "${SESSION_LOGS_DIR}"
fi
if [ "x$SESSION_RECORD" = "x" ]; then
TIMESTAMP=$(date -u +%Y%m%d-%H%M%S)
HOSTNAME=$(uname -n)
SESSION_LOG_FILENAME="session.${TIMESTAMP}.${HOSTNAME}.${USER}.$$"
SESSION_RECORD=started
export SESSION_RECORD
script -f -q "${SESSION_LOGS_DIR}/${SESSION_LOG_FILENAME}"
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment