A better way to do git clone

bash function to do this (works in zsh also):

function lazyclone {
    url=$1;
    reponame=$(echo $url | awk -F/ '{print $NF}' | sed -e 's/.git$//');
    git clone $url $reponame;
    cd $reponame;
}

The awk command prints the part after the last / (e.g from http://example.com/myrepo.git to myrepo.git). The sed command removes the trailing .git

Usage:

$ pwd
~/
$ lazyclone https://github.com/dbr/tvdb_api.git
tvdb_api
Cloning into 'tvdb_api'...
remote: Counting objects: 1477, done.
remote: Compressing objects: 100% (534/534), done.
remote: Total 1477 (delta 952), reused 1462 (delta 940)
Receiving objects: 100% (1477/1477), 268.48 KiB | 202 KiB/s, done.
Resolving deltas: 100% (952/952), done.
$ pwd
~/tvdb_api

With git clone, you can specify the folder to clone to, instead of allowing it to be named automatically.

dir=myclone
git clone git://somerepo "$dir"
cd "$dir"
open "$dir"