-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefaults
executable file
·69 lines (58 loc) · 2.03 KB
/
defaults
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env zsh
# ======================================================================================
# Aliases
# ======================================================================================
# Lot's of aliases will be sourced when we use oh-my-zsh because
# I will be using their git plugin. So, check the cheatsheet.
# https://github.com/ohmyzsh/ohmyzsh/wiki/Cheatsheet#git
alias fit="git"
alias hit="git"
alias gut="git"
alias got="git"
alias grv="git remote -v"
alias gst="git status"
alias gstash="git stash" # default stash.
alias gstashall="git stash -u" # Stash all untracked ones.
alias gp="git push" # default push.
alias gpristinesoft="git clean -dff" # Clears all untracked files.
alias gundo="git reset HEAD~1" # Undo last commit.
# ======================================================================================
# Functions
# ======================================================================================
# Abbreviation suwm: Sync Up with Main/Master
#
# Sync up with main branch. This function is a quick way to
# sync the origin main branch with the upstream main.
#
# @arg $1 main/master default is "master"
function suwm() {
cat <<EOS
Here are the remotes you've added: -
$(git remote -v)
EOS
if ask "Do you want to proceed?" Y; then
local ref=${1:-"master"}
local with_upstream=${2:-true}
gst &&
gstashall &&
if ask "Do you want to clean binaries as well?" N; then
# Loaded via zsh git helpers. It will clean all the
# installed binaries. i.e., node_modules, dist
gpristine
else
gpristinesoft
fi &&
gco "$ref" &&
if [[ "$with_upstream" == true ]]; then
gf "upstream" &&
grb "upstream/$ref" && # git rebase
echo "You have 5 seconds to cancel push 'origin'" &&
sleep 5 &&
gp "origin" "$ref" # git push
else
gf "origin" &&
echo "You have 5 seconds to cancel push 'origin'" &&
gl "origin" "$ref"
fi
fi
}