LoginSignup
12
3

More than 5 years have passed since last update.

コマンド実行時にハッシュタグをつけて履歴から検索しやすくしてみる

Last updated at Posted at 2017-03-30

本当にちょっとしたことなのですが、

  • よく使うコマンドなのにちゃんと覚えていない
  • 毎回調べるのも面倒
  • 覚えているけど少しでも楽したい
  • Ctrl+r での検索ではノイズが多い
  • かといって専用のツールいれるほどでもない

というときに自分がたまにやる小技です。

コマンド実行
[user@localhost ~]$ find . -type f -print0 | xargs -0 mv -t /var/tmp/ #taihi

#がコメントの書式であることを利用して、ハッシュタグをつけるようなイメージです。
ここでは #taihi というタグをつけてるイメージです。
(コマンドの中身はこちらを参考にさせていただきました)

こうしておいて、あとで Ctrl+r で検索する際に #taihi と入力して、再実行します。

履歴を検索
[user@localhost ~]$ (Ctrl+r入力)
(reverse-i-search)`#taihi': find . -type f -print0 | xargs -0 mv  /var/tmp/ #taihi

参考

12
3
2

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
12
3