-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzalias.zsh
178 lines (140 loc) · 4.58 KB
/
zalias.zsh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
if [[ -z "$XDG_CURRENT_DESKTOP" ]]; then
alias ls='eza'
alias ll='eza --long --all'
alias lt='eza --tree --level=5'
else
alias ls='eza --icons auto'
alias ll='eza --icons auto --long --all'
alias lt='eza --icons auto --tree --level=5'
fi
-() cd -
alias ch='chezmoi'
alias wl='wl-copy'
alias t='trash'
alias q='exit'
alias v='nvim'
for v in 'vi' 'vm' 'vim'; do alias $v='v'; done
alias svim='sudo -Es nvim'
alias sv='svim'
alias lvim='vim -c "normal '\''0"'
alias lv='lvim'
alias g='git'
alias ga='git add'
alias ga.='git add --all'
alias gap='git add --patch'
alias gb='git branch'
alias gba='git branch --all'
alias gbd='git branch --delete'
alias gbD='git branch --delete --force'
alias gbm='git branch --move'
alias gc='git commit'
alias gc.='git add --all && git commit'
alias gc!='git commit --amend'
alias gc.!='git add --all && git commit --amend'
alias gcn!='git commit --amend --no-edit'
alias gcm='git commit --message'
alias gcm.='git add --all && git commit --message'
alias gcm!='git commit --amend --message'
alias gcm.!='git add --all && git commit --amend --message'
alias gcmn!='git commit --amend --no-edit --message'
alias gch='git checkout'
alias gcl='git clone'
alias gclean!='git clean --force -d'
alias gcp='git cherry-pick'
alias gd='git diff'
alias gdl='git diff @~1'
alias gds='git diff --staged'
alias gdm='git diff $(git-default-branch)'
alias gexport='git archive --format zip --output'
alias ghm='cd "$(git rev-parse --show-toplevel)"'
alias gl='git log --oneline'
alias glb='git log --branches --not --remotes --no-walk --oneline'
alias gls='git log --oneline --stat'
alias gln='git log HEAD@{1}..HEAD@{0}' # New, since last pull
alias glw='git whatchanged'
alias gm='git merge'
alias gma='git merge --abort'
alias gmc='git merge --continue'
alias gms='git merge --squash'
alias gmu='git merge upstream/$(git-default-branch)'
alias gmv='git mv'
alias gp='git push'
alias gpd!='git push --delete'
alias gpf!='git push --force-with-lease'
alias gpf!!='git push --force'
alias gpo='git push origin'
alias gpom='git push origin $(git-default-branch)'
alias gpl='git pull'
alias gplu='git pull upstream $(git-default-branch)'
alias gplr='git pull --rebase'
alias gplru='git pull --rebase upstream $(git-default-branch)'
alias gplrs='git pull --rebase --autostash'
alias gP='git pull && git push'
alias gr='git reset'
alias grh='git reset --soft'
alias grh!='git reset --hard'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbi='git rebase --interactive'
alias grbir='git rebase --interactive --root'
alias grbm='git rebase $(git-default-branch)'
alias grbom='git rebase origin/$(git-default-branch)'
alias grbum='git rebase upstream/$(git-default-branch)'
alias grbms='GIT_SEQUENCE_EDITOR=: git rebase $(git-default-branch) --interactive --autosquash'
alias grm!='git rm'
alias grmc='git rm --cached' # Untrack the file, marked as deleted
alias grs!='git restore'
alias grssrc!='git restore --source'
alias grss='git restore --staged'
alias grss.='git restore --staged :/'
alias grt='git remote'
alias grta='git remote add'
alias grts='git remote set-url'
alias grtrn='git remote rename'
alias grtrm='git remote remove'
alias grv='git revert'
alias grva='git revert --abort'
alias gs='git status'
alias gss='git status --short'
alias gsh='git show'
alias gshn='git show --name-only'
alias gst='git stash'
alias gstpo='git stash pop'
alias gstpu='git stash push'
alias gstpum='git stash push -m'
alias gstb='git stash branch'
alias gstd!='git stash drop'
alias gstl='git stash list'
alias gsu='git submodule update --init --recursive'
alias gsur='git submodule update --init --recursive --remote'
alias gsw='git switch'
alias gswc='git switch --create'
alias gswm='git switch $(git-default-branch)'
alias gswt='git switch --track'
alias gt='git tag'
alias gta='git tag --annotate'
alias gtd='git tag --delete'
alias gtl='git tag --list'
alias gf='git fetch --all --prune'
alias gft='git fetch --all --prune --tags'
alias gfr='git fetch && git rebase'
alias gFt='git ls-files . --exclude-standard --others' # Untracked files
alias gFm='git diff --name-only --diff-filter=U' # Unmerged files
alias gmain='git-default-branch'
git-default-branch() {
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
return 1
fi
local local_branch=$(git branch -l 'main' 'master' --format '%(refname:short)' | head -n1)
if [ -n $local_branch ]; then
echo $local_branch
return 0
fi
local remote_branch=$(git symbolic-ref refs/remotes/origin/HEAD)
if [ $? = 0 ]; then
echo $remote_branch | sed 's#^refs/remotes/origin/##'
return 0
fi
return 1
}