mirror of
https://github.com/asciinema/asciinema.git
synced 2026-04-24 23:45:50 +03:00
10
Recording tmux session
Meriel Luna Mittelbach edited this page 2025-08-26 15:41:20 +02:00
If you want to record your fancy tmux session with all windows and splits recorded you can do it in the following way:
- setup your tmux session (
tmux new [-s session-name], create windows, splits, start processes in them) - detach (prefix+d)
- run
asciinema rec --command "tmux attach [-t session-name]" tmux-$(date +%F--%H%M).cast - when you're finished, just detach the session again
If you're already inside of tmux, you can detach+reattach in one command:
tmux detach -E 'asciinema rec -c "<tmux attach or tmux new>" tmux.cast'
Consider wrapping it in a shell function (bash/zsh compatible):
tmux-rec() {
local date=$(date +%F_%H%M)
local cmd=(asciinema rec -c "tmux new -s recording-$date" tmux-$date.cast)
if [[ -v TMUX ]]; then tmux detach -E "$(printf '%q ' "${cmd[@]}")"; else "${cmd[@]}"; fi
}