git clone したディレクトリにすぐ移動する
git clone と同時に、作成されたディレクトリに cd したいなーと思っていたので調べてみた。
以下のように basename を利用して、直前のコマンドの引数を $_ で取得するとうまくいく。
$ git clone http://example.com/example.git && cd $(basename $_ .git)
以下のように関数化して ~/.bash_profile にでも書いておけば楽になる。
gcd() {
git clone "$1" && cd "$(basename "$1" .git)"
}