(zsh) update cl function to handle gitlab and github

This commit is contained in:
jc 2024-09-18 01:52:47 -04:00
commit 42ae4f3b30
No known key found for this signature in database

View file

@ -89,16 +89,17 @@ cl() {
local ghq_dir="$HOME/ghq" local ghq_dir="$HOME/ghq"
# extract project name # extract project name
if [[ $url =~ git@github\.com:([^/]+)/([^/]+)\.git ]]; then if [[ $url =~ git@git(lab|hub)\.com:([^/]+)/([^/]+)\.git ]]; then
local project_name="${match[1]}" local project_name="${match[2]}"
local repository_name="${match[2]}" local repository_name="${match[3]}"
elif [[ $url =~ https://github\.com/([^/]+)/([^/]+)\.git ]]; then elif [[ $url =~ https://git(lab|hub)\.com/([^/]+)/([^/]+)\.git ]]; then
local project_name="${match[1]}" local project_name="${match[2]}"
local repository_name="${match[2]}" local repository_name="${match[3]}"
elif [[ $# -ne 0 ]]; then elif [[ $# -ne 0 ]]; then
local domain=$1
local project_name="juancwu" local project_name="juancwu"
local repository_name="$url" local repository_name=$2
local url="git@github.com:juancwu/$repository_name.git" local url="git@git$domain.com:$project_name/$repository_name.git"
else else
echo "Invalid URL format" echo "Invalid URL format"
return 1 return 1