handle a/b from github

This commit is contained in:
Philip Peterson 2026-05-29 21:32:42 -08:00
parent de07e62e8e
commit da436cd3df

View file

@ -3,6 +3,20 @@ alias gb='git branch'
alias gs='git status'
alias gpcb='git push origin $(git rev-parse --abbrev-ref HEAD)'
function git() {
if [[ $1 == clone && $# -ge 2 ]]; then
local url=$2
# expand foo/bar -> https://github.com/foo/bar.git (no protocol, no dots in host part)
if [[ $url =~ ^[A-Za-z0-9_-]+/[A-Za-z0-9_.-]+$ ]]; then
url="https://github.com/${url%.git}.git"
echo "Cloning $url" >&2
fi
command git clone "$url" "${@:3}"
else
command git "$@"
fi
}
alias u='cd ..'
alias uu='cd ../..'
alias uuu='cd ../../..'