0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

親より上位の、特定の名称のディレクトリに移動する

Last updated at Posted at 2022-07-06

やりたいこと

  • Git Bash を使っている。
  • 下記2つ以上のシチュエーションで共通して使えるコマンドが欲しかった。
    • /repository/productA/dev/module/hogehoge/...etc 上で、/repository/productA/dev/ に簡単に移動できるコマンドが欲しい
    • 且つ
    • /repository/productB/dev/api/fugafuga/...etc 上で、/repository/productB/dev/ に簡単に移動できるコマンドが欲しい

解決策

cd `echo $PWD | sed "s=\\(/dev\\)/.*=\\1="`

上記コマンドを下記のように、エイリアス(~/.bashrc) に設定して、使えている。

alias dev="cd `echo $PWD | sed "s=\\(/dev\\)/.*=\\1="`"

実行例

$ pwd
/c/repository/productA/dev/module/hogehoge/test

$ dev

$ pwd
/c/repository/productA/dev
0
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?