1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

zshの履歴に日時を表示する(備忘録)

Posted at

実務中に「あの人が問題対応のときに打ったコマンド、何だったっけ?」
と思う場面が度々あったので、備忘としてメモしておきます

環境

pc:MacBook Pro(2019)
os:macos Sequoia
shell ver:zsh 5.9

コマンド

(1)zshである事を確認

echo $SHELL

(2).zshrcに設定追加

echo "setopt extended_history" >> ~/.zshrc
echo "alias history='history -i'" >> ~/.zshrc

setopt extended_history を設定することで、zsh のコマンド履歴に 実行日時(タイムスタンプ) が記録されるようになります。

(3)追加できている事を確認

tail ~/.zshrc

(4)変更を適用

source ~/.zshrc

(5)historyコマンド実行

2025-05-01 10:41といった表記で日付が確認できるようになります

history

実行結果の例:



 1009  2025-05-01 10:41  tail ~/.zshrc
 1010  2025-05-01 10:47  hisotry
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?