From 350ea3230a0f7ab21c507c1e3d1a916995a35514 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 19 Dec 2022 21:29:32 +0200 Subject: New alias for git subtree --- .config/zsh/.zshrc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to '.config/zsh') diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index bf3c734..9b92422 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -335,6 +335,42 @@ nnn() { #bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n' alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' +#alias cfg='config subtree pull --prefx' +#alias gsp="git subtree push --prefix=_site git@github.com:mertnuhoglu/blog_datascience.git" +#alias gsp="git subtree push.local/bin/scripts https://github.com/srdusr/scripts.git main --squash +function gsp +{ + # Config file for subtrees + # + # Format: + # ;; + # # Lines starting with '#' will be ignored + GIT_SUBTREE_FILE="$PWD/.gitsubtrees" + + if [ ! -f $GIT_SUBTREE_FILE ]; then + echo "Nothing to do - file <`basename $GIT_SUBTREE_FILE`> does not exist." + return + fi + + OLD_IFS=$IFS + IFS=$'\n' + for LINE in $(cat $GIT_SUBTREE_FILE); do + + # Skip lines starting with '#'. + if [[ $LINE = \#* ]]; then + continue + fi + + # Parse the current line. + PREFIX=`echo $LINE | cut -d';' -f 1` + REMOTE=`echo $LINE | cut -d';' -f 2` + BRANCH=`echo $LINE | cut -d';' -f 3` + + # Push to the remote. + echo "config subtree pull --prefix=$PREFIX $REMOTE $BRANCH" + config subtree pull --prefix=$PREFIX $REMOTE $BRANCH + done +} alias vi='nvim' alias nv='nvim' alias trash="gio trash" -- cgit v1.2.3