Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
7 Actually `cd` into the dir, rather than just `echo`ing the name
source | link

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting https://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with https://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && echocd $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && echocd ${${_%%.git*}##*/}

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting https://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with https://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && echo $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && echo ${${_%%.git*}##*/}

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting https://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with https://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && cd $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && cd ${${_%%.git*}##*/}
6 replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
source | link

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting http://unix.stackexchange.com/users/5685/frederik-deweerdthttps://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with http://unix.stackexchange.com/users/129926/henrik-nhttps://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && echo $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && echo ${${_%%.git*}##*/}

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting http://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with http://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && echo $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && echo ${${_%%.git*}##*/}

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting https://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with https://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && echo $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && echo ${${_%%.git*}##*/}
5 two other possibilities
source | link

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting http://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with http://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && echo $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && echo ${${_%%.git*}##*/}

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

If you provide the local name of the repo, it's really easy using $_:

git clone git@github.com:npm/npm.git npm-local-dir && cd $_

But if you don't want to re-type long names, it's a little ugly but doable with sed:

git clone git@github.com:pckujawa/pattern-rec.git && 
cd `echo $_ | sed -n -e 's/^.*\/\([^.]*\)\(.git\)*/\1/p'`

EDIT: Well, I was going to thank Manav (comment below) for the terse

git clone foo/bar && cd !$:t

but it doesn't work in zsh (something about how zsh does expansions causes it not to treat the first command as input to !$). I had to look up what !$:t did (Advancing in the Bash Shell | ${me:-whatever}). !$ grabs the last part of the previous command and :t will "Remove all leading file name components, leaving the tail." Good information, but I wish I could get it to work with zsh (I tried noglob with no success).

EDIT: Instead of using sed or !$:t (which doesn't work in zsh, for me anyway), I found two other options (one adapting http://unix.stackexchange.com/users/5685/frederik-deweerdt 's answer with http://unix.stackexchange.com/users/129926/henrik-n 's comment):

git clone git@github.com:npm/npm.git && echo $(basename $_ .git)

or

git clone git@github.com:npm/npm.git && echo ${${_%%.git*}##*/}
4 incorporate comment into answer; fix typo
source | link
3 link text was not semantic; wrap long line
source | link
2 code block formatting
source | link
1
source | link