#author("2023-06-15T11:05:52+09:00","default:nobuoki","nobuoki")
#author("2023-06-15T20:49:32+09:00","default:nobuoki","nobuoki")
* 準備 [#r50f9cf9]

#prism(bash){{{
# ログ保存用ディレクトリ
mkdir ~/.tmux

# ログにタイムスタンプを付与し制御コードを削除するスクリプト
tee /tmp/tslog <<'...'
#!/bin/sh
awk '{print strftime("%F %T| ") $0}{fflush() }' |
sed -E "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
...

# 作成したスクリプトをPATHが通っているディレクトリへインストール
sudo install /tmp/tslog /usr/local/bin
}}}

* tmux.conf [#v091888d]

#prism(text){{{
bind-key H pipe-pane 'tslog >"$HOME/.tmux/$(date +%Y%m%d-%H%M%S).log"' \; display-message 'Started logging to $HOME/.tmux/'
bind-key h pipe-pane \; display-message 'Ended logging to $HOME/.tmux/'
bind-key H pipe-pane 'tslog >"$HOME/.tmux/%Y%m%d-%H%M%S-#P.log"' \; display-message 'Started logging to $HOME/.tmux/%Y%m%d-%H%M%S-#P.log'
bind-key h pipe-pane \; display-message 'Ended logging'
}}}

* 参考 [#ha66978e]

- [[tmuxのpipe-paneを利用してリモートサーバでの作業ログをローカルに記録する - Glide Note>https://blog.glidenote.com/blog/2013/02/04/tmux-pipe-pane-logging/]]
- [[linux - In CentOS 4.4, how can I strip escape sequences from a text file? - Server Fault>https://serverfault.com/questions/71285/in-centos-4-4-how-can-i-strip-escape-sequences-from-a-text-file]]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS