Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
16
Help us understand the problem. What is going on with this article?
@horimislime

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

More than 5 years have passed since last update.

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で時刻を確認できるようになる。

16
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
16
Help us understand the problem. What is going on with this article?