From 4c155682d27397bcf4ccb20833fe2ea341787a8f Mon Sep 17 00:00:00 2001 From: crater2150 Date: Mon, 24 Feb 2020 10:39:39 +0100 Subject: [PATCH] Update gclone alias to use url from clipboard if not specified --- aliases/git | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/aliases/git b/aliases/git index 1cd8256..c056341 100644 --- a/aliases/git +++ b/aliases/git @@ -60,7 +60,15 @@ alias glll="gls -la" gclone() { local oldurl - local url=$1 + local url + if [[ -n $1 ]]; then + url=$1 + else + echo "${fg_bold[green]}Getting url from cliboard:" + url=$(xclip -o -selection clipboard) + echo $url + fi + shift local git_hosts=( gitlab2.informatik.uni-wuerzburg.de @@ -70,7 +78,7 @@ gclone() { for host in $git_hosts; do if [[ "$url" =~ "^https://$host" ]]; then oldurl=$url - url=${url//https:\/\/$host\//git@$host:} + url=$(echo ${url//https:\/\/$host\//git@$host:} | grep -oe '^[^/]*/[^/]*') fi done