LoginSignup
1
0

More than 5 years have passed since last update.

history コマンド結果の表示変更(日付表示、除外コマンド設定)とサジェスト検索方法

Posted at

history コマンドが、さらに使いやすくなるコマンドを知りました。

history コマンド結果に日付を表示させる

設定

$ echo "HISTTIMEFORMAT='%y/%m/%d %H:%M:%S '" >> ~/.bashrc
$ source ~/.bashrc

確認

$ history 10
  513  18/01/11 13:24:09 echo "HISTTIMEFORMAT='%y/%m/%d %H:%M:%S '" >> ~/.bashrc
  514  18/01/11 13:24:10 vi ~/.bashrc
  515  18/01/11 13:24:23 source ~/.bashrc
  516  18/01/11 13:24:27 history 10

historyコマンド結果のサイズを変更する

*Macの初期値は、「500」になっていました

$ echo "HISTSIZE=10000" >> ~/.bashrc
$ source ~/.bashrc

特定のコマンドはhistoryコマンド結果に表示しない

$ echo "HISTIGNORE='ls*:history*'" >> ~/.bashrc
$ source ~/.bashrc

ls で始まるコマンドとhistory で始まるコマンドは、
historyコマンド結果に表示されなくなりました。

サジェスト機能で、コマンド履歴検索を行う

「ctrl + r」 をクリック

下記の表示がされたら、検索キーワードを入力する

(reverse-i-search)`': 

*これまでは、検索機能を知らず、「history | grep cat」のように検索していました。。

1
0
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
0