This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/dot

55 lines
1.8 KiB
Plaintext
Raw Normal View History

#!/bin/sh
######################################################################
2020-05-23 15:47:21 +02:00
# @author : swytch
# @file : dot
# @license : MIT
2020-05-23 15:47:21 +02:00
# @created : Wednesday May 20, 2020 18:13:05 CEST
#
2020-05-23 15:47:21 +02:00
# @description : git wrapper for dotfiles management
######################################################################
2020-05-06 03:20:19 +02:00
git="/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME"
cmd="$git status" # by default, give the status
2020-05-06 03:20:19 +02:00
[ "$1" = "-g" ] && shift && cmd="$git $@" # make the wrapper transparent
2020-05-06 03:20:19 +02:00
[ "$1" = "-l" ] && shift && cmd="$git log"
[ "$1" = "-lg" ] && shift && cmd="$git log --graph --format=short"
2020-05-06 03:20:19 +02:00
[ "$1" = "-c" ] && shift && cmd="$git commit $@"
[ "$1" = "-ca" ] && shift && cmd="$git commit -a"
[ "$1" = "-cas" ] && shift && cmd="$git commit -S --amend $@"
[ "$1" = "-ch" ] && shift && cmd="$git checkout $@"
2020-05-06 03:20:19 +02:00
[ "$1" = "-mv" ] && shift && cmd="$git mv $@"
[ "$1" = "-ps" ] && shift && cmd="$git push $@"
[ "$1" = "-pl" ] && shift && cmd="$git pull"
[ "$1" = "-a" ] && shift && cmd="$git add $@"
[ "$1" = "-b" ] && shift && cmd="$git branch $@"
[ "$1" = "-s" ] && shift && cmd="$git show $@"
2020-05-06 03:20:19 +02:00
[ "$1" = "-rm" ] && shift && cmd="$git rm --cached $@"
[ "$1" = "-rb" ] && shift && cmd="$git rebase $@"
[ "$1" = "-rbi" ] && shift && cmd="$git rebase -i $@"
[ "$1" = "-rs" ] && shift && cmd="$git reset --soft $@"
2020-05-06 03:20:19 +02:00
[ "$1" = "-d" ] && shift && cmd="$git diff $@"
if [ "$1" = "-m" ] ; then
shift
[ "$1" = "" ] && echo "Please provide a branche to merge from" && exit 1
if [ "$1" != "-a" ] ; then
while [ "$1" != "" ] ; do
2020-05-07 12:58:53 +02:00
$git checkout $1 && $git merge dev
2020-05-06 03:20:19 +02:00
shift
done
else
branches="$(echo "$($git branch)" | sed -e 's/\*/ /;t')"
for arg in $branches ; do
if [ "$arg" != "dev" ] ; then
$git checkout $arg && $git merge dev
fi
done
fi
2020-05-07 12:58:53 +02:00
cmd="$git checkout dev"
2020-05-06 03:20:19 +02:00
fi
$cmd