blob: bd0f9f88b87b85b50f77dc147366e4b58cf22362 (
plain)
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
if status is-interactive
## Functions
function handle_colorls
if command -sq colorls
alias ls 'colorls -G -F'
alias ll 'colorls -G -F -l'
alias la 'colorls -G -F -a'
alias lla 'colorls -G -F -l -a'
else
alias ls 'ls -F'
alias la 'ls -F -a'
alias ll 'ls -F -l'
alias lla 'ls -F -l -a'
end
end
function handle_eza
switch $TERM
case 'xterm-256color'
set -f icons 'yes'
case 'xterm-ghostty'
set -f icons 'yes'
case 'xterm-kitty'
set -f icons 'yes'
case 'tmux-256color'
set -f icons 'yes'
case 'foot'
set -f icons 'yes'
case 'xterm'
set -f icons 'no'
case '*'
set -f icons 'no'
end
if string match -q -e 'XTerm/OpenBSD' $XTERM_VERSION
set -f icons 'no'
end
if string match -q -e 'yes' $icons
alias ls 'eza --icons --group'
alias la 'eza --icons --all'
else
alias ls 'eza --group'
alias la 'eza --all'
end
alias ll 'eza --long --group'
alias lt 'eza --tree'
alias lta 'eza --all --tree'
alias lla 'eza --all --long --group'
alias llta 'eza --all --tree --long --group'
end
### Linux
function handle_linux
if command -sq dircolors; and test -f ~/.config/dircolors
eval (dircolors -c ~/.config/dircolors)
end
alias ls 'ls --color=auto -F'
alias la 'ls --color=auto -F -a'
alias ll 'ls --color=auto -F -l'
alias lla 'ls --color=auto -F -l -a'
alias grep 'grep --color=auto'
alias diff 'diff --color=auto'
alias ff 'find . -type f -name'
alias fd 'find . -type d -name'
alias fbs 'find . -xtype l'
alias who 'who -H -w -u'
alias free 'free -h'
alias df 'df -Th'
alias ps 'ps -ejH'
alias lsof 'lsfd'
# If we have iproute2
if command -sq ip
alias ip "ip -c"
alias sockstat "ss -4 -6 -l -r -p"
alias_if_not route ip route
alias_if_not ifconfig ip link
alias_if_not netstat ss -4 -6 -l -r -p
end
# If we have pacman
if command -sq pacman
alias lspkg 'pacman -Q --color=always | rawpager'
alias lspkgi 'pacman -Qett --color=always | rawpager'
alias lspkgo 'pacman -Qdt'
alias pkginfo 'pacman -Qi'
alias pkgsearch 'pacman -Ss'
alias whatpkg 'pacman -Qo'
if fish_is_root_user
alias pkgadd 'pacman -S'
alias pkgrm 'pacman -Rs'
alias pkgupd 'pacman -Syyu'
alias pkgclean 'paccache -k 0 -r'
alias confnew 'find /etc -type f -name "*.pacnew"'
else
alias pkgadd 'sudo pacman -S'
alias pkgrm 'sudo pacman -Rs'
alias pkgupd 'sudo pacman -Syyu'
alias pkgclean 'sudo paccache -k 0 -r'
alias confnew 'sudo find /etc -type f -name "*.pacnew"'
end
function is-installed
pacman -Qq $argv &>/dev/null
end
end
# If we have apk
if command -sq apk
alias lspkg 'apk list -I'
alias lspkgo 'apk list -O'
alias pkginfo 'apk info'
alias pkgsearch 'apk search'
alias whatpkg 'apk info -W'
if fish_is_root_user
alias pkgadd 'apk add'
alias pkgrm 'apk del'
alias pkgupd 'apk update ; apk upgrade'
alias confnew 'find /etc -type f -name "*.apk-new"'
else
alias pkgadd 'doas apk add'
alias pkgrm 'doas apk del'
alias pkgupd 'doas sh -c "apk update ; apk upgrade"'
alias confnew 'doas find /etc/ -type f -name "*.apk-new"'
end
function is-installed
apk info -e $argv &>/dev/null
end
end
# If we have systemd
if command -sq systemctl
alias pss "systemd-cgls"
alias ipconfig "networkctl -a status"
if not fish_is_root_user
alias showdnscache "sudo resolvectl show-cache"
alias cleardnscache "sudo resolvectl flush-caches"
else
alias showdnscache "resolvectl show-cache"
alias cleardnscache "resolvectl flush-caches"
end
alias_if_not nslookup systemd-resolve
end
end # handle_linux
### macOS
function handle_macos
if test -d '/opt/homebrew/bin'
fish_add_path --prepend --global --path '/opt/homebrew/bin'
end
alias ff "find . -type f -name"
alias fd "find . -type d -name"
alias grep "grep --color=auto"
alias nproc "sysctl -n hw.ncpu"
alias lsblk "diskutil list"
alias route "netstat -nr"
# If we have Homebrew
if command -sq brew
alias lspkg 'brew list ; echo ; brew info'
alias pkginfo 'brew info'
alias pkgsearch 'brew search'
alias pkgadd 'brew install'
alias pkgrm 'brew uninstall'
alias pkgupd 'brew update ; echo ; brew upgrade'
function is-installed
brew list -1 | grep -q "^$argv\$"
end
end
# If we have MacPorts
if command -sq port
alias lspkg 'port installed'
alias lspkgo 'port list rleaves'
alias pkginfo 'port info'
alias pkgsearch 'port search'
if fish_is_root_user
alias pkgadd 'port install'
alias pkgrm 'port uninstall'
alias pkgupd 'port upgrade outdated'
else
alias pkgadd 'sudo port install'
alias pkgrm 'sudo port uninstall'
alias pkgupd 'sudo port upgrade outdated'
end
end
end # handle_macos
### NetBSD
function handle_netbsd
handle_colorls
alias nproc 'sysctl -n hw.ncpu'
alias free 'vmstat'
alias lsusb 'usbdevs'
alias lspci 'pcictl pci0 list'
alias lsbat 'envstat -d acpibat0'
alias lspkg 'pkgin list'
alias pkginfo 'pkgin pkg-descr'
alias pkgsearch 'pkgin search'
if fish_is_root_user
alias pkgadd 'pkgin install'
alias pkgrm 'pkgin remove'
alias pkgupd 'pkgin upgrade'
alias pkgclean 'pkgin clean'
else
alias pkgadd 'doas pkgin install'
alias pkgrm 'doas pkgin remove'
alias pkgupd 'doas pkgin upgrade'
alias pkgclean 'doas pkgin clean'
end
end # handle_netbsd
### OpenBSD
function handle_openbsd
handle_colorls
alias nproc 'sysctl -n hw.ncpu'
alias free 'vmstat'
alias lsof 'fstat'
alias lsblk 'sysctl hw.disknames'
alias lspci 'pcidump'
alias ff 'find . -type f -name'
alias fd 'find . -type d -name'
alias fbs 'find . -type l'
alias route 'netstat -nr'
alias lspkg 'pkg_info -A'
alias lspkgo 'pkg_info -t'
alias pkginfo 'pkg_info'
alias pkgsearch 'pkg_info -Q'
if fish_is_root_user
alias pkgadd 'pkg_add'
alias pkgrm 'pkg_delete'
alias pkgupd 'pkg_add -u'
else
alias pkgadd 'doas pkg_add'
alias pkgrm 'doas pkg_delete'
alias pkgupd 'doas pkg_add -u'
end
function is-installed
pkg_info -q -e "$argv->=0"
end
end # handle_openbsd
### FreeBSD
function handle_freebsd
handle_colorls
alias nproc "sysctl -n hw.ncpu"
alias free "vmstat"
alias lsusb "usbconfig list"
alias lspci "pciconf -lv"
alias lsmod "kldstat"
alias insmod "kldload"
alias pkginfo 'pkg info'
if fish_is_root_user
alias pkgadd 'pkg install'
alias pkgrm 'pkg remove'
alias pkgupd 'pkg upgrade'
alias pkgclean 'pkg clean -a'
else
alias pkgadd 'doas pkg install'
alias pkgrm 'doas pkg remove'
alias pkgupd 'doas pkg upgrade'
alias pkgclean 'doas pkg clean -a'
end
end # handle_freebsd
switch (uname)
case 'Linux'
handle_linux
case 'Darwin'
handle_macos
case 'OpenBSD'
handle_openbsd
case 'NetBSD'
handle_netbsd
case 'FreeBSD'
handle_freebsd
end
## All platforms
if command -sq 'eza'
handle_eza
else
if command -sq tree
alias lta 'tree -a'
alias llta 'tree -apugsh'
end
end
alias l 'ls'
alias md 'mkdir'
alias rd 'rmdir'
alias du 'du -h'
alias_if doas sudo
if command -sq git
alias fishupd 'pushd ~/.config/fish ; git pull ; popd'
end
# process viewer to look for by order of preference
set topprg 'htop' 'btop'
set found_topprg (find_prog $topprg)
if test -n "$found_topprg"
alias top "$found_topprg"
end
end
|