From 8802c2ebb76cd2e221b7cd4d38d70723c7dceba7 Mon Sep 17 00:00:00 2001 From: crater2150 Date: Tue, 14 May 2019 14:44:02 +0200 Subject: [PATCH] Add --autostash to git pull and add clone https-to-git autoconvert --- aliases/git | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/aliases/git b/aliases/git index 1d5a15f..1cd8256 100644 --- a/aliases/git +++ b/aliases/git @@ -27,11 +27,11 @@ defvcsfun() { } #VCS command git hg svn -defvcsfun gst "status -s" "status" "status" -defvcsfun gpl "pull" "pull" "update" -defvcsfun gcm "commit" "commit" "commit" -defvcsfun ga "add" "add" "add" -defvcsfun gpu "push" "push" "i_am_not_distributed_please_dont_push_me" +defvcsfun gst "status -s" "status" "status" +defvcsfun gpl "pull --autostash" "pull" "update" +defvcsfun gcm "commit" "commit" "commit" +defvcsfun ga "add" "add" "add" +defvcsfun gpu "push" "push" "i_am_not_distributed_please_dont_push_me" alias gco="git checkout" alias gca="git commit -a" @@ -57,3 +57,26 @@ gls() { alias gll="gls -l" alias glll="gls -la" + +gclone() { + local oldurl + local url=$1 + shift + local git_hosts=( + gitlab2.informatik.uni-wuerzburg.de + github.com + ) + + for host in $git_hosts; do + if [[ "$url" =~ "^https://$host" ]]; then + oldurl=$url + url=${url//https:\/\/$host\//git@$host:} + fi + done + + if [[ -n "$oldurl" ]]; then + echo "Correcting url to $url" + fi + + git clone $url "$@" +}