From 2321b913f89f2bc678c8931db05e0eb5898d7191 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 15 Aug 2023 12:09:07 +0200 Subject: [functions.zsh] added ginit function to init a dir on db remote --- config/essentials/zsh/functions.zsh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'config/essentials/zsh') diff --git a/config/essentials/zsh/functions.zsh b/config/essentials/zsh/functions.zsh index 0d4b8a5..6c2437f 100644 --- a/config/essentials/zsh/functions.zsh +++ b/config/essentials/zsh/functions.zsh @@ -138,16 +138,24 @@ sgd () { unset d } -# Git functions +ginit() +{ + [ "$1" ] || return 1 + ssh db /var/git/initdir.sh "$1" + git remote add origin git@db:"$1.git" + git push --set-upstream origin $(git_current_branch) +} + # Returns current branch -function git_current_branch() +git_current_branch() { command git rev-parse --git-dir &>/dev/null || return git branch --show-current } # Check if main exists and use instead of master -function git_main_branch() { +git_main_branch() +{ command git rev-parse --git-dir &>/dev/null || return local ref for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do -- cgit v1.2.3