macOSでzshを使用しているとき、cliでhistoryコマンド実行時にタイムスタンプを表示させる方法です。
設定方法
~/.zshrcに下記の2行を追加します。(保存したあとsource ~/.zshrc
を実行すると反映されます)
setopt extended_history
alias history='history -t "%F %T"'
その後、適当にコマンドを実行し、history
コマンドを実行します。各業の先頭にコマンドを実行したタイムスタンプが表示されます
$ history
1 2021-03-10 15:08:33 ls
2 2021-03-10 15:08:34 history
3 2021-03-10 15:08:49 cd project
4 2021-03-10 15:08:50 ls -al
5 2021-03-10 15:08:51 ls
こちらもおススメ