(zsh) update cl function to handle gitlab and github
This commit is contained in:
parent
08481e3a0f
commit
42ae4f3b30
1 changed files with 9 additions and 8 deletions
17
zsh/.zshrc
17
zsh/.zshrc
|
|
@ -89,16 +89,17 @@ cl() {
|
|||
local ghq_dir="$HOME/ghq"
|
||||
|
||||
# extract project name
|
||||
if [[ $url =~ git@github\.com:([^/]+)/([^/]+)\.git ]]; then
|
||||
local project_name="${match[1]}"
|
||||
local repository_name="${match[2]}"
|
||||
elif [[ $url =~ https://github\.com/([^/]+)/([^/]+)\.git ]]; then
|
||||
local project_name="${match[1]}"
|
||||
local repository_name="${match[2]}"
|
||||
if [[ $url =~ git@git(lab|hub)\.com:([^/]+)/([^/]+)\.git ]]; then
|
||||
local project_name="${match[2]}"
|
||||
local repository_name="${match[3]}"
|
||||
elif [[ $url =~ https://git(lab|hub)\.com/([^/]+)/([^/]+)\.git ]]; then
|
||||
local project_name="${match[2]}"
|
||||
local repository_name="${match[3]}"
|
||||
elif [[ $# -ne 0 ]]; then
|
||||
local domain=$1
|
||||
local project_name="juancwu"
|
||||
local repository_name="$url"
|
||||
local url="git@github.com:juancwu/$repository_name.git"
|
||||
local repository_name=$2
|
||||
local url="git@git$domain.com:$project_name/$repository_name.git"
|
||||
else
|
||||
echo "Invalid URL format"
|
||||
return 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue