LoginSignup
2

More than 5 years have passed since last update.

よく作業するディレクトリをpecoで選択して移動するコマンド

Posted at

アクティブに作業するディレクトリのパスを予めテキストファイルに書いておいて、pecoでこれらを選択して移動するコマンドをつくりました。

テキストファイル

ホームからの相対パスを書くテキストファイルはホームディレクトリの直下にactives.txtという名前で置きます。

actives.txt(例)
sandbox1/
sandbox2/
reports/lec/L01/
www/

コマンド本体

今回コマンド名はad(active directoriesの略)にしました。下記の内容を.zshrcに書いておけば使えるようになります。

alias ad='cd $HOME/"$(cat ~/actives.txt | peco)"'

実行方法

任意の場所で

$ ad

を実行するだけです。
actives.txtの内容が全くそのまま選択肢として表示されますので、何文字か入力して、pecoの力で絞り込み検索ができます。決定したディレクトリに移動します。

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
2