This repository was archived by the owner on Jun 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys.nu
More file actions
123 lines (108 loc) · 3.14 KB
/
sys.nu
File metadata and controls
123 lines (108 loc) · 3.14 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
#*
#* _ __ _ _
#* __ _ ___ __ _| |_ / _(_) |___ ___ WEBSITE: https://goatfiles.github.io
#* / _` / _ \/ _` | _| _| | / -_|_-< REPOS: https://github.com/goatfiles
#* \__, \___/\__,_|\__|_| |_|_\___/__/ LICENCE: https://github.com/goatfiles/dotfiles/blob/main/LICENSE
#* |___/
#* MAINTAINERS:
#* AMTOINE: https://github.com/amtoine antoine#1306 7C5EE50BA27B86B7F9D5A7BA37AAE9B486CFF1AB
#* ATXR: https://github.com/atxr atxr#6214 3B25AF716B608D41AB86C3D20E55E4B1DE5B2C8B
#*
# TODO: documentation
export def disk [] {
df -h |
str replace "Mounted on" "Mountpoint" |
detect columns |
rename filesystem size used avail used% mountpoint |
into filesize size used avail |
upsert used% {|it| 100 * (1 - $it.avail / $it.size)}
}
# TODO: documentation
export def devices [] {
lsblk -lp |
str replace --all ":" " " |
detect columns |
rename name major minor RM size RO type mountpoints |
into filesize size
}
# TODO: documentation
# credit to terminally_online#9473
# https://discord.com/channels/601130461678272522/615253963645911060/1044604359213858816
export def vuln [] {
ls /sys/devices/system/cpu/vulnerabilities
| each {|it|
{
name: ($it.name | path basename),
migitation: (open $it.name | str trim)
}
}
}
# TODO: documentation
# credit to terminally_online#9473
# https://discord.com/channels/601130461678272522/615253963645911060/1044604359213858816
export def ext4 [] {
ls /sys/fs/ext4/features/ | each {|it|
{
name: ($it.name | path basename),
supported: (open -r $it.name | str trim | $in == "supported" )
}
}
}
# TODO: documentation
# credit to terminally_online#9473
# https://discord.com/channels/601130461678272522/615253963645911060/1044604359213858816
export def uptime [] {
open -r /proc/uptime
| str trim
| split row ' '
| get 0
| $in + "sec"
| into duration
}
# TODO: documentation
# credit to terminally_online#9473
# https://discord.com/channels/601130461678272522/615253963645911060/1044604359213858816
# updated in
# https://discord.com/channels/601130461678272522/615253963645911060/1045037215484498041
export def mounts [
--parse (-p)
] {
let mounts = (
open -r /proc/mounts
| from csv -s " " --noheaders
| rename device mountpoint filesystem options
| drop column 2
)
if ($parse) {
$mounts
| update options {|it|
$it.options
| split row ","
| split column "="
| if ($in | columns | any {|| $it == column2}) {
transpose -i -r -d
} else {
get column1
}
}
} else {
$mounts
}
}
# TODO: documentation
# credit to terminally_online#9473
# https://discord.com/channels/601130461678272522/615253963645911060/1044604359213858816
export def users [] {
open -r /etc/passwd
| from csv -s ':' --noheaders
| rename username password userid groupid comment home shell
| reject password
}
# TODO: documentation
# credit to terminally_online#9473
# https://discord.com/channels/601130461678272522/615253963645911060/1044604359213858816
export def os [] {
open -r /etc/os-release
| from csv -s "=" --noheaders
| rename key value
}