LoginSignup
3
3

More than 5 years have passed since last update.

ターミナルで作業ディレクトリのローテーションが便利

Posted at

ターミナルで複数のディレクトリで作業するときに使ってる便利なコマンドです。昔から使ってるのですが、Qiitaに無さそうなので追加。

シェルのpushdを使うとディレクトリをメモしてくれます。popdで戻れるのですが、何度も行き来すると面倒です。

~ $ pushd .
~ $ cd /
/ $ popd
~ $
~ $ cd /

そこで、pushd +1を使うと、ディレクトリを行き来できます。

~ $ pushd .
~ $ cd /
/ $ pushd +1
~ $ pushd +1
/ $ pushd +1

便利そうですね。

しかし、何度も「pushd +1」と書くのは面倒。そこで、aliasしてます。

alias rd='pushd +1'

すると、

~ $ pushd .
~ $ cd /
/ $ rd
~ $ rd
/ $ rd
~ $ rd
/ $ rd
~ $ rd

これだと、簡単に行き来できます。3つ以上のディレクトリでも、ぐるぐるできます。

rd: rotate-directory

です。

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