-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash_aliases
More file actions
206 lines (182 loc) · 5.85 KB
/
.bash_aliases
File metadata and controls
206 lines (182 loc) · 5.85 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
alias repos='cd ~/Documents/repos'
# git
alias ga='git add'
alias gaa='ga .'
alias gap='git add --patch'
alias gai='git add --interactive'
alias gs='git status -uno'
alias gsg='git status'
alias gss='git status --short'
alias gc='git commit --verbose'
alias gcm='gc -m'
alias gcf='gc --fixup'
alias gcfh='gcf HEAD'
alias gcfa='gcf $(glo --invert-grep -1 --pretty=format:"%h" --grep=fixup\!)'
alias gcam='gc --amend'
alias gcamn='gc --amend --no-edit'
alias gcmi='gcm "Initial Commit"'
alias gcy='yarn commit'
alias gcyr='yarn commit --retry'
alias go='git checkout '
alias yolo='git commit -m "$(curl -s http://whatthecommit.com/index.txt)"'
# find a branch and check it out
function gof {
git branch -a | grep -v remotes | grep $1 | head -n 1 | xargs git checkout
}
alias gom='git checkout master'
alias goma='git checkout main'
alias gob='git checkout -b'
alias go-='git checkout -'
alias gb='git branch'
alias gba='git branch -a'
alias gbv='git branch -vv'
alias gbav='git branch -a -vv'
alias gbsu='git branch --set-upstream-to'
alias gbrn='git branch -m'
alias gdeletemerged='git branch --merged | grep -v \* | xargs git branch -D'
alias plo='git pull origin'
alias plom='git pull origin master'
alias gpl='git pull'
alias gpls='git stash && gpl && git stash apply'
alias gplr='gpl -r'
alias gplmr='git pull origin master -r'
alias gplmar='git pull origin main -r'
alias gplro='gpl -r origin'
alias gf='git fetch --prune'
alias gp='git push'
alias gpsh='git push -u origin HEAD'
alias gpf='git push --force-with-lease'
alias gm='git merge'
alias gmm='git merge master'
alias gma='git merge --abort'
alias gd='git diff'
alias gds='gd --staged'
alias gdst='gd --stat'
alias gr='git reset'
alias gra='git reset .'
alias grs='git reset --soft'
alias grh='git reset --hard'
alias grsh='git reset --soft HEAD^'
# reset to upstream branch
alias grhu='git reset --hard @{upstream}'
alias grmc='git rm -r --cached .; git add .'
# git log
alias gl='git log --oneline -n 15'
alias glv='git log'
alias glog='git log --oneline --graph'
alias glop='git log --pretty=format:"(%h) - %an: %s" --graph'
alias glfancy="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
alias glme='git log --author="Behrens"'
# git stash
alias gsta='git stash'
alias gsap='git stash apply'
alias gsh='git show head'
alias gcl='git clone'
# log changes to a line
function gll() {
git log -L $1,$1:$2
}
alias gdeletelastunpushedcommit='git reset HEAD~1 --hard'
alias gamf='ga && git commit --amend --no-edit && gp --force'
alias gcp='git cherry-pick'
alias grb='git rebase'
alias grbi='git rebase --interactive'
alias grbc='git rebase --continue'
alias grba='git rebase --abort'
alias grbo='git rebase --onto'
alias grbis='git rebase --interactive --autosquash'
alias grbism='git rebase --interactive --autosquash master'
alias grbisa='git rebase --interactive --autosquash $(glo --invert-grep -1 --pretty=format:"%h" --grep=fixup\!)^1'
alias grbmo='git fetch origin && git rebase origin/$(git rev-parse --verify origin/main >/dev/null 2>&1 && echo "main" || echo "master")'
# reset branch to head
alias grsh='git reset HEAD --hard'
alias grso='git reset origin --hard'
# navigation
alias b='cd -'
alias d='cd ~/Documents'
alias p='cd ~/Documents/Projects'
alias m='cd ~/Documents/Projects/messaging'
# vi
alias v='vim'
alias vba='vi ~/.bash_aliases'
alias sba='. ~/.bash_aliases'
alias vbp='vi ~/.bash_profile'
alias sbp='. ~/.bash_profile'
alias vbr='vi ~/.bashrc'
alias vbcs='vi ~/.bash_aliases_cspecific'
alias vrc='vi ~/.vimrc'
# neovim or nvim
# alias n="nvim"
alias nrc="nvim ~/.config/nvim/init.vim"
alias nil="nvim ~/.config/nvim/init.lua"
# scripts
alias mkex='chmod +x'
# alias dog='cat'
# alias cat='bat'
# background services
alias mgo='mongod --config /usr/local/etc/mongod.conf'
alias mpn='top | grep mongod'
alias ip='ifconfig | grep -A 4 en0 | grep "inet " | egrep -oh "([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}" | grep -m 1 ".*"'
# dotfile aliases
alias df='git -C ~ --git-dir ~/.dotfiles/.git/ --work-tree=$HOME'
alias dfd='df diff'
alias dfds='df diff --staged'
alias dfs='df status'
alias dfc='df commit'
alias dfca='df commit -a'
alias dfa='df add'
alias cdf='cd ~/.dotfiles'
alias dfl='df log'
alias dfpl='df pull'
alias dfph='df push'
alias dfsh='df show'
alias dot='dfca -m "Update dotfiles"; df pull; szr; df push --quiet &'
# python stuff
alias serv='python3 -m http.server 8080'
# other fun stuff
alias restart='sudo shutdown -r now'
alias me='cat ~/me'
# directories
alias gift='cd ~/Documents/giftgo'
alias r='cd ~/Documents/repos'
alias 1='cd ~/Documents/repos/wordz'
alias 2='cd ~/Documents/repos/type-race'
# Get pid of process using port 5000
alias pid5='lsof -i tcp:5000'
alias kino='kill $(pid5 | grep -Eo "[0-9]{1,5}" | head -1)'
alias cr='cargo run'
alias cc='cargo check'
alias cb='cargo build'
# computer specific aliases
if [ -f ~/.bash_aliases_cspecific ]; then
. ~/.bash_aliases_cspecific
fi
# run postgres locally
alias pg='pg_ctl -D /opt/homebrew/var/postgresql@16 start'
alias pgs='pg_ctl -D /opt/homebrew/var/postgresql@16 stop'
# claude/ai
alias cl='claude --enable-auto-mode'
mr () {
commit_message=$(git log -1 --pretty=%B)
if [[ -z "$commit_message" ]]; then
echo "Error: No commit message found."
return 1
fi
branch_name=$(echo "$commit_message" | tr '[:upper:]' '[:lower:]' | tr -s '[:space:]' '-' | tr -cd '[:alnum:]-')
branch_name="${branch_name%-}"
git diff --exit-code --quiet
if [[ $? -ne 0 ]]; then
git stash
stash_created=true
fi
git checkout -b "$branch_name"
glab mr create --fill --yes --squash-before-merge --remove-source-branch
git checkout main
git reset --hard @{upstream}
if [[ "$stash_created" == true ]]; then
git stash apply
else
echo "No changes were stashed."
fi
echo "Branch '$branch_name' created and merge request '$commit_message' created successfully."
}