-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliasrc
252 lines (210 loc) · 5.12 KB
/
aliasrc
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
## vim: set fenc=utf-8 ts=2 sw=0 sts=0 sr et si tw=0 fdm=marker fmr={{{,}}} ft=zsh:
##
## aliasrc by Andy3153
## created 26/10/20 ~ 14:42:12
## remade 11/03/24 ~ 01:34:23
##
# {{{ Use doas instead of sudo if available
##
## Also add the ability to use aliases in sudo/doas commands (because of the spaces)
##
if ! command -v doas &> /dev/null
then
alias doas="sudo "
alias sudo="sudo "
else
alias doas="doas "
fi
# }}}
# {{{ Aliases
# Add ddate to clear command
alias clear="clear && startMessage"
# Reload zsh configuration
alias rldzsh="zsh ; exit"
# {{{ Package managers
# {{{ NixOS
if grep -i nixos /etc/lsb-release > /dev/null
then
update()
{
nh os switch --update -- --impure
}
if [ "$(hostname)" != "sparkle" ] # if it's not my main computer
then
update()
{
cdzsh 2>/dev/null && gp --rebase
cdnvim 2>/dev/null && gp --rebase
cdhypr 2>/dev/null && gp --rebase
cdnix 2>/dev/null && gp --rebase
nh os switch -- --impure
}
fi
fi
# }}}
# {{{ Arch-based distros
if command -v pacman &> /dev/null
then
alias p="doas pacman"
update()
{
doas pacman -Syu "$@"; doas flatpak update
}
elif command -v paclabel &> /dev/null
then
alias p="doas paclabel"
alias labels="doas ${EDITOR} /etc/paclabel/labels"
alias flabels="doas ${EDITOR} /etc/paclabel/flatpak-labels"
update()
{
doas paclabel -Syu "$@"; doas flatpak update
}
fi
if command -v paru &> /dev/null
then
alias paru="paru --removemake --pgpfetch --newsonupgrade --bottomup"
alias P="paru"
update()
{
paru -Syu --skipreview "$@"; doas flatpak update
}
fi
# }}}
# {{{ Flatpak
if command -v flatpak &> /dev/null
then
alias f="doas flatpak"
alias fI="doas flatpak install"
alias fU="doas flatpak uninstall"
alias fS="flatpak search"
alias fL="flatpak list"
fi
# }}}
# {{{ Debian-based distros
if command -v apt &> /dev/null
then
alias a="doas apt"
alias ai="doas apt install"
alias ar="doas apt remove"
alias aar="doas apt autoremove"
alias ac="doas apt clean"
alias aac="doas apt autoclean"
alias aupg="doas apt update && doas apt upgrade"
fi
if command -v tap &> /dev/null
then
alias A="doas tap"
alias Ai="doas tap install"
alias Ar="doas tap remove"
alias Aar="doas tap autoremove"
alias Ac="doas tap clean"
alias Aac="doas tap autoclean"
alias Aupg="doas tap update && doas tap upgrade"
fi
# }}}
# }}}
# {{{ Basic navigation
alias lss="ls -alh"
alias cd..="cd .."
alias :q="exit"
alias :Q="exit"
# }}}
# {{{ (n)vi(m)
alias vi="nvim"
alias vim="nvim"
alias dvim="doas nvim"
# }}}
# {{{ Ranger
alias r="source ranger"
alias R="/usr/bin/ranger"
# }}}
# {{{ Systemctl
# Unpriviledged services
alias sc="systemctl"
alias scs="systemctl status"
# Unpriviledged user services
alias scu="systemctl --user"
alias scus="systemctl --user status"
alias scuS="systemctl --user start"
alias scuSS="systemctl --user stop"
alias scuR="systemctl --user restart"
alias scuE="systemctl --user enable"
alias scuD="systemctl --user disable"
alias scuEN="systemctl --user enable --now"
alias scuDN="systemctl --user disable --now"
# Priviledged services
alias dsc="doas systemctl"
alias dscs="doas systemctl status"
alias dscS="doas systemctl start"
alias dscSS="doas systemctl stop"
alias dscR="doas systemctl restart"
alias dscE="doas systemctl enable"
alias dscD="doas systemctl disable"
alias dscEN="doas systemctl enable --now"
alias dscDN="doas systemctl disable --now"
# }}}
# {{{ Git
alias g="git"
alias gc="git clone"
alias gp="git pull"
alias gs="git status"
alias gl="git log"
alias gd="git diff"
alias gdt="git difftool"
alias gS="git stash"
alias gSp="git stash pop"
alias gSD="git stash drop"
alias gR="git rebase --interactive"
alias gA.="git add ."
alias gA="git add"
alias gAp="git add --patch"
alias gAp.="git add --patch ."
alias gC="git commit"
alias gP="git push"
# }}}
# {{{ Docker
alias d="docker"
alias db="docker build"
alias di="docker image"
alias dv="docker volume"
alias dn="docker network"
alias dex="docker exec"
alias dc="docker compose"
# }}}
# {{{ Enter XDG user directories and my homedirs
alias cddesk="cd ${XDG_DESKTOP_DIR}"
alias cddoc="cd ${XDG_DOCUMENTS_DIR}"
alias cddown="cd ${XDG_DOWNLOAD_DIR}"
alias cdmusic="cd ${XDG_MUSIC_DIR}"
alias cdpic="cd ${XDG_PICTURES_DIR}"
alias cdvid="cd ${XDG_VIDEOS_DIR}"
alias cdetc="cd ${HOME}/etc"
alias cdgame="cd ${HOME}/games"
alias cdsrc="cd ${HOME}/src"
alias cdtorr="cd ${HOME}/torrents"
alias cdvm="cd ${HOME}/vms"
# }}}
# {{{ Enter dotfile directories
alias cdzsh="cd $HOME/src/sh/andy3153-zshrc/"
alias cdnvim="cd $HOME/src/nvim/andy3153-init.lua/"
alias cdhypr="cd $HOME/src/hyprland/hyprland-rice/"
alias cdhyprc="cd $HOME/src/hyprland/hyprland-rice/dotconfig"
alias cdhyprl="cd $HOME/src/hyprland/hyprland-rice/dotlocal"
alias cdnix="cd $HOME/src/nixos/nixos-rice/"
alias cdnixmpkg="cd $HOME/src/nixos/my-nixpkgs/"
alias cdnixhw="cd $HOME/src/nixos/nixos-hardware/"
alias cdnixpkg="cd $HOME/src/nixos/nixpkgs/"
# }}}
# {{{ Open tmux inside ssh
ssht()
{
ssh -t "$@" "tmux attach || tmux new"
}
# }}}
# {{{ Run a game
#run_game()
#{
# suspend_compositing.sh suspend & gamemoderun $@ ; suspend_compositing.sh resume
#}
# }}}
# }}}