tvl-depot/users/riking/dotfiles/fish/functions/gh-clone.fish
Kane York dd94d3036a feat(u/riking/dotfiles): convert bashrc functions to fish
Change-Id: I8a7d1806a8920d31c0b572a4259eef908339e449
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1927
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
2020-09-03 22:03:16 +00:00

18 lines
581 B
Fish

function gh-clone --description 'Clone and CD to a github repository'
if test (count $argv) -eq 1
set user (string split "/" -- $argv[1])[1]
set repo (string split "/" -- $argv[1])[2]
else
set user $argv[1]
set repo $argv[2]
end
if test -d "$HOME/go/src/github.com/$user/$repo"
cd "$HOME/go/src/github.com/$user/$repo"
return 0
end
mkdir -p "$HOME/go/src/github.com/$user"
cd "$HOME/go/src/github.com/$user"
git clone "git@github.com:$user/$repo.git"
cd "$HOME/go/src/github.com/$user/$repo"
end