ディレクトリパスをエイリアスで登録して簡単に移動できるgotoコマンドを使ってみる
ディレクトリのパスをエイリアスとして登録して簡単に移動できるgotoっていうコマンドを見つけたから使い方のメモ
インストール
$ mkdir -p ~/.bash $ wget https://raw.githubusercontent.com/iridakos/goto/master/goto.sh -O ~/.bash/goto.sh
.bashrc
に以下を追記する
source ~/.bash/goto.sh
読み込んで
$ source ~/.bashrc
使ってみる
$ goto usage: goto [<option>] <alias> [<directory>] default usage: goto <alias> - changes to the directory registered for the given alias OPTIONS: -r, --register: registers an alias goto -r|--register <alias> <directory> -u, --unregister: unregisters an alias goto -u|--unregister <alias> -p, --push: pushes the current directory onto the stack, then performs goto goto -p|--push <alias> -o, --pop: pops the top directory from the stack, then changes to that directory goto -o|--pop -l, --list: lists aliases goto -l|--list -x, --expand: expands an alias goto -x|--expand <alias> -c, --cleanup: cleans up non existent directory aliases goto -c|--cleanup -h, --help: prints this help goto -h|--help -v, --version: displays the version of the goto script goto -v|--version
使い方
移動
goto <alias>
また、Tab
で補完できる
エイリアス登録(-r
)
-r
--register
goto -r <alias> <directory>
例)~/src/python
をpython
としてエイリアス登録
$ goto -r python ~/src/python
エイリアス登録を解除(-u
)
-u
--unregisters
goto -u <alias>
例)エイリアスのpython
の登録を解除
$ goto -u python
カレントディレクトリをスタックにpushし、goto(-p
)
-p
--push
goto -p <alias>
カレントディレクトリに戻ってきたいときとか使えそう
例)カレントディレクトリをスタックに追加してから、python
に移動
$ pwd /Users/tamago324/dotfiles/ $ goto -p python
スタックからpopし、移動(-o
)
-o
--pop
goto -o
-p
でpushされたスタックからpopし、移動
例)/Users/tamago324/dotfiles/
でgoto -p xxx
としていた場合
$ goto -o $ pwd /Users/tamago324/dotfiles/
スタックに追加していたため、戻れる
エイリアスの一覧(-l
)
-l
--list
goto -l
エイリアスの完全パスを取得(-x
)
-x
--expand
goto -x <alias>
存在しないパスのエイリアスを削除(-c
)
-c
--cleanup
goto -c