LoginSignup
19
17

More than 5 years have passed since last update.

zshの履歴でコマンド実行時刻を見れるようにする

Posted at

historyコマンドで-dを指定するとコマンドを実行した時刻が表示できる。年月日も見たい場合は-f。

$ history -d
...
 8464  18:17  emacs .zshrc
 8465  18:19  less .zsh_history

 
このままだと現在のセッションで実行したコマンドの時刻しか見れないので、.zsh_historyに実行時刻を記録するよう設定を追加する。

.zshrc
setopt extended_history #share_historyでもOK

 
この設定を加えると、.zsh_historyに実行コマンドと合わせてタイムスタンプが記録されるようになる。

.zsh_history
$ tail -3 .zsh_history
echo foobar
emacs .zshrc
: 1361702407:0;tail -3 .zsh_history

これで閉じたセッションで実行したコマンドもhistoryで時刻を確認できるようになる。

19
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
17