Skip to content

Instantly share code, notes, and snippets.

@svagionitis
Last active April 16, 2020 17:32
Show Gist options
  • Save svagionitis/7a2994ffe26432b4b33930a8751d5c5c to your computer and use it in GitHub Desktop.
Save svagionitis/7a2994ffe26432b4b33930a8751d5c5c to your computer and use it in GitHub Desktop.
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