LoginSignup
6

More than 5 years have passed since last update.

up.shを書いた

Last updated at Posted at 2014-04-24

up.sh

既にありそうな感じだったけど、最近シェルスクリプトを書く事も少なくなって来ていたので、リハビリがてら?久しぶりに書いてみた。

どういうスクリプトかというと

Terminal
$ pwd
/foo/bar/baz/qux/quux
$ up 3
$ pwd
/foo/bar

とまあ、upのあとに引数として数字を渡すと、その数だけ上に移動したりする。

Terminal
$ pwd
/foo/bar/baz/qux/quux
$ up az
$ pwd
/foo/bar/baz

upのあとに文字列を渡すと、カレントディレクトリから引数でgrepして、一番近い位置に移動する。上記の例の場合はazでgrepしてbazのところに一致しているので/foo/bar/bazに移動してる。

なんか妙に階層が深いリポジトリが多くて、移動が大変だったので書いた。玄人ならpushdとかpopdを使うのかもしれないけど……

zとあわせて便利に使ってます。

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
6