Compare commits
735 commits
9835028199
...
745e8f0a28
Author | SHA1 | Date | |
---|---|---|---|
745e8f0a28 | |||
5fc07cfbc1 | |||
245aa85f29 | |||
317c71fe52 | |||
fbb6e2bb68 | |||
c032849e95 | |||
4325ab4776 | |||
531aa618bb | |||
e4d0b71e5d | |||
4b2cc9a243 | |||
d0bf0958c8 | |||
9eefdb31f8 | |||
c60ab4f5f5 | |||
5e8e84246d | |||
dc301be51d | |||
8260e4e870 | |||
83a3a9d9ba | |||
736fd791c2 | |||
2e622026cd | |||
f9baa85fc7 | |||
eb9725a2c6 | |||
3cdcac9885 | |||
377acbd817 | |||
c3240b8b15 | |||
2f686e3512 | |||
a56aa8124f | |||
dda61e2594 | |||
4d64db0b70 | |||
a0d487f473 | |||
dc66287ed1 | |||
ecff8f16bc | |||
de22cafbd0 | |||
903faba54e | |||
4335005aac | |||
d590bfda0c | |||
7b1e6b0fd5 | |||
1bae77cd6a | |||
897a228614 | |||
e811d73563 | |||
7719b6a562 | |||
4ba9c94a42 | |||
04199bdfbb | |||
f1192c0c58 | |||
32b5389786 | |||
1e5451f059 | |||
24a623bd6e | |||
57da8c6212 | |||
f25059d159 | |||
68a4d51870 | |||
835f7339f3 | |||
75e7e2330d | |||
6eec85df21 | |||
b93a6909bb | |||
321070d5cc | |||
1572a779ae | |||
eee9e38b7d | |||
05271ef828 | |||
4c862481f7 | |||
ff077a039a | |||
ff7f64e670 | |||
13e89092e4 | |||
586373ca3f | |||
86be462cbe | |||
0e8cab41f6 | |||
839c8fa069 | |||
1bc166a046 | |||
a8da17d196 | |||
1507a935b9 | |||
47188ffedd | |||
80463e9213 | |||
b9158be284 | |||
d048757efe | |||
558c5d82c3 | |||
df1fb4f343 | |||
25e7cc4f6c | |||
ec8d1c113c | |||
678cf741c9 | |||
62b8f60841 | |||
df136cbad5 | |||
e9904f2965 | |||
8fb0750b59 | |||
51de08aaa3 | |||
d517b783d7 | |||
47f108f0a3 | |||
c68409c546 | |||
0eaebdf401 | |||
4b9f7df102 | |||
ae8aaec327 | |||
84f6922b6f | |||
e029b00cae | |||
d2ee4678d7 | |||
35626d1104 | |||
20ea46c5e4 | |||
e6e446868d | |||
6eee35b3a4 | |||
bb76a2f956 | |||
c4b7796bb3 | |||
8490621281 | |||
0b2b2acb7b | |||
6b8da7e16b | |||
a52d3595f7 | |||
0ed8b2486c | |||
ee694a8fde | |||
d691f67581 | |||
e305827808 | |||
5ffc9fc840 | |||
cdc976db0b | |||
942de1caed | |||
86db452e72 | |||
510ca5a5b3 | |||
6b45b885c7 | |||
c2a3a130d1 | |||
4cf5783562 | |||
96f0697e37 | |||
dc0540c4ca | |||
844b2f21d3 | |||
beb4695b29 | |||
1dfebbc35a | |||
ce6ca845bc | |||
c641c95c0d | |||
04f64f68a8 | |||
aaa530295e | |||
321d55a823 | |||
aa1226f8f4 | |||
f2544c4243 | |||
9da45266c4 | |||
07483cdadf | |||
8fae0bd63e | |||
14e9e52362 | |||
838dbfc4f5 | |||
c8f6264f20 | |||
a133acea99 | |||
ea17fc995a | |||
d90f0fd6ef | |||
7dfbb947ff | |||
bb08d4c5da | |||
1ad055dfb4 | |||
1a1679031e | |||
67510c2dee | |||
c9c4aa9a6f | |||
3c3f8ffeca | |||
1016240483 | |||
b02b2d183f | |||
d8929dfd4c | |||
05e500c36a | |||
fbe30920d7 | |||
2089e8c1e0 | |||
e33138bab4 | |||
0bbd7a68c1 | |||
e212c967b0 | |||
58090332dd | |||
07f5f9f4e9 | |||
46704e9e37 | |||
bbcbcf28a2 | |||
1061c309c3 | |||
948e22d64f | |||
dce638fcbd | |||
d28e44097c | |||
96db58083c | |||
ec16bff4b0 | |||
39dedbd440 | |||
31e52f9861 | |||
441c42896b | |||
04a86e40ed | |||
e933c159c3 | |||
9e80019ddd | |||
985d4f45a6 | |||
b6ffd72569 | |||
dd4fd93e12 | |||
40e3b95aaf | |||
6588da4ad6 | |||
b13056034b | |||
95ea69c92f | |||
5e21bdec58 | |||
0b4ac490cd | |||
e55392137c | |||
9974f0a99d | |||
81b1f9529c | |||
0f4bd2be85 | |||
63efbb7028 | |||
41ca1b08f8 | |||
3108283a42 | |||
12bc25233c | |||
d418c758d8 | |||
ef0a7a6f28 | |||
4cbdeae4e9 | |||
22c9a66162 | |||
6a7800e19e | |||
491dc1fa1c | |||
15dfd51681 | |||
97e985f266 | |||
08179f386e | |||
743b82cb2d | |||
53957e5690 | |||
b2df5a6eb5 | |||
baa163b5b2 | |||
dcc82f1cf7 | |||
0f312f6c85 | |||
63deee7326 | |||
9522c537b4 | |||
be22e290f4 | |||
8d01c89dc1 | |||
078d3b783e | |||
1ef0f04b07 | |||
464d23cba3 | |||
6d000b2ead | |||
7df87a0517 | |||
c7430d275a | |||
75c3627d2c | |||
ab50952317 | |||
95df4c78e5 | |||
f77081fd17 | |||
92010392ae | |||
aceca1fc69 | |||
f96bcd9a9f | |||
ee10bfe04c | |||
c46896293b | |||
ede62d14ef | |||
ffe24a4c91 | |||
6ab26f5187 | |||
b380b2c0b0 | |||
d82805ff38 | |||
0cce49e919 | |||
aae50d9bef | |||
b9804edd7a | |||
eaaa9662cd | |||
69dac56a26 | |||
b68d4746e6 | |||
3b0f3c14c1 | |||
9a83206f3c | |||
4d8be7e299 | |||
b11bb1c60a | |||
4931f47fe2 | |||
7376790a30 | |||
9910b4786b | |||
02a743fc1b | |||
1084edee23 | |||
12515e6284 | |||
0d3d0bc211 | |||
808d0dc064 | |||
44c771534a | |||
982a81adbe | |||
20f4af36d0 | |||
8262f7c5d0 | |||
dcde6ddbc9 | |||
3d5e4f5a68 | |||
9b05b663da | |||
049eaaff6f | |||
93a9ed20d5 | |||
cb3c7de641 | |||
7363e51f4e | |||
18e2154931 | |||
bbff4013f3 | |||
dcef6d2d62 | |||
975382a359 | |||
cfd529a5d8 | |||
a9fa61d7a8 | |||
237d34eef3 | |||
797b565940 | |||
33a638dbef | |||
941adedaba | |||
d24113e1b0 | |||
03d4f4289c | |||
1bafe4d385 | |||
f4b9f4780c | |||
a6e05017b7 | |||
ae0807bf54 | |||
a38610d0e9 | |||
bb90ce401b | |||
7918a3c336 | |||
df71c07296 | |||
29ac723242 | |||
d34c068990 | |||
f8ed45ad95 | |||
34b6b915f4 | |||
a2efc15707 | |||
dde88afb21 | |||
cd4d7d3fcb | |||
7e788e5940 | |||
033999e9f6 | |||
5f23aadfe5 | |||
e5c43ae676 | |||
79b5c724e4 | |||
af70985d82 | |||
5780c0ed18 | |||
235202a64d | |||
0eea7d052e | |||
5e9ae45748 | |||
19b95e6061 | |||
232f583be3 | |||
58578f9523 | |||
c2ce37595c | |||
7a1320e108 | |||
d8de9913ce | |||
beb479ba7c | |||
7f814102e0 | |||
5539baa340 | |||
c5185768b0 | |||
3554f0b905 | |||
a92770848e | |||
1ddba59759 | |||
ecb6a686f2 | |||
3360a7983d | |||
db596ce969 | |||
01b0224eee | |||
9312698f43 | |||
2acb0be68a | |||
bd4fe3656e | |||
c68598931b | |||
6a49f4981a | |||
dd801e188e | |||
ecb4005b0e | |||
a31401bd77 | |||
8d6b4884a1 | |||
ea5bd6cfb2 | |||
ca0399d4f3 | |||
5af5181aa4 | |||
7ae9eb739a | |||
8df4abafca | |||
ccf058440c | |||
259dbd11d1 | |||
11fc443c8f | |||
db65dea9dd | |||
449f1dadd8 | |||
e2a59923af | |||
a2726f2f3b | |||
c1f5176e25 | |||
03450c9ac7 | |||
6df0543e89 | |||
adddd9af3b | |||
95f52f32eb | |||
e73163d2d3 | |||
3c737f1928 | |||
a5a9beff26 | |||
524ddb8968 | |||
97389ceef7 | |||
895c169599 | |||
c7d3d72e62 | |||
e43429a683 | |||
9d8772d716 | |||
3522a8a2f4 | |||
0c6f8d6dd7 | |||
014ac219ac | |||
213f6ae1f1 | |||
cafe6ab80b | |||
1e6a8d5c2a | |||
9d4c32e34a | |||
c03750a2f3 | |||
dc087a205b | |||
94746ca497 | |||
58ca9eb86f | |||
36aaa275a7 | |||
2b807632b3 | |||
964df6e8dc | |||
5139c4367e | |||
f366620418 | |||
6eaab0b75f | |||
e8dfd1b98a | |||
62ae8d73cc | |||
60adeb9f40 | |||
ce576b7a99 | |||
ba3b90366b | |||
347951cbdf | |||
62a33a5583 | |||
4cc5b8a502 | |||
e27dcc2eb3 | |||
4d888d9784 | |||
bc7b4962f6 | |||
5ff98571f9 | |||
1d86226365 | |||
1a05b48cf5 | |||
9b5d0de840 | |||
8c5b43a4e8 | |||
d7bf240ba0 | |||
6ce158712d | |||
ba5d740362 | |||
4f6e6e7ba2 | |||
1486ff4246 | |||
b73663cf4b | |||
52e7cf8f9c | |||
f52abc28b3 | |||
672b385447 | |||
05710e7ef7 | |||
00183fecc1 | |||
8982496082 | |||
216fe057c9 | |||
6603c88198 | |||
2722134a0f | |||
8d53e86bcd | |||
d028d83f7a | |||
87c53a18ba | |||
818f48d92f | |||
c4e9f06cb2 | |||
3b062767c3 | |||
458e4b60f6 | |||
2a568eeb22 | |||
dae14f780e | |||
f332104d12 | |||
28330ca3c8 | |||
7398fa0726 | |||
76225ff815 | |||
a6e63a6722 | |||
39fdabd885 | |||
c22e6d18ce | |||
8f81cb4455 | |||
0cc06b6de0 | |||
e8c65c9821 | |||
40c151d69e | |||
010cb76003 | |||
b557ddde70 | |||
c4f68fc29b | |||
5e800b713d | |||
7bce373af6 | |||
6be681d0fb | |||
799732c8ef | |||
4590c5cda6 | |||
7611ee6103 | |||
fdffd7fb08 | |||
378e0e530f | |||
3b2df8f8a0 | |||
dfe3be4f1c | |||
5cf0d4021e | |||
11c131e849 | |||
0dfc4d99ed | |||
a4ed6cdbdb | |||
88162d22fe | |||
663d99bb14 | |||
8b39df8ed0 | |||
fbfb4c27e6 | |||
44adf7cc8f | |||
d3bfa52eda | |||
373b40dcf1 | |||
3a2a6a483c | |||
6267af5ef8 | |||
d7e2f15257 | |||
3b979057c1 | |||
6840588cd5 | |||
4e81f18817 | |||
305968a9e6 | |||
fe5c75b142 | |||
671beb4b0e | |||
195b185f6e | |||
976cb6e919 | |||
f163abbd37 | |||
9da2ddeb6f | |||
95828fe06c | |||
3d784b81c4 | |||
304d163d74 | |||
b37e4abc4e | |||
abb6ed3a26 | |||
763d199cde | |||
68d5c0b51a | |||
084c92e50a | |||
918090d9be | |||
dbf1295148 | |||
c2d83e717f | |||
7c8f2d8f49 | |||
cc7e1cafb4 | |||
e139ac7758 | |||
a6180ecd65 | |||
9b9e503225 | |||
9f550c4412 | |||
c4fcfbdca2 | |||
6b81ee0a5a | |||
ddde3e3c6b | |||
98c121d837 | |||
d3a510ab38 | |||
d11ab01afe | |||
ef87d4d410 | |||
1f9ba3b19d | |||
6419243098 | |||
5776a03fe4 | |||
bf1e7539fa | |||
783d5e334e | |||
5f13535022 | |||
33e823024c | |||
7687037070 | |||
8983b9cd9f | |||
63af101db9 | |||
566189cc80 | |||
28e3acd8a7 | |||
bee3710cde | |||
c7659c47fa | |||
0face50a52 | |||
8ab6d5758d | |||
d2ce7a1b74 | |||
d468491ae0 | |||
b693e17e29 | |||
48e29b9e60 | |||
91b0862539 | |||
cb02b15146 | |||
dce03fc9b9 | |||
9b830a7d36 | |||
718d1d1e78 | |||
efada1fce5 | |||
3b05dfecc4 | |||
801f3b859c | |||
0ffbf27412 | |||
6f17ecfec3 | |||
cc8ca58cff | |||
a3191908dd | |||
125e2ac9ca | |||
27329865ee | |||
0ae7d01a1e | |||
5dc81a4508 | |||
925006e496 | |||
b9856a5e32 | |||
f7757d1fbf | |||
018f99c1d6 | |||
75e8940a43 | |||
e32da9d7fa | |||
d2ba729c13 | |||
074d9d5a73 | |||
75ff649291 | |||
2765d87386 | |||
8e7f6b291d | |||
5b750c894b | |||
7cb8f74214 | |||
fad8ddc7e2 | |||
807d4b480d | |||
67e7b951bd | |||
500977a716 | |||
2b654b58f3 | |||
b272ea2181 | |||
fb02c72976 | |||
18fa2453ea | |||
e6d6487010 | |||
f806069845 | |||
382d0489d9 | |||
ca3dc0c2a8 | |||
5a76c09cb1 | |||
c31db13ebf | |||
d8f56b869c | |||
f8f5bb623d | |||
ac69623ed3 | |||
2b1610bbe6 | |||
5ab4a0054a | |||
f571ad3307 | |||
02f2f5323c | |||
cbabed2017 | |||
58829f7045 | |||
b053c65680 | |||
874dd04672 | |||
c00ceaacaf | |||
9e9434e8e0 | |||
a31d85f16a | |||
a98be0588f | |||
abc7186d57 | |||
f796532025 | |||
10aa0b80b5 | |||
6f752c3afc | |||
afc8c6c833 | |||
71f0ef0856 | |||
3972d3ce39 | |||
7cbe78dbc6 | |||
cf4d945350 | |||
969734c4cd | |||
d969810396 | |||
d58afc8226 | |||
eeda17878a | |||
8fbfabb388 | |||
f4cda4c096 | |||
f71653e290 | |||
a5cf152c80 | |||
1624f18fc8 | |||
3ac8efc19d | |||
74a27a077c | |||
d9c6a67d40 | |||
adcc61b377 | |||
0c2df7cb6d | |||
e36e590799 | |||
6bd52d184e | |||
22f0f463df | |||
7905892e59 | |||
4514296ee4 | |||
63b62a6f09 | |||
34ead4eb5d | |||
0606d17293 | |||
2fde68b230 | |||
8dbf695233 | |||
34640e9183 | |||
f6c861e0d9 | |||
7fe64724c2 | |||
ab50c39bbb | |||
7a2d2e3f7e | |||
23c14ff966 | |||
e458a78afe | |||
e692555334 | |||
3ff07ed461 | |||
237953e785 | |||
67580388fa | |||
b6b923e1dd | |||
ad4b5f7e6c | |||
3c0a753049 | |||
5243263397 | |||
76e8b3af28 | |||
8013de8704 | |||
4415132cfd | |||
6cf84b81b3 | |||
9b873d35f2 | |||
dcf5282721 | |||
dee85aab3b | |||
0e8ea7af97 | |||
90b5440f13 | |||
0daec8e9d4 | |||
003d02f226 | |||
0b960f7fba | |||
e876f37b7d | |||
8afbad6e4c | |||
0db196a41c | |||
ffb301e21b | |||
0b7e362582 | |||
633f42b6c2 | |||
52a93c61cc | |||
fde55c7c04 | |||
97f74cb623 | |||
7ffcea4b84 | |||
53a2299f34 | |||
25a8c2f30b | |||
6455d789aa | |||
275b8bdf2c | |||
755e938876 | |||
66b925e0a2 | |||
d5e81ff9c3 | |||
8bc91cc00b | |||
a35d7da975 | |||
57c4d58631 | |||
7358508a93 | |||
70006908fe | |||
d7bee96329 | |||
3e924813c8 | |||
b54d423f87 | |||
3b71c87e03 | |||
060287a127 | |||
3092524d58 | |||
9609171ad6 | |||
80f19583ce | |||
3ffc60e4f1 | |||
b170098755 | |||
3fc442bf70 | |||
4c7ad425b2 | |||
04ccbd37c4 | |||
abe546de10 | |||
d2eb5dd011 | |||
4f043326ee | |||
ffdc0c74e1 | |||
e9694b0c17 | |||
ca65005707 | |||
3911f08261 | |||
e6d67ac56e | |||
afac1464dc | |||
ad467c223c | |||
db5874722a | |||
64c39902a6 | |||
4a500e83ac | |||
a8d4d6373e | |||
81616ae770 | |||
8a99b9e1b7 | |||
c41c49c30d | |||
ab2d3d9141 | |||
e93728cdc5 | |||
6b4410052b | |||
9017b8d905 | |||
26b40b3bd0 | |||
ac2f69eea8 | |||
c89a269e78 | |||
9bd2c799a0 | |||
7557c5b2cc | |||
2c8add321a | |||
bb55e1f358 | |||
42cefc7a49 | |||
4f362fa0c4 | |||
dbd9da9cd8 | |||
6f3ed66c06 | |||
81dc60be1c | |||
b541f2021d | |||
69d9784679 | |||
e26343e222 | |||
e6089c1624 | |||
038ee0cbf3 | |||
5d07b3c14a | |||
39f7ca123d | |||
f271a456fd | |||
cfc99b0cd7 | |||
4930c7bd04 | |||
22077fad31 | |||
b5761c429b | |||
4ce6077f23 | |||
2520fbee34 | |||
5433ef186a | |||
6818171cbc | |||
1f44f63093 | |||
b07230a6a1 | |||
248bbae91b | |||
e25bf7bbfb | |||
45127eab10 | |||
07961df4c9 | |||
b9949d107c | |||
515d64bc2a | |||
b14f4c2f27 | |||
f4f5eb31c9 | |||
76d233d4f7 | |||
9cfd4aa889 | |||
e017ce2785 | |||
c301758e1c | |||
63bb37330a | |||
65f9d3b249 | |||
b7b590a97c | |||
9166e6ff45 | |||
1f75f16a73 | |||
7354deeee2 | |||
6786a4ea2f | |||
b5c4c51ced | |||
0d11ca4ee4 | |||
76f16debb1 | |||
e017d1a5b7 | |||
df61ae9d80 | |||
7fc49d3dd0 | |||
1c05cd488e | |||
a4e9584ae1 | |||
dd1ee57228 | |||
7f1ade34d0 | |||
74c01068b4 | |||
b52612afed | |||
06f5191c7c | |||
3343762acc | |||
7bb0eeecf1 | |||
98056f2fb6 | |||
247b6a7fed | |||
a4697a41fa | |||
596e9b86c2 | |||
3ed56f6453 | |||
e221bf5dfd | |||
8d7b4f3a9c | |||
817924687a |
63 changed files with 2261 additions and 26 deletions
13
readme.md
13
readme.md
|
@ -51,6 +51,8 @@ A tiny framework to read, write & execute things.
|
||||||
|
|
||||||
### Task stack
|
### Task stack
|
||||||
|
|
||||||
|
#### Python
|
||||||
|
|
||||||
* character constants for box drawing
|
* character constants for box drawing
|
||||||
* common __str__ function
|
* common __str__ function
|
||||||
* parse pyproject.toml to write commands
|
* parse pyproject.toml to write commands
|
||||||
|
@ -59,3 +61,14 @@ A tiny framework to read, write & execute things.
|
||||||
* system commands to run
|
* system commands to run
|
||||||
* with single call of subprocess.run
|
* with single call of subprocess.run
|
||||||
* or alternate subprocess method?
|
* or alternate subprocess method?
|
||||||
|
|
||||||
|
#### Shell
|
||||||
|
|
||||||
|
* git switch signing commits & tags
|
||||||
|
* shellcheck & shfmt
|
||||||
|
* python tools
|
||||||
|
* log
|
||||||
|
* hetzner
|
||||||
|
* apt
|
||||||
|
* apt-file search | grep
|
||||||
|
* ffmpeg
|
||||||
|
|
|
@ -5,8 +5,8 @@ __version__ = "0.0.1"
|
||||||
from os import linesep
|
from os import linesep
|
||||||
|
|
||||||
|
|
||||||
class Class:
|
class Object:
|
||||||
"""Root class."""
|
"""Root object."""
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Return machine-readable state.
|
"""Return machine-readable state.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Handle errors."""
|
"""Handle errors."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Error(Class, Exception):
|
class Error(Object, Exception):
|
||||||
"""Parent class for all errors."""
|
"""Parent class for all errors."""
|
||||||
|
|
|
@ -139,11 +139,9 @@ def wipe(path: Path) -> None:
|
||||||
:type path: Path
|
:type path: Path
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(path)
|
|
||||||
except NotADirectoryError:
|
|
||||||
path.unlink(missing_ok=True)
|
path.unlink(missing_ok=True)
|
||||||
except FileNotFoundError:
|
except IsADirectoryError:
|
||||||
pass
|
shutil.rmtree(path)
|
||||||
|
|
||||||
|
|
||||||
def write(file_path: Path, text: str, charset: str = CHARSET) -> None:
|
def write(file_path: Path, text: str, charset: str = CHARSET) -> None:
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class OS(Class, ABC):
|
class OS(Object, ABC):
|
||||||
"""Operating System."""
|
"""Operating System."""
|
||||||
|
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
from rwx.ps import Command
|
from rwx.ps import Command
|
||||||
|
|
||||||
|
|
||||||
class PM(Class, ABC):
|
class PM(Object, ABC):
|
||||||
"""Package Manager."""
|
"""Package Manager."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Project(Class):
|
class Project(Object):
|
||||||
"""Parent class for any type of project."""
|
"""Parent class for any type of project."""
|
||||||
|
|
||||||
def __init__(self, file: Path) -> None:
|
def __init__(self, file: Path) -> None:
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from rwx import Class, txt
|
from rwx import Object, txt
|
||||||
|
|
||||||
|
|
||||||
class Command(Class):
|
class Command(Object):
|
||||||
"""Command to run."""
|
"""Command to run."""
|
||||||
|
|
||||||
def __init__(self, *arguments: str | tuple[str, ...]) -> None:
|
def __init__(self, *arguments: str | tuple[str, ...]) -> None:
|
||||||
|
|
31
rwx/sw/freetube/authors.py
Normal file
31
rwx/sw/freetube/authors.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
"""FreeTube authors."""
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from rwx import Object
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from .playlists import Playlist
|
||||||
|
|
||||||
|
|
||||||
|
class Author(Object):
|
||||||
|
"""FreeTube author."""
|
||||||
|
|
||||||
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
"""Set uid & name.
|
||||||
|
|
||||||
|
:param uid: identifier
|
||||||
|
:type uid: str
|
||||||
|
:param name: label
|
||||||
|
:type name: str
|
||||||
|
"""
|
||||||
|
self.uid = uid
|
||||||
|
self.name = name
|
||||||
|
self.playlist: Playlist
|
||||||
|
|
||||||
|
def to_db(self) -> str:
|
||||||
|
"""Return non-breakable name.
|
||||||
|
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
return self.name.replace(" ", chr(0xA0))
|
|
@ -1,9 +1,9 @@
|
||||||
"""FreeTube channels."""
|
"""FreeTube channels."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Channel(Class):
|
class Channel(Object):
|
||||||
"""FreeTube channel."""
|
"""FreeTube channel."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
24
rwx/sw/freetube/languages.py
Normal file
24
rwx/sw/freetube/languages.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
"""FreeTube languages."""
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from rwx import Object
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from .playlists import Playlist
|
||||||
|
|
||||||
|
|
||||||
|
class Language(Object):
|
||||||
|
"""FreeTube language."""
|
||||||
|
|
||||||
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
"""Set uid & name.
|
||||||
|
|
||||||
|
:param uid: identifier
|
||||||
|
:type uid: str
|
||||||
|
:param name: label
|
||||||
|
:type name: str
|
||||||
|
"""
|
||||||
|
self.uid = uid
|
||||||
|
self.name = name
|
||||||
|
self.playlist: Playlist
|
|
@ -1,11 +1,11 @@
|
||||||
"""FreeTube playlists."""
|
"""FreeTube playlists."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
from .videos import Video
|
from .videos import Video
|
||||||
|
|
||||||
|
|
||||||
class Playlist(Class):
|
class Playlist(Object):
|
||||||
"""FreeTube playlist."""
|
"""FreeTube playlist."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"""FreeTube profiles."""
|
"""FreeTube profiles."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
from .channels import Channel
|
from .channels import Channel
|
||||||
|
|
||||||
|
|
||||||
class Profile(Class):
|
class Profile(Object):
|
||||||
"""FreeTube profile."""
|
"""FreeTube profile."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
"""FreeTube settings."""
|
"""FreeTube settings."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
from .db import to_db
|
from .db import to_db
|
||||||
|
|
||||||
|
|
||||||
class Setting(Class):
|
class Setting(Object):
|
||||||
"""FreeTube setting."""
|
"""FreeTube setting."""
|
||||||
|
|
||||||
def __init__(self, uid: str, value: object) -> None:
|
def __init__(self, uid: str, value: object) -> None:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""FreeTube videos."""
|
"""FreeTube videos."""
|
||||||
|
|
||||||
from rwx import Class
|
from rwx import Object
|
||||||
|
|
||||||
|
|
||||||
class Video(Class):
|
class Video(Object):
|
||||||
"""FreeTube video."""
|
"""FreeTube video."""
|
||||||
|
|
||||||
def __init__(self, uid: str, name: str) -> None:
|
def __init__(self, uid: str, name: str) -> None:
|
||||||
|
|
4
sh/.shellcheckrc
Normal file
4
sh/.shellcheckrc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
disable=3043
|
||||||
|
enable=all
|
||||||
|
external-sources=true
|
||||||
|
shell=sh
|
95
sh/alias/apt.sh
Normal file
95
sh/alias/apt.sh
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
# show package information
|
||||||
|
acl() { a__apt_cache_list "${@}"; }
|
||||||
|
a__apt_cache_list() {
|
||||||
|
apt-cache \
|
||||||
|
show \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# package versions policy
|
||||||
|
acp() { a__apt_cache_policy "${@}"; }
|
||||||
|
a__apt_cache_policy() {
|
||||||
|
apt-cache \
|
||||||
|
policy \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# search package
|
||||||
|
acs() { a__apt_cache_search "${@}"; }
|
||||||
|
a__apt_cache_search() {
|
||||||
|
apt-cache \
|
||||||
|
search \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
agap() { a__apt_get_auto_purge "${@}"; }
|
||||||
|
a__apt_get_auto_purge() {
|
||||||
|
apt-get \
|
||||||
|
autopurge \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
agar() { a__apt_get_auto_remove "${@}"; }
|
||||||
|
a__apt_get_auto_remove() {
|
||||||
|
apt-get \
|
||||||
|
autoremove \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# clean packages cache
|
||||||
|
agc() { a__apt_get_clean "${@}"; }
|
||||||
|
a__apt_get_clean() {
|
||||||
|
apt-get \
|
||||||
|
clean \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# upgrade allowing package installation or removal
|
||||||
|
agfu() { a__apt_get_full_upgrade "${@}"; }
|
||||||
|
a__apt_get_full_upgrade() {
|
||||||
|
apt-get \
|
||||||
|
full-upgrade \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# install packages
|
||||||
|
agi() { a__apt_get_install "${@}"; }
|
||||||
|
a__apt_get_install() {
|
||||||
|
apt-get \
|
||||||
|
install \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
agp() { a__apt_get_purge "${@}"; }
|
||||||
|
a__apt_get_purge() {
|
||||||
|
apt-get \
|
||||||
|
purge \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
agr() { a__apt_get_remove "${@}"; }
|
||||||
|
a__apt_get_remove() {
|
||||||
|
apt-get \
|
||||||
|
remove \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# update packages catalog
|
||||||
|
agud() { a__apt_get_up_date "${@}"; }
|
||||||
|
a__apt_get_up_date() {
|
||||||
|
apt-get \
|
||||||
|
update \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# upgrade forbidding package installation or removal
|
||||||
|
agug() { a__apt_get_up_grade "${@}"; }
|
||||||
|
a__apt_get_up_grade() {
|
||||||
|
apt-get \
|
||||||
|
upgrade \
|
||||||
|
"${@}"
|
||||||
|
}
|
5
sh/alias/batcat.sh
Normal file
5
sh/alias/batcat.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
b() { a__bat "${@}"; }
|
||||||
|
a__bat() {
|
||||||
|
batcat \
|
||||||
|
"${@}"
|
||||||
|
}
|
73
sh/alias/btrfs.sh
Normal file
73
sh/alias/btrfs.sh
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
bfdf() { a__btrfs_filesystem_d_f "${@}"; }
|
||||||
|
a__btrfs_filesystem_d_f() {
|
||||||
|
btrfs \
|
||||||
|
filesystem \
|
||||||
|
df \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bfdu() { a__btrfs_filesystem_d_u "${@}"; }
|
||||||
|
a__btrfs_filesystem_d_u() {
|
||||||
|
btrfs \
|
||||||
|
filesystem \
|
||||||
|
du \
|
||||||
|
--summarize \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bfu() { a__btrfs_filesystem_usage "${@}"; }
|
||||||
|
a__btrfs_filesystem_usage() {
|
||||||
|
btrfs \
|
||||||
|
filesystem \
|
||||||
|
usage \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bpg() { a__btrfs_property_get "${@}"; }
|
||||||
|
a__btrfs_property_get() {
|
||||||
|
btrfs \
|
||||||
|
property \
|
||||||
|
get \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bsc() { a__btrfs_subvolume_create "${@}"; }
|
||||||
|
a__btrfs_subvolume_create() {
|
||||||
|
btrfs \
|
||||||
|
subvolume \
|
||||||
|
create \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bsd() { a__btrfs_subvolume_delete "${@}"; }
|
||||||
|
a__btrfs_subvolume_delete() {
|
||||||
|
btrfs \
|
||||||
|
subvolume \
|
||||||
|
delete \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bsl() { a__btrfs_subvolume_list "${@}"; }
|
||||||
|
a__btrfs_subvolume_list() {
|
||||||
|
if [ -n "${1}" ]; then
|
||||||
|
btrfs subvolume list "${1}" |
|
||||||
|
cut --delimiter " " --fields 9 |
|
||||||
|
sort
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
bss() { a__btrfs_subvolume_snapshot "${@}"; }
|
||||||
|
a__btrfs_subvolume_snapshot() {
|
||||||
|
btrfs \
|
||||||
|
subvolume \
|
||||||
|
snapshot \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bssr() { a__btrfs_subvolume_snapshot_r "${@}"; }
|
||||||
|
a__btrfs_subvolume_snapshot_r() {
|
||||||
|
btrfs \
|
||||||
|
subvolume \
|
||||||
|
snapshot -r \
|
||||||
|
"${@}"
|
||||||
|
}
|
27
sh/alias/byobu.sh
Normal file
27
sh/alias/byobu.sh
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
bb() { a__byo_bu "${@}"; }
|
||||||
|
a__byo_bu() {
|
||||||
|
byobu \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bba() { a__byo_bu_attach "${@}"; }
|
||||||
|
a__byo_bu_attach() {
|
||||||
|
byobu \
|
||||||
|
attach-session \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bbl() { a__byo_bu_ls "${@}"; }
|
||||||
|
a__byo_bu_ls() {
|
||||||
|
byobu \
|
||||||
|
ls \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
bbnd() { a__byo_bu_new_detach "${@}"; }
|
||||||
|
a__byo_bu_new_detach() {
|
||||||
|
byobu \
|
||||||
|
new-session \
|
||||||
|
-d \
|
||||||
|
"${@}"
|
||||||
|
}
|
15
sh/alias/chmod.sh
Normal file
15
sh/alias/chmod.sh
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# change mode to directory
|
||||||
|
cmd() { a__change_mode_directory "${@}"; }
|
||||||
|
a__change_mode_directory() {
|
||||||
|
chmod \
|
||||||
|
"755" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# change mode to file
|
||||||
|
cmf() { a__change_mode_file "${@}"; }
|
||||||
|
a__change_mode_file() {
|
||||||
|
chmod \
|
||||||
|
"644" \
|
||||||
|
"${@}"
|
||||||
|
}
|
15
sh/alias/chown.sh
Normal file
15
sh/alias/chown.sh
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# change owner to root
|
||||||
|
cor() { a__change_owner_root "${@}"; }
|
||||||
|
a__change_owner_root() {
|
||||||
|
chown \
|
||||||
|
"0:0" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# change owner to user
|
||||||
|
cou() { a__change_owner_user "${@}"; }
|
||||||
|
a__change_owner_user() {
|
||||||
|
chown \
|
||||||
|
"1000:1000" \
|
||||||
|
"${@}"
|
||||||
|
}
|
6
sh/alias/clear.sh
Normal file
6
sh/alias/clear.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# clear terminal
|
||||||
|
c() { a__clear "${@}"; }
|
||||||
|
a__clear() {
|
||||||
|
clear \
|
||||||
|
"${@}"
|
||||||
|
}
|
7
sh/alias/cp.sh
Normal file
7
sh/alias/cp.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# copy interactively
|
||||||
|
cpi() { a__co_py_interactive "${@}"; }
|
||||||
|
a__co_py_interactive() {
|
||||||
|
cp \
|
||||||
|
--interactive \
|
||||||
|
"${@}"
|
||||||
|
}
|
5
sh/alias/emacs.sh
Normal file
5
sh/alias/emacs.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
em() { a__e_macs "${@}"; }
|
||||||
|
a__e_macs() {
|
||||||
|
emacs \
|
||||||
|
"${@}"
|
||||||
|
}
|
5
sh/alias/evince.sh
Normal file
5
sh/alias/evince.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
ev() { a__e_vince "${@}"; }
|
||||||
|
a__e_vince() {
|
||||||
|
evince \
|
||||||
|
"${@}"
|
||||||
|
}
|
535
sh/alias/git.sh
Normal file
535
sh/alias/git.sh
Normal file
|
@ -0,0 +1,535 @@
|
||||||
|
SH_GIT_LOG_FORMAT="\
|
||||||
|
%C(auto)%h%d
|
||||||
|
S %C(red)%GS
|
||||||
|
A %C(green)%an %ae
|
||||||
|
%C(green)%ai
|
||||||
|
C %C(blue)%cn %ce
|
||||||
|
%C(blue)%ci
|
||||||
|
%B"
|
||||||
|
|
||||||
|
# add to index
|
||||||
|
ga() { a__git_add "${@}"; }
|
||||||
|
a__git_add() {
|
||||||
|
git \
|
||||||
|
add \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# add all to index
|
||||||
|
gaa() { a__git_add_all "${@}"; }
|
||||||
|
a__git_add_all() {
|
||||||
|
git \
|
||||||
|
add \
|
||||||
|
--all \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# add parts of all to index
|
||||||
|
gaap() { a__git_add_all_patch "${@}"; }
|
||||||
|
a__git_add_all_patch() {
|
||||||
|
git \
|
||||||
|
add \
|
||||||
|
--all \
|
||||||
|
--patch \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# add parts to index
|
||||||
|
gap() { a__git_add_patch "${@}"; }
|
||||||
|
a__git_add_patch() {
|
||||||
|
git \
|
||||||
|
add \
|
||||||
|
--patch \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# create a branch
|
||||||
|
gb() { a__git_branch "${@}"; }
|
||||||
|
a__git_branch() {
|
||||||
|
git \
|
||||||
|
branch \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# delete a branch
|
||||||
|
gbd() { a__git_branch_delete "${@}"; }
|
||||||
|
a__git_branch_delete() {
|
||||||
|
git \
|
||||||
|
branch \
|
||||||
|
--delete \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# force a branch deletion
|
||||||
|
gbdf() { a__git_branch_delete_force "${@}"; }
|
||||||
|
a__git_branch_delete_force() {
|
||||||
|
git \
|
||||||
|
branch \
|
||||||
|
--delete \
|
||||||
|
--force \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# list branches
|
||||||
|
gbl() { a__git_branch_list "${@}"; }
|
||||||
|
a__git_branch_list() {
|
||||||
|
git \
|
||||||
|
branch \
|
||||||
|
--all \
|
||||||
|
--list \
|
||||||
|
--verbose \
|
||||||
|
--verbose \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set the link to a remote branch from a local branch
|
||||||
|
gbsu() { a__git_branch_set_upstream "${@}"; }
|
||||||
|
a__git_branch_set_upstream() {
|
||||||
|
git \
|
||||||
|
branch \
|
||||||
|
--set-upstream-to \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# switch to a branch or checkout file(s) from a commit
|
||||||
|
gc() { a__git_checkout "${@}"; }
|
||||||
|
a__git_checkout() {
|
||||||
|
git \
|
||||||
|
checkout \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# checkout an orphan branch
|
||||||
|
gco() { a__git_checkout_orphan "${@}"; }
|
||||||
|
a__git_checkout_orphan() {
|
||||||
|
git \
|
||||||
|
checkout \
|
||||||
|
--orphan \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# pick a commit
|
||||||
|
gcp() { a__git_cherry_pick "${@}"; }
|
||||||
|
a__git_cherry_pick() {
|
||||||
|
git \
|
||||||
|
cherry-pick \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# abort the commit pick
|
||||||
|
gcpa() { a__git_cherry_pick_abort "${@}"; }
|
||||||
|
a__git_cherry_pick_abort() {
|
||||||
|
git \
|
||||||
|
cherry-pick \
|
||||||
|
--abort \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# continue the commit pick
|
||||||
|
gcpc() { a__git_cherry_pick_continue "${@}"; }
|
||||||
|
a__git_cherry_pick_continue() {
|
||||||
|
git \
|
||||||
|
cherry-pick \
|
||||||
|
--continue \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# clean untracked files
|
||||||
|
gcf() { a__git_clean_force "${@}"; }
|
||||||
|
a__git_clean_force() {
|
||||||
|
git \
|
||||||
|
clean \
|
||||||
|
-d \
|
||||||
|
--force \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# redo the last commit with a different message
|
||||||
|
gcam() { a__git_commit_amend_message "${@}"; }
|
||||||
|
a__git_commit_amend_message() {
|
||||||
|
git \
|
||||||
|
commit \
|
||||||
|
--amend \
|
||||||
|
--message \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# make a root commit
|
||||||
|
gcem() { a__git_commit_empty_message "${@}"; }
|
||||||
|
a__git_commit_empty_message() {
|
||||||
|
git \
|
||||||
|
commit \
|
||||||
|
--allow-empty \
|
||||||
|
--allow-empty-message \
|
||||||
|
--message \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# commit the index
|
||||||
|
gcm() { a__git_commit_message "${@}"; }
|
||||||
|
a__git_commit_message() {
|
||||||
|
git \
|
||||||
|
commit \
|
||||||
|
--message \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# configure the user email
|
||||||
|
gcue() { a__git_config_user_email "${@}"; }
|
||||||
|
a__git_config_user_email() {
|
||||||
|
git \
|
||||||
|
config \
|
||||||
|
"user.email" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# configure the user name
|
||||||
|
gcun() { a__git_config_user_name "${@}"; }
|
||||||
|
a__git_config_user_name() {
|
||||||
|
git \
|
||||||
|
config \
|
||||||
|
"user.name" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# differences from last or between commits
|
||||||
|
gd() { a__git_diff "${@}"; }
|
||||||
|
a__git_diff() {
|
||||||
|
git \
|
||||||
|
diff \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# display what is indexed in cache
|
||||||
|
gdc() { a__git_diff_cached "${@}"; }
|
||||||
|
a__git_diff_cached() {
|
||||||
|
git \
|
||||||
|
diff \
|
||||||
|
--cached \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# indexed character-level differences
|
||||||
|
gdcw() { a__git_diff_cached_word "${@}"; }
|
||||||
|
a__git_diff_cached_word() {
|
||||||
|
git \
|
||||||
|
diff \
|
||||||
|
--cached \
|
||||||
|
--word-diff-regex "." \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# differences via external tool
|
||||||
|
gdt() { a__git_diff_tool "${@}"; }
|
||||||
|
a__git_diff_tool() {
|
||||||
|
git \
|
||||||
|
difftool \
|
||||||
|
--dir-diff \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# character-level differences
|
||||||
|
gdw() { a__git_diff_word "${@}"; }
|
||||||
|
a__git_diff_word() {
|
||||||
|
git \
|
||||||
|
diff \
|
||||||
|
--word-diff-regex "." \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# fetch from the remote repository
|
||||||
|
gf() { a__git_fetch "${@}"; }
|
||||||
|
a__git_fetch() {
|
||||||
|
git \
|
||||||
|
fetch \
|
||||||
|
--tags \
|
||||||
|
--verbose \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# fetch from remote repository and prune local orphan branches
|
||||||
|
gfp() { a__git_fetch_prune "${@}"; }
|
||||||
|
a__git_fetch_prune() {
|
||||||
|
a__git_fetch \
|
||||||
|
--prune \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# garbage collect all orphan commits
|
||||||
|
ggc() { a__git_garbage_collect "${@}"; }
|
||||||
|
a__git_garbage_collect() {
|
||||||
|
git \
|
||||||
|
reflog \
|
||||||
|
expire \
|
||||||
|
--all \
|
||||||
|
--expire "all" &&
|
||||||
|
git \
|
||||||
|
gc \
|
||||||
|
--aggressive \
|
||||||
|
--prune="now"
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize a new repository
|
||||||
|
gi() { a__git_init "${@}"; }
|
||||||
|
a__git_init() {
|
||||||
|
git \
|
||||||
|
init \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize a new bare repository
|
||||||
|
gib() { a__git_init_bare "${@}"; }
|
||||||
|
a__git_init_bare() {
|
||||||
|
git \
|
||||||
|
init \
|
||||||
|
--bare \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# log history
|
||||||
|
gl() { a__git_log "${@}"; }
|
||||||
|
a__git_log() {
|
||||||
|
git \
|
||||||
|
log \
|
||||||
|
--abbrev=8 \
|
||||||
|
--abbrev-commit \
|
||||||
|
--format="${SH_GIT_LOG_FORMAT}" \
|
||||||
|
--graph \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# log all history
|
||||||
|
gla() { a__git_log_all "${@}"; }
|
||||||
|
a__git_log_all() {
|
||||||
|
a__git_log \
|
||||||
|
--all \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# log all history with patches
|
||||||
|
glap() { a__git_log_all_patch "${@}"; }
|
||||||
|
a__git_log_all_patch() {
|
||||||
|
a__git_log \
|
||||||
|
--all \
|
||||||
|
--patch \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# log history with patches
|
||||||
|
glp() { a__git_log_patch "${@}"; }
|
||||||
|
a__git_log_patch() {
|
||||||
|
a__git_log \
|
||||||
|
--patch \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# fast-forward merge to remote branch
|
||||||
|
gm() { a__git_merge "${@}"; }
|
||||||
|
a__git_merge() {
|
||||||
|
git \
|
||||||
|
merge \
|
||||||
|
--ff-only \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# abort the current merge commit
|
||||||
|
gma() { a__git_merge_abort "${@}"; }
|
||||||
|
a__git_merge_abort() {
|
||||||
|
git \
|
||||||
|
merge \
|
||||||
|
--abort \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# do a merge commit
|
||||||
|
gmc() { a__git_merge_commit "${@}"; }
|
||||||
|
a__git_merge_commit() {
|
||||||
|
git \
|
||||||
|
merge \
|
||||||
|
--no-ff \
|
||||||
|
--message \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# squash a branch and index its modifications
|
||||||
|
gms() { a__git_merge_squash "${@}"; }
|
||||||
|
a__git_merge_squash() {
|
||||||
|
git \
|
||||||
|
merge \
|
||||||
|
--squash \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# merge via external tool
|
||||||
|
gmt() { a__git_merge_tool "${@}"; }
|
||||||
|
a__git_merge_tool() {
|
||||||
|
git \
|
||||||
|
mergetool \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# push to the remote repository
|
||||||
|
gp() { a__git_push "${@}"; }
|
||||||
|
a__git_push() {
|
||||||
|
git \
|
||||||
|
push \
|
||||||
|
--tags \
|
||||||
|
--verbose \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# delete from the remote repository
|
||||||
|
gpd() { a__git_push_delete "${@}"; }
|
||||||
|
a__git_push_delete() {
|
||||||
|
git \
|
||||||
|
push \
|
||||||
|
--delete \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# force the push to the remote repository
|
||||||
|
gpf() { a__git_push_force "${@}"; }
|
||||||
|
a__git_push_force() {
|
||||||
|
a__git_push \
|
||||||
|
--force \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# rebase current branch onto another
|
||||||
|
grb() { a__git_re_base "${@}"; }
|
||||||
|
a__git_re_base() {
|
||||||
|
git \
|
||||||
|
rebase \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# abort current rebase
|
||||||
|
grba() { a__git_re_base_abort "${@}"; }
|
||||||
|
a__git_re_base_abort() {
|
||||||
|
git \
|
||||||
|
rebase \
|
||||||
|
--abort \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# continue current rebase
|
||||||
|
grbc() { a__git_re_base_continue "${@}"; }
|
||||||
|
a__git_re_base_continue() {
|
||||||
|
git \
|
||||||
|
rebase \
|
||||||
|
--continue \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# force rebase without fast-forward
|
||||||
|
grbf() { a__git_re_base_force "${@}"; }
|
||||||
|
a__git_re_base_force() {
|
||||||
|
git \
|
||||||
|
rebase \
|
||||||
|
--force-rebase \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# rebase interactively
|
||||||
|
grbi() { a__git_re_base_interactive "${@}"; }
|
||||||
|
a__git_re_base_interactive() {
|
||||||
|
git \
|
||||||
|
rebase \
|
||||||
|
--interactive \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# add a new remote repository
|
||||||
|
grma() { a__git_re_mote_add "${@}"; }
|
||||||
|
a__git_re_mote_add() {
|
||||||
|
git \
|
||||||
|
remote \
|
||||||
|
add \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# list remote repositories
|
||||||
|
grml() { a__git_re_mote_list "${@}"; }
|
||||||
|
a__git_re_mote_list() {
|
||||||
|
git \
|
||||||
|
remote \
|
||||||
|
--verbose \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set the location of a remote repository
|
||||||
|
grmsu() { a__git_re_mote_set_upstream "${@}"; }
|
||||||
|
a__git_re_mote_set_upstream() {
|
||||||
|
git \
|
||||||
|
remote \
|
||||||
|
set-url \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# show connection to a remote repository
|
||||||
|
grms() { a__git_re_mote_show "${@}"; }
|
||||||
|
a__git_re_mote_show() {
|
||||||
|
git \
|
||||||
|
remote \
|
||||||
|
show \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# remove and add removal to index
|
||||||
|
grm() { a__git_re_move "${@}"; }
|
||||||
|
a__git_re_move() {
|
||||||
|
git \
|
||||||
|
rm \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# remove file(s) from index or move current branch pointer
|
||||||
|
grs() { a__git_re_set "${@}"; }
|
||||||
|
a__git_re_set() {
|
||||||
|
git \
|
||||||
|
reset \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# wipe modifications or reset current branch to another commit
|
||||||
|
grsh() { a__git_re_set_hard "${@}"; }
|
||||||
|
a__git_re_set_hard() {
|
||||||
|
git \
|
||||||
|
reset \
|
||||||
|
--hard \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# show a commit
|
||||||
|
gsc() { a__git_show_commit "${@}"; }
|
||||||
|
a__git_show_commit() {
|
||||||
|
git \
|
||||||
|
show \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# current state of repository
|
||||||
|
gs() { a__git_status "${@}"; }
|
||||||
|
a__git_status() {
|
||||||
|
git \
|
||||||
|
status \
|
||||||
|
--untracked-files="all" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# tag a commit
|
||||||
|
gt() { a__git_tag "${@}"; }
|
||||||
|
a__git_tag() {
|
||||||
|
git \
|
||||||
|
tag \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# delete a tag
|
||||||
|
gtd() { a__git_tag_delete "${@}"; }
|
||||||
|
a__git_tag_delete() {
|
||||||
|
git \
|
||||||
|
tag \
|
||||||
|
--delete \
|
||||||
|
"${@}"
|
||||||
|
}
|
14
sh/alias/gpg.sh
Normal file
14
sh/alias/gpg.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# turn gpg agent off
|
||||||
|
gak() { a__gpg_agent_kill "${@}"; }
|
||||||
|
a__gpg_agent_kill() {
|
||||||
|
gpgconf \
|
||||||
|
--kill "gpg-agent"
|
||||||
|
}
|
||||||
|
|
||||||
|
# bind gpg agent to current tty
|
||||||
|
gau() { a__gpg_agent_update "${@}"; }
|
||||||
|
a__gpg_agent_update() {
|
||||||
|
gpg-connect-agent \
|
||||||
|
updatestartuptty \
|
||||||
|
/bye
|
||||||
|
}
|
9
sh/alias/grep.sh
Normal file
9
sh/alias/grep.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# grep from current directory with regex
|
||||||
|
g() { a__grep "${@}"; }
|
||||||
|
a__grep() {
|
||||||
|
grep \
|
||||||
|
--directories "recurse" \
|
||||||
|
--line-number \
|
||||||
|
--regexp \
|
||||||
|
"${@}"
|
||||||
|
}
|
14
sh/alias/kill.sh
Normal file
14
sh/alias/kill.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# kill a process by id
|
||||||
|
k() { a__kill "${@}"; }
|
||||||
|
a__kill() {
|
||||||
|
kill \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# force kill a process by id
|
||||||
|
kf() { a__kill_force "${@}"; }
|
||||||
|
a__kill_force() {
|
||||||
|
kill \
|
||||||
|
-9 \
|
||||||
|
"${@}"
|
||||||
|
}
|
14
sh/alias/killall.sh
Normal file
14
sh/alias/killall.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# kill all instances of a process by name
|
||||||
|
ka() { a__kill_all "${@}"; }
|
||||||
|
a__kill_all() {
|
||||||
|
killall \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# force kill all instances of a process by name
|
||||||
|
kaf() { a__kill_all_force "${@}"; }
|
||||||
|
a__kill_all_force() {
|
||||||
|
killall \
|
||||||
|
-9 \
|
||||||
|
"${@}"
|
||||||
|
}
|
32
sh/alias/ls.sh
Normal file
32
sh/alias/ls.sh
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
export LS_COLORS="\
|
||||||
|
di=0;94\
|
||||||
|
"
|
||||||
|
|
||||||
|
# list current directory’s entries
|
||||||
|
l() { a__ls "${@}"; }
|
||||||
|
a__ls() {
|
||||||
|
ls \
|
||||||
|
--all \
|
||||||
|
--color \
|
||||||
|
-l \
|
||||||
|
-p \
|
||||||
|
--time-style "+" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# list timestamps
|
||||||
|
lt() { a__ls_time "${@}"; }
|
||||||
|
a__ls_time() {
|
||||||
|
a__ls \
|
||||||
|
--time-style "+%Y%m%d-%H%M%S%-:::z" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# list timestamps recent last
|
||||||
|
ltr() { a__ls_time_reverse "${@}"; }
|
||||||
|
a__ls_time_reverse() {
|
||||||
|
a__ls_time \
|
||||||
|
--reverse \
|
||||||
|
-t \
|
||||||
|
"${@}"
|
||||||
|
}
|
31
sh/alias/lsblk.sh
Normal file
31
sh/alias/lsblk.sh
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# list block devices
|
||||||
|
lb() { a__list_block "${@}"; }
|
||||||
|
a__list_block() {
|
||||||
|
a__list_block_output \
|
||||||
|
"SIZE" \
|
||||||
|
"TYPE" \
|
||||||
|
"FSTYPE" \
|
||||||
|
"LABEL" \
|
||||||
|
"MOUNTPOINTS" \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# base arguments
|
||||||
|
lbne() { a__list_block_no_empty "${@}"; }
|
||||||
|
a__list_block_no_empty() {
|
||||||
|
lsblk \
|
||||||
|
--noempty \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# output arguments
|
||||||
|
lbo() { a__list_block_output "${@}"; }
|
||||||
|
a__list_block_output() {
|
||||||
|
local argument
|
||||||
|
local arguments="NAME"
|
||||||
|
for argument in "${@}"; do
|
||||||
|
arguments="${arguments},${argument}"
|
||||||
|
done
|
||||||
|
a__list_block_no_empty \
|
||||||
|
--output "${arguments}"
|
||||||
|
}
|
14
sh/alias/mkdir.sh
Normal file
14
sh/alias/mkdir.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# make a directory
|
||||||
|
md() { a__make_directory "${@}"; }
|
||||||
|
a__make_directory() {
|
||||||
|
mkdir \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# make a directory after making its parents
|
||||||
|
mdp() { a__make_directory_parents "${@}"; }
|
||||||
|
a__make_directory_parents() {
|
||||||
|
mkdir \
|
||||||
|
--parents \
|
||||||
|
"${@}"
|
||||||
|
}
|
5
sh/alias/mount.sh
Normal file
5
sh/alias/mount.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
m() { a__mount "${@}"; }
|
||||||
|
a__mount() {
|
||||||
|
mount \
|
||||||
|
"${@}"
|
||||||
|
}
|
7
sh/alias/mv.sh
Normal file
7
sh/alias/mv.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# move interactively
|
||||||
|
mvi() { a__mo_ve_interactive "${@}"; }
|
||||||
|
a__mo_ve_interactive() {
|
||||||
|
mv \
|
||||||
|
--interactive \
|
||||||
|
"${@}"
|
||||||
|
}
|
5
sh/alias/nano.sh
Normal file
5
sh/alias/nano.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
nn() { a__na_no "${@}"; }
|
||||||
|
a__na_no() {
|
||||||
|
nano \
|
||||||
|
"${@}"
|
||||||
|
}
|
5
sh/alias/newsboat.sh
Normal file
5
sh/alias/newsboat.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
nb() { a__news_boat "${@}"; }
|
||||||
|
a__news_boat() {
|
||||||
|
newsboat \
|
||||||
|
"${@}"
|
||||||
|
}
|
140
sh/alias/overlay.sh
Normal file
140
sh/alias/overlay.sh
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
obm() { a__overlay_bind_mount "${@}"; }
|
||||||
|
a__overlay_bind_mount() {
|
||||||
|
local directory
|
||||||
|
for directory in "dev" "dev/pts" "proc" "sys"; do
|
||||||
|
if ! mount --bind "/${directory}" "overlay/mount/${directory}"; then
|
||||||
|
rwx_log_error "Unable to bind mount directory: ${directory}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
obu() { a__overlay_bind_unmount "${@}"; }
|
||||||
|
a__overlay_bind_unmount() {
|
||||||
|
local directory
|
||||||
|
for directory in "sys" "proc" "dev/pts" "dev"; do
|
||||||
|
if ! umount --lazy "overlay/mount/${directory}"; then
|
||||||
|
rwx_log_error "Unable to bind unmount directory: ${directory}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
ocr() { a__overlay_command_root "${@}"; }
|
||||||
|
a__overlay_command_root() {
|
||||||
|
chroot \
|
||||||
|
"overlay/mount" "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ocu() { a__overlay_command_user "${@}"; }
|
||||||
|
a__overlay_command_user() {
|
||||||
|
chroot \
|
||||||
|
--userspec "1000:1000" \
|
||||||
|
"overlay/mount" "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
omm() { a__overlay_mirror_mount "${@}"; }
|
||||||
|
a__overlay_mirror_mount() {
|
||||||
|
mount --make-rslave --rbind "/deb" "overlay/mount/deb"
|
||||||
|
}
|
||||||
|
|
||||||
|
omu() { a__overlay_mirror_unmount "${@}"; }
|
||||||
|
a__overlay_mirror_unmount() {
|
||||||
|
umount --recursive "overlay/mount/deb"
|
||||||
|
}
|
||||||
|
|
||||||
|
orm() { a__overlay_root_mount "${@}"; }
|
||||||
|
a__overlay_root_mount() {
|
||||||
|
local root="${1}"
|
||||||
|
if [ -z "${root}" ]; then
|
||||||
|
rwx_log_error "No root target directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
root="$(realpath "${root}")"
|
||||||
|
if ! mkdir "overlay"; then
|
||||||
|
rwx_log_error "Unable to make overlay directory"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
(
|
||||||
|
if ! cd "overlay"; then
|
||||||
|
rwx_log_error "Unable to move into overlay directory"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
local directory
|
||||||
|
for directory in "lower" "upper" "work" "mount"; do
|
||||||
|
if ! mkdir --parents "${directory}"; then
|
||||||
|
rwx_log_error "Unable to make directory: ${directory}"
|
||||||
|
return 4
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
local file="${root}/filesystem.squashfs"
|
||||||
|
if ! mount "${file}" "lower"; then
|
||||||
|
rwx_log_error "Unable to lower mount: ${file}"
|
||||||
|
return 5
|
||||||
|
fi
|
||||||
|
if ! mount \
|
||||||
|
-o "lowerdir=lower,upperdir=upper,workdir=work" \
|
||||||
|
-t "overlay" \
|
||||||
|
"overlay" "mount"; then
|
||||||
|
rwx_log_error "Unable to overlay mount"
|
||||||
|
return 6
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ors() { a__overlay_root_squash "${@}"; }
|
||||||
|
a__overlay_root_squash() {
|
||||||
|
local directory="${1}"
|
||||||
|
local file
|
||||||
|
local level="${2}"
|
||||||
|
if [ -n "${directory}" ]; then
|
||||||
|
if mkdir "${directory}"; then
|
||||||
|
[ -n "${level}" ] || level="18"
|
||||||
|
for file in "vmlinuz" "initrd.img"; do
|
||||||
|
cp "overlay/mount/${file}" "${directory}"
|
||||||
|
done
|
||||||
|
mksquashfs \
|
||||||
|
"overlay/mount" "${directory}/filesystem.squashfs" \
|
||||||
|
-noappend \
|
||||||
|
-comp "zstd" -Xcompression-level "${level}"
|
||||||
|
chown --recursive 1000:1000 "${directory}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
oru() { a__overlay_root_unmount "${@}"; }
|
||||||
|
a__overlay_root_unmount() {
|
||||||
|
(
|
||||||
|
if ! cd "overlay"; then
|
||||||
|
rwx_log_error "Unable to move into overlay directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ! umount "mount"; then
|
||||||
|
rwx_log_error "Unable to unmount mount directory"
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
if ! rmdir "mount"; then
|
||||||
|
rwx_log_error "Unable to remove mount directory"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
local directory
|
||||||
|
for directory in "upper" "work"; do
|
||||||
|
if ! rm --force --recursive "${directory}"; then
|
||||||
|
rwx_log_error "Unable to remove directory: ${directory}"
|
||||||
|
return 4
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ! umount "lower"; then
|
||||||
|
rwx_log_error "Unable to unmount lower directory"
|
||||||
|
return 5
|
||||||
|
fi
|
||||||
|
if ! rmdir "lower"; then
|
||||||
|
rwx_log_error "Unable to remove lower directory"
|
||||||
|
return 6
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
if ! rmdir "overlay"; then
|
||||||
|
rwx_log_error "Unable to remove overlay directory"
|
||||||
|
return 7
|
||||||
|
fi
|
||||||
|
}
|
14
sh/alias/pass.sh
Normal file
14
sh/alias/pass.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# display pass entry’s content
|
||||||
|
p() { a__pass "${@}"; }
|
||||||
|
a__pass() {
|
||||||
|
pass \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# copy passphrase into clipboard
|
||||||
|
pc() { a__pass_clip "${@}"; }
|
||||||
|
a__pass_clip() {
|
||||||
|
pass \
|
||||||
|
--clip \
|
||||||
|
"${@}"
|
||||||
|
}
|
7
sh/alias/pgrep.sh
Normal file
7
sh/alias/pgrep.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# look for a string in processes names
|
||||||
|
pg() { a__proc_grep "${@}"; }
|
||||||
|
a__proc_grep() {
|
||||||
|
pgrep \
|
||||||
|
--list-full \
|
||||||
|
"${@}"
|
||||||
|
}
|
17
sh/alias/pwgen.sh
Normal file
17
sh/alias/pwgen.sh
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# generate passwords
|
||||||
|
pwg() { a__pass_word_gen "${@}"; }
|
||||||
|
a__pass_word_gen() {
|
||||||
|
pwgen \
|
||||||
|
-1 \
|
||||||
|
--num-passwords 1048576 \
|
||||||
|
--secure \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# generate passwords with symbols
|
||||||
|
pwgs() { a__pass_word_gen_symbols "${@}"; }
|
||||||
|
a__pass_word_gen_symbols() {
|
||||||
|
a__pass_word_gen \
|
||||||
|
--symbols \
|
||||||
|
"${@}"
|
||||||
|
}
|
7
sh/alias/rm.sh
Normal file
7
sh/alias/rm.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# remove interactively
|
||||||
|
rmi() { a__re_move_interactive "${@}"; }
|
||||||
|
a__re_move_interactive() {
|
||||||
|
rm \
|
||||||
|
--interactive \
|
||||||
|
"${@}"
|
||||||
|
}
|
27
sh/alias/rsync.sh
Normal file
27
sh/alias/rsync.sh
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# synchronize
|
||||||
|
rs() { a__r_sync "${@}"; }
|
||||||
|
a__r_sync() {
|
||||||
|
rsync \
|
||||||
|
--archive \
|
||||||
|
--no-inc-recursive \
|
||||||
|
--partial \
|
||||||
|
--progress \
|
||||||
|
--verbose \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# synchronize and delete after
|
||||||
|
rsda() { a__r_sync_delete_after "${@}"; }
|
||||||
|
a__r_sync_delete_after() {
|
||||||
|
a__r_sync \
|
||||||
|
--delete-after \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# synchronize and delete before
|
||||||
|
rsdb() { a__r_sync_delete_before "${@}"; }
|
||||||
|
a__r_sync_delete_before() {
|
||||||
|
a__r_sync \
|
||||||
|
--delete-before \
|
||||||
|
"${@}"
|
||||||
|
}
|
29
sh/alias/shell.sh
Normal file
29
sh/alias/shell.sh
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# shorten alias
|
||||||
|
a() {
|
||||||
|
alias \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# swap directory (current ↔ previous)
|
||||||
|
sd() {
|
||||||
|
cd \
|
||||||
|
- ||
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# exit terminal
|
||||||
|
x() {
|
||||||
|
exit \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
[ "${RWX_SHELL}" = "bash" ] || return
|
||||||
|
|
||||||
|
# shellcheck disable=SC3033
|
||||||
|
..() {
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
# shellcheck disable=SC3033
|
||||||
|
...() {
|
||||||
|
cd ../..
|
||||||
|
}
|
31
sh/alias/tar.sh
Normal file
31
sh/alias/tar.sh
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
tc() { a__tar_create "${@}"; }
|
||||||
|
a__tar_create() {
|
||||||
|
a__tar_verbose \
|
||||||
|
--create \
|
||||||
|
--auto-compress \
|
||||||
|
--file \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
tl() { a__tar_list "${@}"; }
|
||||||
|
a__tar_list() {
|
||||||
|
a__tar_verbose \
|
||||||
|
--list \
|
||||||
|
--file \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
tv() { a__tar_verbose "${@}"; }
|
||||||
|
a__tar_verbose() {
|
||||||
|
tar \
|
||||||
|
--verbose \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
tx() { a__tar_xtract "${@}"; }
|
||||||
|
a__tar_xtract() {
|
||||||
|
a__tar_verbose \
|
||||||
|
--extract \
|
||||||
|
--file \
|
||||||
|
"${@}"
|
||||||
|
}
|
5
sh/alias/tmux.sh
Normal file
5
sh/alias/tmux.sh
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
tm() { a__t_mux "${@}"; }
|
||||||
|
a__t_mux() {
|
||||||
|
tmux \
|
||||||
|
"${@}"
|
||||||
|
}
|
12
sh/alias/tree.sh
Normal file
12
sh/alias/tree.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
t() { a__tree "${@}"; }
|
||||||
|
a__tree() {
|
||||||
|
tree \
|
||||||
|
"${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ta() { a__tree_all "${@}"; }
|
||||||
|
a__tree_all() {
|
||||||
|
tree \
|
||||||
|
-a \
|
||||||
|
"${@}"
|
||||||
|
}
|
76
sh/debian.sh
Normal file
76
sh/debian.sh
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
RWX_DEBIAN_CODENAME="$(
|
||||||
|
grep "VERSION_CODENAME" "/etc/os-release" |
|
||||||
|
cut --delimiter "=" --fields "2"
|
||||||
|
)"
|
||||||
|
|
||||||
|
rwx_apt_clean() {
|
||||||
|
apt-get \
|
||||||
|
clean
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_apt_conf_write() {
|
||||||
|
printf "\
|
||||||
|
Acquire::AllowInsecureRepositories False;
|
||||||
|
Acquire::AllowWeakRepositories False;
|
||||||
|
Acquire::AllowDowngradeToInsecureRepositories False;
|
||||||
|
Acquire::Check-Valid-Until True;
|
||||||
|
APT::Install-Recommends False;
|
||||||
|
APT::Install-Suggests False;
|
||||||
|
APT::Get::Show-Versions True;
|
||||||
|
Dir::Etc::SourceParts \"\";
|
||||||
|
Dpkg::Progress True;
|
||||||
|
" >"/etc/apt/apt.conf.d/apt.conf"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_apt_install_backports() {
|
||||||
|
rwx_apt_install_target "${RWX_DEBIAN_CODENAME}-backports" "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_apt_install_release() {
|
||||||
|
rwx_apt_install_target "${RWX_DEBIAN_CODENAME}" "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_apt_install_target() {
|
||||||
|
local target="${1}"
|
||||||
|
shift
|
||||||
|
local package
|
||||||
|
for package in "${@}"; do
|
||||||
|
rwx_log "" \
|
||||||
|
"${package} ← ${target}"
|
||||||
|
apt-get \
|
||||||
|
install \
|
||||||
|
--assume-yes \
|
||||||
|
--target-release "${target}" \
|
||||||
|
"${package}"
|
||||||
|
rwx_apt_clean
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_apt_sources_write() {
|
||||||
|
printf "%s" "\
|
||||||
|
deb https://deb.debian.org/debian \
|
||||||
|
${RWX_DEBIAN_CODENAME} main non-free-firmware contrib non-free
|
||||||
|
deb https://deb.debian.org/debian \
|
||||||
|
${RWX_DEBIAN_CODENAME}-backports main non-free-firmware contrib non-free
|
||||||
|
deb https://deb.debian.org/debian \
|
||||||
|
${RWX_DEBIAN_CODENAME}-updates main non-free-firmware contrib non-free
|
||||||
|
deb https://deb.debian.org/debian-security \
|
||||||
|
${RWX_DEBIAN_CODENAME}-security main non-free-firmware contrib non-free
|
||||||
|
" >"/etc/apt/sources.list"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_apt_update() {
|
||||||
|
apt-get \
|
||||||
|
update
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_apt_upgrade() {
|
||||||
|
apt-get \
|
||||||
|
upgrade \
|
||||||
|
--assume-yes
|
||||||
|
rwx_apt_clean
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_debian_frontend_disable() {
|
||||||
|
export DEBIAN_FRONTEND="noninteractive"
|
||||||
|
}
|
121
sh/fs.sh
Normal file
121
sh/fs.sh
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
rwx_fs_make_btrfs() {
|
||||||
|
local device="${1}"
|
||||||
|
local label="${2}"
|
||||||
|
local uuid="${3}"
|
||||||
|
if [ -b "${device}" ]; then
|
||||||
|
set -- \
|
||||||
|
--force \
|
||||||
|
--checksum "sha256"
|
||||||
|
if [ -n "${label}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
--label "${label}"
|
||||||
|
fi
|
||||||
|
if [ -n "${uuid}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
--uuid "${uuid}"
|
||||||
|
fi
|
||||||
|
mkfs.btrfs "${@}" "${device}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_fs_make_btrfs_swap() {
|
||||||
|
local path="${1}"
|
||||||
|
local size="${2}"
|
||||||
|
local uuid="${3}"
|
||||||
|
if [ -n "${path}" ]; then
|
||||||
|
set -- filesystem mkswapfile
|
||||||
|
if [ -n "${size}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
--size "${size}"
|
||||||
|
fi
|
||||||
|
if [ -n "${uuid}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
--uuid "${uuid}"
|
||||||
|
fi
|
||||||
|
btrfs "${@}" "${path}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_fs_make_fat() {
|
||||||
|
local device="${1}"
|
||||||
|
local name="${2}"
|
||||||
|
local volid="${3}"
|
||||||
|
if [ -b "${device}" ]; then
|
||||||
|
set -- \
|
||||||
|
-F 32 \
|
||||||
|
-S 4096
|
||||||
|
if [ -n "${name}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
-n "${name}"
|
||||||
|
fi
|
||||||
|
if [ -n "${volid}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
-i "${volid}"
|
||||||
|
fi
|
||||||
|
mkfs.fat "${@}" "${device}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_fs_raid_create() {
|
||||||
|
if [ -n "${4}" ]; then
|
||||||
|
local name="${1}"
|
||||||
|
local uuid="${2}"
|
||||||
|
shift 2
|
||||||
|
mdadm \
|
||||||
|
--create "/dev/md/${name}" \
|
||||||
|
--level 0 \
|
||||||
|
--metadata 1 \
|
||||||
|
--name "md:${name}" \
|
||||||
|
--raid-devices ${#} \
|
||||||
|
--uuid "${uuid}" \
|
||||||
|
"${@}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_fs_wipe() {
|
||||||
|
local device="${1}"
|
||||||
|
local buffer="${2}"
|
||||||
|
local count="${3}"
|
||||||
|
if [ -b "${device}" ]; then
|
||||||
|
set -- \
|
||||||
|
status="progress" \
|
||||||
|
if="/dev/zero" \
|
||||||
|
of="${device}"
|
||||||
|
if [ -n "${buffer}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
bs="${buffer}"
|
||||||
|
fi
|
||||||
|
if [ -n "${count}" ]; then
|
||||||
|
set -- "${@}" \
|
||||||
|
count="${count}"
|
||||||
|
fi
|
||||||
|
dd "${@}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_fs_luks_format() {
|
||||||
|
local passphrase="${1}"
|
||||||
|
local device="${2}"
|
||||||
|
local label="${3}"
|
||||||
|
local uuid="${4}"
|
||||||
|
if [ -b "${device}" ]; then
|
||||||
|
set -- \
|
||||||
|
--batch-mode \
|
||||||
|
--cipher "aes-xts-plain64" \
|
||||||
|
--hash "sha512" \
|
||||||
|
--iter-time 4096 \
|
||||||
|
--key-size 512 \
|
||||||
|
--pbkdf "argon2id" \
|
||||||
|
--type "luks2" \
|
||||||
|
--use-random \
|
||||||
|
--verbose
|
||||||
|
if [ -n "${label}" ]; then
|
||||||
|
set -- "${@}" --label "${label}"
|
||||||
|
fi
|
||||||
|
if [ -n "${uuid}" ]; then
|
||||||
|
set -- "${@}" --uuid "${uuid}"
|
||||||
|
fi
|
||||||
|
echo "${passphrase}" |
|
||||||
|
cryptsetup "${@}" luksFormat "${device}"
|
||||||
|
fi
|
||||||
|
}
|
24
sh/gnome.sh
Normal file
24
sh/gnome.sh
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
rwx_gnome_proxy() {
|
||||||
|
local value
|
||||||
|
case "${1}" in
|
||||||
|
"on") value="manual" ;;
|
||||||
|
*) value="none" ;;
|
||||||
|
esac
|
||||||
|
gsettings set "org.gnome.system.proxy" "mode" "${value}"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_gnome_workspaces_primary() {
|
||||||
|
local bool
|
||||||
|
local group="org.gnome.mutter"
|
||||||
|
local name="workspaces-only-on-primary"
|
||||||
|
local var="${group}/${name}"
|
||||||
|
# get
|
||||||
|
bool="$(gsettings get "${group}" "${name}")"
|
||||||
|
rwx_log_debug "${var}: ${bool}"
|
||||||
|
# not
|
||||||
|
bool="$(rwx_not "${bool}")"
|
||||||
|
rwx_log_debug "bool: ${bool}"
|
||||||
|
# set
|
||||||
|
gsettings set "${group}" "${name}" "${bool}"
|
||||||
|
rwx_log_info "${var}: ${bool}"
|
||||||
|
}
|
12
sh/gpg.sh
Normal file
12
sh/gpg.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
rwx_gpg_ssh_auth_sock() {
|
||||||
|
local user_id
|
||||||
|
user_id=$(id --user)
|
||||||
|
if [ "${user_id}" -ne 0 ]; then
|
||||||
|
if [ -f "${HOME}/.gnupg/gpg-agent.conf" ]; then
|
||||||
|
SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
||||||
|
export SSH_AUTH_SOCK
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_gpg_ssh_auth_sock
|
20
sh/lint/shellcheck.sh
Normal file
20
sh/lint/shellcheck.sh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
rwx_shellcheck() {
|
||||||
|
local root="${1}"
|
||||||
|
local file module modules path
|
||||||
|
file="$(mktemp)"
|
||||||
|
modules="$(rwx_find_shell "${root}")"
|
||||||
|
rwx_ifs_set
|
||||||
|
for module in ${modules}; do
|
||||||
|
path="${root}/${module}"
|
||||||
|
echo ". \"${path}\"" >>"${file}"
|
||||||
|
done
|
||||||
|
rwx_ifs_unset
|
||||||
|
shellcheck \
|
||||||
|
--check-sourced \
|
||||||
|
--enable "all" \
|
||||||
|
--exclude "3043" \
|
||||||
|
--external-sources \
|
||||||
|
--shell "dash" \
|
||||||
|
"${file}"
|
||||||
|
rm "${file}"
|
||||||
|
}
|
4
sh/lint/shfmt.sh
Normal file
4
sh/lint/shfmt.sh
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
rwx_shfmt() {
|
||||||
|
local root="${1}"
|
||||||
|
shfmt --diff "${root}"
|
||||||
|
}
|
6
sh/live.sh
Normal file
6
sh/live.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# remount read-only medium in read-write
|
||||||
|
rwx_live_medium_remount() {
|
||||||
|
mount \
|
||||||
|
-o "remount,rw" \
|
||||||
|
"/usr/lib/live/mount/medium"
|
||||||
|
}
|
68
sh/log.sh
Normal file
68
sh/log.sh
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
RWX_LOG_LEVEL_FATAL=0
|
||||||
|
RWX_LOG_LEVEL_ERROR=1
|
||||||
|
RWX_LOG_LEVEL_WARN=2
|
||||||
|
RWX_LOG_LEVEL_INFO=3
|
||||||
|
RWX_LOG_LEVEL_DEBUG=4
|
||||||
|
RWX_LOG_LEVEL_TRACE=5
|
||||||
|
|
||||||
|
RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO}
|
||||||
|
|
||||||
|
rwx_log() { rwx_log_info "${@}"; }
|
||||||
|
|
||||||
|
rwx_log_debug() {
|
||||||
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_DEBUG}" ]; then
|
||||||
|
_rwx_log "[DEBUG]" "${@}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_log_error() {
|
||||||
|
local code="${1}"
|
||||||
|
shift
|
||||||
|
[ -n "${code}" ] || rwx_log_fatal 1 "No error code"
|
||||||
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_ERROR}" ]; then
|
||||||
|
_rwx_log "[ERROR]" "${@}" >&2
|
||||||
|
return "${code}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_log_fatal() {
|
||||||
|
local code="${1}"
|
||||||
|
shift
|
||||||
|
[ -n "${code}" ] || rwx_log_fatal 1 "No error code"
|
||||||
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_FATAL}" ]; then
|
||||||
|
_rwx_log "[FATAL]" "${@}" >&2
|
||||||
|
exit "${code}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_log_info() {
|
||||||
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_INFO}" ]; then
|
||||||
|
_rwx_log "" "${@}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_log_trace() {
|
||||||
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_TRACE}" ]; then
|
||||||
|
_rwx_log "[TRACE]" "${@}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_log_warn() {
|
||||||
|
if [ "${RWX_LOG_LEVEL}" -ge "${RWX_LOG_LEVEL_WARN}" ]; then
|
||||||
|
_rwx_log "[ WARN]" "${@}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_rwx_log() {
|
||||||
|
local prefix="${1}"
|
||||||
|
shift
|
||||||
|
[ ${#} -gt 0 ] || set -- ""
|
||||||
|
local line
|
||||||
|
for line in "${@}"; do
|
||||||
|
if [ -n "${prefix}" ]; then
|
||||||
|
__rwx_log "${prefix} ${line}"
|
||||||
|
else
|
||||||
|
__rwx_log "${line}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
139
sh/main.sh
Normal file
139
sh/main.sh
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
# ╭───────────╮
|
||||||
|
# │ constants │
|
||||||
|
# ╰───────────╯
|
||||||
|
|
||||||
|
RWX_MAIN_NAME="main.sh"
|
||||||
|
RWX_SELF_NAME="rwx"
|
||||||
|
|
||||||
|
# ╭───────────╮
|
||||||
|
# │ variables │
|
||||||
|
# ╰───────────╯
|
||||||
|
|
||||||
|
RWX_ROOT_USER="${HOME}/${RWX_SELF_NAME}"
|
||||||
|
RWX_SHELL="$(cat "/proc/${$}/comm")"
|
||||||
|
RWX_SYSTEM_ROOT="/usr/local/lib"
|
||||||
|
|
||||||
|
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
|
||||||
|
RWX_ROOT_SYSTEM="${RWX_SYSTEM_ROOT}/${RWX_SELF_NAME}"
|
||||||
|
|
||||||
|
# ╭──────╮
|
||||||
|
# │ core │
|
||||||
|
# ╰──────╯
|
||||||
|
|
||||||
|
# test if active shell is in interactive mode
|
||||||
|
rwx_shell_interactive() {
|
||||||
|
case "${-}" in
|
||||||
|
*i*) ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬─────╮
|
||||||
|
# │ core │ log │
|
||||||
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
|
__rwx_log() {
|
||||||
|
if rwx_shell_interactive; then
|
||||||
|
[ ${#} -gt 0 ] || set -- ""
|
||||||
|
local line
|
||||||
|
for line in "${@}"; do
|
||||||
|
echo "${line}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬──────╮
|
||||||
|
# │ core │ find │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
|
# find directory’s files by extension
|
||||||
|
rwx_find_extension() {
|
||||||
|
local extension="${1}"
|
||||||
|
local root="${2}"
|
||||||
|
local file="${3}"
|
||||||
|
set -- \
|
||||||
|
"${root}" \
|
||||||
|
-name "*.${extension}" \
|
||||||
|
-type "f"
|
||||||
|
[ -n "${file}" ] &&
|
||||||
|
set -- "${@}" \
|
||||||
|
-not \
|
||||||
|
-name "${file}"
|
||||||
|
find "${@}" \
|
||||||
|
-printf "%P\n" |
|
||||||
|
sort
|
||||||
|
}
|
||||||
|
|
||||||
|
# find directory’s sh files
|
||||||
|
rwx_find_shell() {
|
||||||
|
rwx_find_extension "sh" "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬─────╮
|
||||||
|
# │ core │ ifs │
|
||||||
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
|
rwx_ifs_set() {
|
||||||
|
_RWX_IFS="${IFS}"
|
||||||
|
IFS="
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_ifs_unset() {
|
||||||
|
IFS="${_RWX_IFS}"
|
||||||
|
unset RWX_IFS
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬────────╮
|
||||||
|
# │ core │ source │
|
||||||
|
# ╰──────┴────────╯
|
||||||
|
|
||||||
|
rwx_source() {
|
||||||
|
local path="${1}"
|
||||||
|
[ -d "${path}" ] ||
|
||||||
|
return 1
|
||||||
|
local count module modules
|
||||||
|
modules="$(rwx_find_shell "${path}" "${RWX_MAIN_NAME}")"
|
||||||
|
rwx_ifs_set
|
||||||
|
count=0
|
||||||
|
__rwx_log "" \
|
||||||
|
". ${path}"
|
||||||
|
for module in ${modules}; do
|
||||||
|
count=$((count + 1))
|
||||||
|
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
|
||||||
|
module="${path}/${module}"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. "${module}"
|
||||||
|
done
|
||||||
|
rwx_ifs_unset
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────┬──────╮
|
||||||
|
# │ core │ main │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
|
# run initial steps
|
||||||
|
rwx_main() {
|
||||||
|
# system root
|
||||||
|
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
|
||||||
|
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# user root
|
||||||
|
rwx_source "${RWX_ROOT_USER}"
|
||||||
|
# run interactive extras
|
||||||
|
if rwx_shell_interactive; then
|
||||||
|
# check format
|
||||||
|
rwx_log
|
||||||
|
rwx_shfmt "${RWX_ROOT_SYSTEM}"
|
||||||
|
# check syntax
|
||||||
|
rwx_log
|
||||||
|
rwx_shellcheck "${RWX_ROOT_SYSTEM}"
|
||||||
|
# help
|
||||||
|
rwx_log
|
||||||
|
rwx_self_help
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# run main function
|
||||||
|
rwx_main
|
94
sh/rescue/common.sh
Normal file
94
sh/rescue/common.sh
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
rwx_rescue_configure() {
|
||||||
|
local hostname="${1}"
|
||||||
|
# apt / conf
|
||||||
|
rwx_apt_conf_write
|
||||||
|
# apt / sources
|
||||||
|
rwx_apt_sources_write
|
||||||
|
# bash / rc
|
||||||
|
main_link_bashrc
|
||||||
|
mv "${HOME}/.bashrc" "${HOME}/.bashrc.old"
|
||||||
|
# host name
|
||||||
|
hostname "${hostname}"
|
||||||
|
# locales
|
||||||
|
printf "\
|
||||||
|
en_US.UTF-8 UTF-8
|
||||||
|
fr_FR.UTF-8 UTF-8
|
||||||
|
" >"/etc/locale.gen"
|
||||||
|
# generate locales
|
||||||
|
locale-gen
|
||||||
|
# update catalog
|
||||||
|
rwx_apt_update
|
||||||
|
# disable frontend
|
||||||
|
rwx_debian_frontend_disable
|
||||||
|
# install backports
|
||||||
|
rwx_apt_install_backports "tmux"
|
||||||
|
# install packages
|
||||||
|
rwx_apt_install_release "apt-file" "mosh" "screen" "byobu"
|
||||||
|
# update catalog
|
||||||
|
rwx_apt_update
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_rescue_install() {
|
||||||
|
# update catalog
|
||||||
|
rwx_apt_update
|
||||||
|
# disable frontend
|
||||||
|
rwx_debian_frontend_disable
|
||||||
|
# upgrade packages
|
||||||
|
rwx_apt_upgrade
|
||||||
|
# install packages
|
||||||
|
rwx_apt_install_release \
|
||||||
|
"man-db" \
|
||||||
|
"dmidecode" "efibootmgr" "lshw" "pciutils" "usbutils" \
|
||||||
|
"parted" "mdadm" "cryptsetup-bin" "lvm2" \
|
||||||
|
"btrfs-progs" "dosfstools" "duperemove" "squashfs-tools" \
|
||||||
|
"git" "micro" "nano" "python3" "rsync" "vim" \
|
||||||
|
"exa" "lf" "ncdu" "nnn" "ranger" "tree" \
|
||||||
|
"file" "htop" "iotop" "ipcalc" "libdigest-sha3-perl" "lsof"
|
||||||
|
# install backports
|
||||||
|
rwx_apt_install_backports \
|
||||||
|
"grub-pc-bin" \
|
||||||
|
\
|
||||||
|
"grub-efi-amd64-bin"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_rescue_upload() {
|
||||||
|
local host="${1}"
|
||||||
|
local hostname="${2}"
|
||||||
|
if [ -n "${hostname}" ]; then
|
||||||
|
local user="root"
|
||||||
|
#
|
||||||
|
local user_host="${user}@${host}"
|
||||||
|
# remove fingerprints
|
||||||
|
ssh-keygen -R "${host}"
|
||||||
|
# copy ssh id
|
||||||
|
ssh-copy-id \
|
||||||
|
-o "StrictHostKeyChecking=accept-new" \
|
||||||
|
"${user_host}"
|
||||||
|
# upload root
|
||||||
|
rsync --delete --recursive \
|
||||||
|
"$(dirname "${ENV}")" "${user_host}:/etc"
|
||||||
|
# call setup
|
||||||
|
# TODO variable
|
||||||
|
ssh "${user_host}" -- \
|
||||||
|
". \"${ENV}\" ; rwx_rescue_configure \"${hostname}\""
|
||||||
|
# create session
|
||||||
|
ssh "${user_host}" -- byobu new-session -d
|
||||||
|
# send keys
|
||||||
|
ssh "${user_host}" -- byobu send-keys "rwx_rescue_install" "C-m"
|
||||||
|
# attach session
|
||||||
|
mosh "${user_host}" -- byobu attach-session
|
||||||
|
else
|
||||||
|
echo "host & hostname"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_rescue_wipe_1_zero() {
|
||||||
|
rwx_fs_wipe "/dev/mapper/crypt" "512M"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_rescue_wipe_3_close() {
|
||||||
|
umount "/media/boot"
|
||||||
|
umount "/media/crypt" &&
|
||||||
|
cryptsetup luksClose "crypt"
|
||||||
|
}
|
125
sh/rescue/hetzner.sh
Normal file
125
sh/rescue/hetzner.sh
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
rwx_rescue_wipe_0_init_hetzner_8_8() {
|
||||||
|
local device
|
||||||
|
set \
|
||||||
|
"/dev/sda" \
|
||||||
|
"/dev/sdb"
|
||||||
|
local members
|
||||||
|
local number
|
||||||
|
local passphrase
|
||||||
|
# read passphrase
|
||||||
|
passphrase="$(rwx_read_passphrase)"
|
||||||
|
# warn
|
||||||
|
rwx_warn_wipe "${@}"
|
||||||
|
#
|
||||||
|
number=0
|
||||||
|
for device in "${@}"; do
|
||||||
|
number=$((number + 1))
|
||||||
|
echo
|
||||||
|
echo "#${number}: ${device}"
|
||||||
|
#
|
||||||
|
parted --script "${device}" \
|
||||||
|
mktable gpt \
|
||||||
|
unit "mib" \
|
||||||
|
mkpart "crypt-${number}" 33282 7630885 \
|
||||||
|
mkpart "boot-${number}" 514 33282 \
|
||||||
|
mkpart "esp-${number}" 2 514 \
|
||||||
|
set 3 esp on \
|
||||||
|
mkpart "bios-${number}" 1 2 \
|
||||||
|
set 4 bios_grub on
|
||||||
|
done
|
||||||
|
#
|
||||||
|
number=0
|
||||||
|
for device in "${@}"; do
|
||||||
|
number=$((number + 1))
|
||||||
|
echo
|
||||||
|
echo "#${number}: ${device}4"
|
||||||
|
# wipe bios
|
||||||
|
rwx_fs_wipe "${device}4"
|
||||||
|
done
|
||||||
|
#
|
||||||
|
number=0
|
||||||
|
for device in "${@}"; do
|
||||||
|
number=$((number + 1))
|
||||||
|
echo
|
||||||
|
echo "#${number}: ${device}3"
|
||||||
|
# format esp
|
||||||
|
rwx_fs_wipe "${device}3" "1M"
|
||||||
|
rwx_fs_make_fat "${device}3" "esp-${number}" "0000000${number}"
|
||||||
|
# mount esp
|
||||||
|
mkdir --parents "/media/esp/${number}"
|
||||||
|
mount "${device}3" "/media/esp/${number}"
|
||||||
|
done
|
||||||
|
#
|
||||||
|
number=0
|
||||||
|
for device in "${@}"; do
|
||||||
|
number=$((number + 1))
|
||||||
|
echo
|
||||||
|
echo "#${number}: ${device}2"
|
||||||
|
# wipe boot
|
||||||
|
rwx_fs_wipe "${device}2" "1G" 1
|
||||||
|
done
|
||||||
|
#
|
||||||
|
members=""
|
||||||
|
for device in "${@}"; do
|
||||||
|
members="${members} ${device}2"
|
||||||
|
done
|
||||||
|
rwx_fs_raid_create \
|
||||||
|
"boot" "00000000:00000000:00000000:00000002" ${members}
|
||||||
|
#
|
||||||
|
rwx_fs_make_btrfs "/dev/md/boot" "boot" \
|
||||||
|
"00000000-0000-0000-0000-00000000000b"
|
||||||
|
# mount boot
|
||||||
|
mkdir --parents "/media/boot"
|
||||||
|
mount \
|
||||||
|
--options "autodefrag,compress-force=zstd" \
|
||||||
|
"/dev/md/boot" "/media/boot"
|
||||||
|
#
|
||||||
|
number=0
|
||||||
|
for device in "${@}"; do
|
||||||
|
number=$((number + 1))
|
||||||
|
echo
|
||||||
|
echo "#${number}: ${device}1"
|
||||||
|
# wipe crypt head
|
||||||
|
rwx_fs_wipe "${device}1" "1G" 1
|
||||||
|
done
|
||||||
|
#
|
||||||
|
members=""
|
||||||
|
for device in "${@}"; do
|
||||||
|
members="${members} ${device}1"
|
||||||
|
done
|
||||||
|
rwx_fs_raid_create \
|
||||||
|
"crypt" "00000000:00000000:00000000:00000001" ${members}
|
||||||
|
# encrypt
|
||||||
|
rwx_fs_luks_format "${passphrase}" "/dev/md/crypt"
|
||||||
|
# open
|
||||||
|
echo "${passphrase}" |
|
||||||
|
cryptsetup luksOpen "/dev/md/crypt" "crypt"
|
||||||
|
# passphrase
|
||||||
|
unset passphrase
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_rescue_wipe_2_make_hetzner_8_8() {
|
||||||
|
local passphrase
|
||||||
|
# close
|
||||||
|
cryptsetup luksClose "crypt"
|
||||||
|
# read passphrase
|
||||||
|
passphrase="$(rwx_read_passphrase)"
|
||||||
|
# encrypt
|
||||||
|
rwx_fs_luks_format "${passphrase}" "/dev/md/crypt"
|
||||||
|
# open
|
||||||
|
echo "${passphrase}" |
|
||||||
|
cryptsetup luksOpen "/dev/md/crypt" "crypt"
|
||||||
|
# passphrase
|
||||||
|
unset passphrase
|
||||||
|
# format crypt
|
||||||
|
rwx_fs_make_btrfs "/dev/mapper/crypt" "crypt" \
|
||||||
|
"00000000-0000-0000-0000-00000000000c"
|
||||||
|
# mount crypt
|
||||||
|
mkdir --parents "/media/crypt"
|
||||||
|
mount \
|
||||||
|
--options "autodefrag,compress-force=zstd" \
|
||||||
|
"/dev/mapper/crypt" "/media/crypt"
|
||||||
|
# make swap file
|
||||||
|
rwx_fs_make_btrfs_swap "/media/crypt/swap" "64g" \
|
||||||
|
"00000000-0000-0000-0000-000000000005"
|
||||||
|
}
|
71
sh/rescue/ovh.sh
Normal file
71
sh/rescue/ovh.sh
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
rwx_rescue_wipe_0_init_ovh_vle2() {
|
||||||
|
local device="/dev/sdb"
|
||||||
|
local passphrase
|
||||||
|
# read passphrase
|
||||||
|
passphrase="$(rwx_read_passphrase)"
|
||||||
|
# warn
|
||||||
|
rwx_warn_wipe "${device}"
|
||||||
|
#
|
||||||
|
parted --script "${device}" \
|
||||||
|
mktable gpt \
|
||||||
|
unit "mib" \
|
||||||
|
mkpart "crypt" 4610 40959 \
|
||||||
|
mkpart "boot" 514 4610 \
|
||||||
|
mkpart "esp" 2 514 \
|
||||||
|
set 3 esp on \
|
||||||
|
mkpart bios 1 2 \
|
||||||
|
set 4 bios_grub on
|
||||||
|
# bios / wipe
|
||||||
|
rwx_fs_wipe "${device}4"
|
||||||
|
# esp / wipe
|
||||||
|
rwx_fs_wipe "${device}3" "1M"
|
||||||
|
# esp / format
|
||||||
|
rwx_fs_make_fat "${device}3" "esp" "00000001"
|
||||||
|
# esp / mount
|
||||||
|
mkdir --parents "/media/esp"
|
||||||
|
mount "${device}3" "/media/esp"
|
||||||
|
# boot / wipe
|
||||||
|
rwx_fs_wipe "${device}2" "1G" 1
|
||||||
|
# boot / format
|
||||||
|
rwx_fs_make_btrfs "${device}2" "boot" \
|
||||||
|
"00000000-0000-0000-0000-00000000000b"
|
||||||
|
# boot / mount
|
||||||
|
mkdir --parents "/media/boot"
|
||||||
|
mount --options "autodefrag,compress-force=zstd" \
|
||||||
|
"${device}2" "/media/boot"
|
||||||
|
# crypt / wipe
|
||||||
|
rwx_fs_wipe "${device}1" "1G" 1
|
||||||
|
# crypt / encrypt
|
||||||
|
rwx_fs_luks_format "${passphrase}" "${device}1"
|
||||||
|
# crypt / open
|
||||||
|
echo "${passphrase}" |
|
||||||
|
cryptsetup luksOpen "${device}1" "crypt"
|
||||||
|
# passphrase
|
||||||
|
unset passphrase
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_rescue_wipe_2_make_ovh_vle2() {
|
||||||
|
local device="/dev/sdb"
|
||||||
|
local passphrase
|
||||||
|
# crypt / close
|
||||||
|
cryptsetup luksClose "crypt"
|
||||||
|
# read passphrase
|
||||||
|
passphrase="$(rwx_read_passphrase)"
|
||||||
|
# crypt / encrypt
|
||||||
|
rwx_fs_luks_format "${passphrase}" "${device}1"
|
||||||
|
# crypt / open
|
||||||
|
echo "${passphrase}" |
|
||||||
|
cryptsetup luksOpen "${device}1" "crypt"
|
||||||
|
# passphrase
|
||||||
|
unset passphrase
|
||||||
|
# crypt / format
|
||||||
|
rwx_fs_make_btrfs "/dev/mapper/crypt" "crypt" \
|
||||||
|
"00000000-0000-0000-0000-00000000000c"
|
||||||
|
# crypt / mount
|
||||||
|
mkdir --parents "/media/crypt"
|
||||||
|
mount --options "autodefrag,compress-force=zstd" \
|
||||||
|
"/dev/mapper/crypt" "/media/crypt"
|
||||||
|
# crypt / swap
|
||||||
|
rwx_fs_make_btrfs_swap "/media/crypt/swap" "4g" \
|
||||||
|
"00000000-0000-0000-0000-000000000005"
|
||||||
|
}
|
16
sh/self.sh
Normal file
16
sh/self.sh
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# get functions from file
|
||||||
|
rwx_self_functions() {
|
||||||
|
grep \
|
||||||
|
--directories "recurse" \
|
||||||
|
--no-filename \
|
||||||
|
"()" "${RWX_ROOT_SYSTEM}" |
|
||||||
|
cut --delimiter "(" --fields 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# output help message
|
||||||
|
rwx_self_help() {
|
||||||
|
rwx_log \
|
||||||
|
"rwx_… = functions" \
|
||||||
|
" a__… = aliases" \
|
||||||
|
" u__… = user"
|
||||||
|
}
|
125
sh/shell.sh
Normal file
125
sh/shell.sh
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
_rwx_shell_color() {
|
||||||
|
local code="${1}"
|
||||||
|
case "${RWX_SHELL}" in
|
||||||
|
"bash")
|
||||||
|
printf "\x01\e[0"
|
||||||
|
if [ -n "${code}" ]; then
|
||||||
|
printf "%s" ";${code}"
|
||||||
|
fi
|
||||||
|
printf "m\x02"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf "\033["
|
||||||
|
if [ -n "${code}" ]; then
|
||||||
|
printf "%s" "${code}"
|
||||||
|
else
|
||||||
|
printf "0"
|
||||||
|
fi
|
||||||
|
printf "m"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
RWX_COLOR_BROWN="$(_rwx_shell_color 33)"
|
||||||
|
RWX_COLOR_CYAN="$(_rwx_shell_color 36)"
|
||||||
|
RWX_COLOR_DEFAULT="$(_rwx_shell_color)"
|
||||||
|
RWX_COLOR_GREEN="$(_rwx_shell_color 31)"
|
||||||
|
RWX_COLOR_MAGENTA="$(_rwx_shell_color 35)"
|
||||||
|
RWX_COLOR_RED="$(_rwx_shell_color 32)"
|
||||||
|
|
||||||
|
rwx_shell_configure() {
|
||||||
|
[ -n "${ENV}" ] || ENV="${RWX_MAIN_PATH}"
|
||||||
|
export ENV
|
||||||
|
# prompt
|
||||||
|
PS1="\$(rwx_shell_prompt \${?})"
|
||||||
|
PS2="├ "
|
||||||
|
# specific
|
||||||
|
case "${RWX_SHELL}" in
|
||||||
|
"bash")
|
||||||
|
# completion
|
||||||
|
local root="/usr/share/bash-completion"
|
||||||
|
local file="bash_completion"
|
||||||
|
local path="${root}/${file}"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
[ -f "${path}" ] && . "${path}"
|
||||||
|
root="${root}/completions"
|
||||||
|
if [ -d "${root}" ]; then
|
||||||
|
set \
|
||||||
|
"git" \
|
||||||
|
"tar"
|
||||||
|
for file in "${@}"; do
|
||||||
|
path="${root}/${file}"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
[ -f "${path}" ] && . "${path}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# history
|
||||||
|
HISTCONTROL="ignorespace"
|
||||||
|
HISTSIZE=-1
|
||||||
|
HISTTIMEFORMAT="%Y%m%d %H%M%S "
|
||||||
|
;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
rwx_shell_configure
|
||||||
|
|
||||||
|
rwx_shell_prompt() {
|
||||||
|
local date host id
|
||||||
|
local code="${1}"
|
||||||
|
date="$(date +%H:%M:%S)"
|
||||||
|
local git
|
||||||
|
host="$(hostname)"
|
||||||
|
id="$(id --user)"
|
||||||
|
local path="${PWD}"
|
||||||
|
local user="${USER}"
|
||||||
|
local view="└ "
|
||||||
|
# code
|
||||||
|
if [ "${code}" -ne 0 ]; then
|
||||||
|
view="${view}${RWX_COLOR_GREEN}"
|
||||||
|
else
|
||||||
|
view="${view}${RWX_COLOR_RED}"
|
||||||
|
fi
|
||||||
|
view="${view}${code}"
|
||||||
|
# date
|
||||||
|
view="${view}${RWX_COLOR_DEFAULT} @ "
|
||||||
|
view="${view}${RWX_COLOR_BROWN}${date}"
|
||||||
|
# git
|
||||||
|
if command -v "__git_ps1" >"/dev/null"; then
|
||||||
|
git="$(__git_ps1)"
|
||||||
|
if [ -n "${git}" ]; then
|
||||||
|
view="${view}${RWX_COLOR_DEFAULT} –${RWX_COLOR_MAGENTA}${git}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# new
|
||||||
|
view="${view}\\n"
|
||||||
|
# path
|
||||||
|
view="${view}${RWX_COLOR_CYAN}${path}"
|
||||||
|
# new
|
||||||
|
view="${view}\\n"
|
||||||
|
# frame
|
||||||
|
view="${view}${RWX_COLOR_DEFAULT}┌ "
|
||||||
|
# user
|
||||||
|
if [ "${id}" -eq 0 ]; then
|
||||||
|
view="${view}${RWX_COLOR_GREEN}"
|
||||||
|
else
|
||||||
|
view="${view}${RWX_COLOR_RED}"
|
||||||
|
fi
|
||||||
|
view="${view}${user}"
|
||||||
|
# host
|
||||||
|
view="${view}${RWX_COLOR_DEFAULT} @ "
|
||||||
|
view="${view}${RWX_COLOR_BROWN}${host}"
|
||||||
|
# new
|
||||||
|
view="${view}\\n"
|
||||||
|
# prompt
|
||||||
|
view="${view}${RWX_COLOR_DEFAULT}${PS2}"
|
||||||
|
# print
|
||||||
|
printf "%b" "${view}"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_shell_setup() {
|
||||||
|
# shell
|
||||||
|
echo "export ENV=\"${ENV}\"" >"/etc/profile.d/${RWX_SELF_NAME}.sh"
|
||||||
|
# bash
|
||||||
|
local file="/etc/bash.bashrc"
|
||||||
|
rm --force --recursive "${file}"
|
||||||
|
ln --symbolic "${ENV}" "${file}"
|
||||||
|
}
|
37
sh/util.sh
Normal file
37
sh/util.sh
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
rwx_list_block_devices() {
|
||||||
|
lsblk \
|
||||||
|
--noempty \
|
||||||
|
--output "NAME,SIZE,TYPE,FSTYPE,LABEL,MOUNTPOINTS"
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_not() {
|
||||||
|
case "${1}" in
|
||||||
|
"false") echo "true" ;;
|
||||||
|
"true") echo "false" ;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_read_passphrase() {
|
||||||
|
rwx_read_secret "PassPhrase: "
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_read_secret() {
|
||||||
|
local prompt="${1}"
|
||||||
|
local secret
|
||||||
|
printf "%s" "${prompt}" 1>&2
|
||||||
|
stty -echo
|
||||||
|
read -r secret
|
||||||
|
stty echo
|
||||||
|
echo >&2
|
||||||
|
echo "${secret}"
|
||||||
|
unset secret
|
||||||
|
}
|
||||||
|
|
||||||
|
rwx_warn_wipe() {
|
||||||
|
local tmp
|
||||||
|
rwx_list_block_devices
|
||||||
|
printf "%s" "WIPE ${*} /?\\ OR CANCEL /!\\"
|
||||||
|
read -r tmp
|
||||||
|
rwx_log_trace "${tmp}"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue