-
Notifications
You must be signed in to change notification settings - Fork 1
/
bashrc
224 lines (182 loc) · 4.93 KB
/
bashrc
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# Bash
# https://gnu.org/software/bash/
# Starship
# https://starship.rs
eval "$(starship init bash)"
# McFly
# https://github.com/cantino/mcfly
eval "$(mcfly init bash)"
# zoxide
# https://github.com/ajeetdsouza/zoxide
eval "$(zoxide init bash)"
# Aliases ----------------------------------------------------------------------
alias q=exit
alias md='mkdir -p --'
alias _='rm -Rf --'
# Spawns a command.
spawn() {
nohup "$@" < /dev/null > /dev/null 2>&1 &
}
alias @=spawn
# Navigation
alias ..='cd ..'
alias ...='cd ../..'
# ifconfig.co
# https://ifconfig.co
alias ipd='curl ifconfig.co'
# procs
# https://github.com/dalance/procs
alias ps=procs
# rsync
# https://rsync.samba.org
alias rsync='rsync -azH --info=progress2 --delete'
# tar.xz
txz() {
tar caf "$1.tar.xz" "$1"
}
# bat
# https://github.com/sharkdp/bat
alias cat='BAT_THEME=ansi bat'
# curl
# https://curl.haxx.se
alias curl='curl -sSL'
# treeview
# https://github.com/veeso/tui-realm-treeview
alias t=treeview
# Git
# https://git-scm.com
# https://cli.github.com
# https://github.com/extrawurst/gitui
alias g=git
alias G=gitui
alias gw='git add'
alias gw.='gw .'
alias gst='git status'
alias gdiff='git diff'
alias gb='git branch'
alias gco='git checkout'
# Log
# https://git-scm.com/docs/git-log
alias gl='git log'
# Grep logs
alias gF='git log -p -S'
alias gE='git log -p -G'
# Commit
alias gci='git commit'
alias gcm='git commit --message'
alias greword='git commit --amend'
alias gpick='git commit --amend --no-edit'
alias gsnapshot='date "+%F %T" | git commit --file=-'
# Push
# https://git-scm.com/docs/git-push
alias gpush='git push'
# Pull
# https://git-scm.com/docs/git-pull
alias gpull='git pull'
# Undo commit
alias gu='git restore --staged'
alias gD='git restore --staged --worktree'
alias gD.='gD .'
alias gsquash='git reset --soft'
alias gsquash^='git reset --soft HEAD^'
alias grb='git reset --hard'
alias grb^='git reset --hard HEAD^'
alias ggc=git-gc-all-ferocious
# Navigation
alias gcd='cd "$(git rev-parse --show-toplevel)"'
# Web
alias gv='gh repo view --web'
alias gist='gh gist create --web'
gc() {
[ $# -lt 2 ] && suffix=.git
repository=${1}${suffix}
directory=$1; directory=${directory#https://}; directory=${directory%.git}; directory=~/.local/share/$directory
pastel paint green --bold "Cloning '$repository' into '$directory'"
git clone "$repository" "$directory"
}
gc2() {
gc "$1" ''
}
gg() {
gw.
gD.
ggc
}
GG() {
set -- ~/.local/share/github.com/*/* ~/.local/share/gitlab.com/*/* ~/.local/share/git.sr.ht/*/*
for repository do
pastel paint green --bold "$repository"
cd "$repository"
gw.
gD.
ggc
g pull
done
cd
}
# exa
# https://the.exa.website
alias l='exa --icons'
alias la='exa --icons --all'
alias ll='exa --icons --git --long'
alias lla='exa --icons --git --long --all'
alias L='exa --tree'
alias La='exa --tree --all'
# batch
# https://github.com/taupiqueur/batch
# interactive map
imap() {
batch -f 'iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE' -f 'tr [:upper:] [:lower:]' -f "tr -s \\'[:blank:] -" -f 'tr -d ?!,' "$@"
}
# auto map
amap() {
imap -E "$@"
}
# interactive mv
imv() {
imap -p : -M 'mkdir -vp -- "$(dirname -- "$2")" && mv -vi -- "$1" "$2"' -d 'rm -vi --' "$@"
}
# mpv
# https://mpv.io
alias m=mpv
# yt-dlp
# https://github.com/yt-dlp/yt-dlp
alias y=yt-dlp
# Pandoc
# https://pandoc.org
alias pandoc='pandoc --pdf-engine tectonic'
# Ruby on Rails
# https://rubyonrails.org
alias r=rails
alias rr='rails routes --grep'
# Window managers --------------------------------------------------------------
# Sway
# https://swaywm.org
# https://github.com/swaywm/sway/issues/3851
alias sway='WLR_NO_HARDWARE_CURSORS=1 sway'
# IDEs -------------------------------------------------------------------------
# IntelliJ IDEA
# https://jetbrains.com/idea/
# https://github.com/swaywm/sway/issues/595
alias idea-community='_JAVA_AWT_WM_NONREPARENTING=1 @ idea-community'
# Android Studio
# https://developer.android.com/studio
# https://github.com/swaywm/sway/issues/595
alias android-studio='_JAVA_AWT_WM_NONREPARENTING=1 @ android-studio'
# Functions --------------------------------------------------------------------
# Reloads bashrc.
reload_bashrc() {
. ~/.bash_profile
}
# RVM
# https://rvm.io
# . ~/.rvm/scripts/rvm
# macOS ------------------------------------------------------------------------
# Keep MacBook awake with lid closed
# https://caffeinated.app/keep-macbook-awake-with-lid-closed/
alias caffeinate-lid='sudo pmset -b sleep 0; sudo pmset -b disablesleep 1'
alias decaffeinate-lid='sudo pmset -b sleep 5; sudo pmset -b disablesleep 0'
# Sets the PATH environment variable for all services on macOS.
alias set-path='sudo launchctl config user path ~/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/opt/homebrew/sbin:/usr/local/sbin:/usr/sbin:/sbin'
# Erases .DS_Store and .localized files from your home folder.
alias DS_Store="find ~ '(' -name '*.DS_Store' -or -name '*.localized' ')' -print -exec rm -Ri -- {} +"