This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/git.sh

102 lines
2.4 KiB
Bash
Raw Normal View History

2023-08-08 16:24:15 +03:00
# short aliases.
alias gps="git push"
2023-10-14 02:09:58 +03:00
alias gpsf="git push --force"
2023-08-08 16:24:15 +03:00
alias gpl="git pull"
alias gl="git log"
alias gs="git status"
alias gst="git stash"
alias gd="git diff"
alias gc="git commit -m"
alias gch="git checkout"
alias gchb="git checkout -b"
2023-10-23 04:54:33 +03:00
alias gb="git branch --all"
alias gbd="git branch -D"
alias gbda="git branch | grep -v ^* | xargs git branch -D"
alias gf="git fetch --all -v -p"
2023-08-08 16:24:15 +03:00
alias gt="git tag"
alias gi="git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached"
alias gpc="git diff >"
alias gp="git apply"
2023-10-30 03:49:10 +03:00
# alias to preview diff while adding. adds current dir by default.
# usage: ga [FILES]
2023-08-08 16:24:15 +03:00
ga()
{
2023-10-30 03:49:10 +03:00
local target=${@}
if [[ "${target}" = "" ]]; then
target="."
fi
git diff ${target}
git add ${target}
2023-08-08 16:24:15 +03:00
}
2023-09-30 07:20:31 +03:00
2023-10-30 03:49:10 +03:00
# rebase by X commits or from root. when COUNT is 0 - rebase from root. default is 2.
# usage: gr [COMMIT COUNT]
2023-09-30 07:20:31 +03:00
gr()
{
local base="${1}"
# rebase last 2 commits by default.
if [[ "${base}" = "" ]]; then
base="2"
fi
# if 0, rebase from root. else from specified base.
if [[ "${base}" = "0" ]]; then
git rebase -i --root
else
git rebase -i HEAD~${base}
fi
}
2023-10-12 13:06:34 +03:00
# specify git user as Dmitry Voronin with provided email.
# usage: gu [EMAIL]
2023-10-12 13:06:34 +03:00
gu()
{
local name="Dmitry Voronin"
local email="${1}"
2023-10-12 13:06:34 +03:00
if [[ "${name}" = "" || "${email}" = "" ]]; then
echo "usage: gu [EMAIL]"
2023-11-20 18:39:04 +03:00
return 2
2023-10-12 13:06:34 +03:00
fi
git config user.name "${name}"
git config user.email "${email}"
}
2023-11-18 06:11:37 +03:00
# Get my git repo.
# Usage: gg <REPO>
gg()
{
git clone https://git.voronind.com/voronind/"${1}"
}
2023-10-23 03:31:00 +03:00
# autocomplete.
2023-11-04 23:12:41 +03:00
_completion_loader git &> /dev/null
2023-11-15 00:11:30 +03:00
__git_complete gps _git_push &> /dev/null
2023-11-04 23:12:41 +03:00
__git_complete gpsf _git_push &> /dev/null
__git_complete gpl _git_pull &> /dev/null
__git_complete gl _git_log &> /dev/null
__git_complete gs _git_status &> /dev/null
__git_complete gst _git_stash &> /dev/null
__git_complete gd _git_diff &> /dev/null
__git_complete gc _git_commit &> /dev/null
__git_complete gch _git_checkout &> /dev/null
__git_complete gchb _git_checkout &> /dev/null
__git_complete gb _git_branch &> /dev/null
__git_complete gbd _git_branch &> /dev/null
__git_complete gf _git_fetch &> /dev/null
__git_complete gt _git_tag &> /dev/null
__git_complete gp _git_apply &> /dev/null
__git_complete ga _git_add &> /dev/null
_gu()
{
2023-10-30 03:49:10 +03:00
_autocomplete_first account@voronind.com dd.voronin@fsight.ru
}
complete -F _gu gu