From 5c92b14bb3910588a5dd2c100f1a2aa67cbf457e Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Fri, 30 Mar 2018 02:26:23 +0530 Subject: [PATCH] [add-command] dotgit -- for managing dotfiles repo in $HOME --- scripts/mkr.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/mkr.sh b/scripts/mkr.sh index d2f3ad1..ab1d648 100644 --- a/scripts/mkr.sh +++ b/scripts/mkr.sh @@ -54,6 +54,26 @@ rmd () { # Git commands +## low-level `dot-git-cmd`, to be used for `dotgit` command +alias dot-git-cmd="git --git-dir=$HOME/.dotfiles --work-tree=$HOME" + +# Manage dotfiles repo +# Usage: dotgit [commands...] +dotgit () { + if [[ $1 == "-d" || $1 == "--diff" ]]; then + dot-git-cmd diff + elif [[ $1 == "-u" || $1 == "--update" ]]; then + dot-git-cmd add $HOME + dot-git-cmd commit -m date + elif [[ $1 == "-p" || $1 == "--push" ]]; then + dot-git-cmd add $HOME + dot-git-cmd commit -m date + dot-git-cmd push + else + dot-git-cmd $1 + fi +} + ## pull ## Usage: pull [remote branch] pull () { @@ -74,7 +94,6 @@ commit () { ## push ## Usage: push [remote branch] ## if only commit message is present, pushes to default upstream - push () { git add . git commit -m "$1"