Compare commits

...

125 Commits

Author SHA1 Message Date
Stefan Hagen
832cfe42c3 Update 2026-02-17 08:42 Darwin/arm64-GH2T6W9K6H 2026-02-17 09:09:14 +01:00
c0dev0id
bf213e469f Update 2026-01-26 20:34 OpenBSD/amd64-dalek 2026-01-26 20:35:00 +01:00
c0dev0id
0bd8a43d4f Update 2026-01-26 16:17 OpenBSD/amd64-dalek 2026-01-26 16:17:20 +01:00
c0dev0id
186dfa8096 Update 2026-01-25 09:38 OpenBSD/amd64-t14 2026-01-25 09:38:17 +01:00
c0dev0id
0769d7a789 Update 2026-01-17 09:55 OpenBSD/amd64-t14 2026-01-17 09:55:19 +01:00
c0dev0id
4dfd87462c Update 2025-12-13 14:50 OpenBSD/amd64-t14 2025-12-13 14:50:33 +01:00
c0dev0id
1cc3015bb5 Update 2025-09-29 07:50 OpenBSD/amd64-t14 2025-09-29 07:50:12 +02:00
c0dev0id
a3954fb9dc Update 2025-09-03 17:04 OpenBSD/amd64-t14 2025-09-03 17:04:32 +02:00
c0dev0id
a074d5b67d Update 2025-08-31 19:39 OpenBSD/amd64-t14 2025-08-31 19:39:39 +02:00
c0dev0id
ff04acca3a Update 2025-08-20 22:21 OpenBSD/amd64-t14 2025-08-20 22:21:12 +02:00
c0dev0id
6028f3a023 Update 2025-08-18 17:54 OpenBSD/amd64-t14 2025-08-18 17:54:24 +02:00
c0dev0id
9764ad6f1f Update 2025-07-25 08:50 OpenBSD/amd64-t14 2025-07-25 08:50:16 +02:00
c0dev0id
72850600e5 Update 2025-07-23 20:58 OpenBSD/amd64-t14 2025-07-23 20:58:48 +02:00
c0dev0id
0d3de71e2c Update 2025-07-23 20:52 OpenBSD/amd64-t14 2025-07-23 20:52:22 +02:00
c0dev0id
d318a58bb0 Update 2025-07-23 20:50 OpenBSD/amd64-t14 2025-07-23 20:51:00 +02:00
c0dev0id
299a3c8b51 Update 2025-07-23 20:50 OpenBSD/amd64-dalek 2025-07-23 20:50:45 +02:00
c0dev0id
6a3fe358f3 Update 2025-07-23 20:36 OpenBSD/amd64-t14 2025-07-23 20:36:22 +02:00
c0dev0id
a0d78823ae Update 2025-07-23 08:45 OpenBSD/amd64-t14 2025-07-23 08:45:16 +02:00
c0dev0id
8f37eceb9a Update 2025-07-23 08:44 OpenBSD/amd64-dalek 2025-07-23 08:44:35 +02:00
c0dev0id
0530d9228b Update 2025-07-21 11:40 OpenBSD/amd64-dalek 2025-07-21 11:40:45 +02:00
c0dev0id
15b0116633 Update 2025-07-21 11:31 OpenBSD/amd64-dalek 2025-07-21 11:31:44 +02:00
c0dev0id
6bbb12e7b3 Update 2025-07-19 07:49 OpenBSD/amd64-dalek 2025-07-19 07:49:02 +02:00
c0dev0id
1a2d91b0d7 Update 2025-07-19 07:40 OpenBSD/amd64-t14 2025-07-19 07:40:13 +02:00
c0dev0id
13bedaa7d3 Update 2025-07-16 09:55 OpenBSD/amd64-t14 2025-07-16 09:55:28 +02:00
c0dev0id
3b839841ac Update 2025-07-16 09:55 OpenBSD/amd64-t14 2025-07-16 09:55:17 +02:00
c0dev0id
9f365fe933 Update 2025-06-08 11:15 OpenBSD/amd64-t14 2025-06-08 11:15:49 +02:00
c0dev0id
62d5edaf29 Update 2025-05-29 09:47 OpenBSD/amd64-t14 2025-05-29 09:47:51 +02:00
c0dev0id
1371b1c8a2 Update 2025-05-25 14:13 OpenBSD/amd64-t14 2025-05-25 14:13:50 +02:00
c0dev0id
e900fc1f35 Update 2025-04-07 09:42 OpenBSD/amd64-t14 2025-04-07 09:42:02 +02:00
c0dev0id
ed8624ef01 Update 2025-03-12 08:17 OpenBSD/amd64-t14 2025-03-12 08:17:57 +01:00
c0dev0id
475bef8131 Update 2025-02-26 07:55 OpenBSD/amd64-t14 2025-02-26 07:55:21 +01:00
c0dev0id
3794862593 Update 2025-02-07 10:15 Linux/x86_64-ld5587 2025-02-07 10:15:31 +01:00
c0dev0id
8bce1b28b3 Update 2025-02-06 08:42 OpenBSD/amd64-t14 2025-02-06 08:42:16 +01:00
c0dev0id
7fc3348d20 Update 2025-02-02 11:02 OpenBSD/amd64-t14 2025-02-02 11:02:11 +01:00
c0dev0id
068de67638 Update 2025-02-01 18:41 OpenBSD/amd64-t14 2025-02-01 18:41:15 +01:00
c0dev0id
00f804c99f Update 2025-01-28 07:47 OpenBSD/amd64-t14 2025-01-28 07:47:21 +01:00
c0dev0id
ee9207d716 Update 2025-01-23 13:10 Darwin/arm64-GH2T6W9K6H 2025-01-23 13:10:13 +01:00
c0dev0id
3c6adda31b Update 2025-01-23 10:26 Darwin/arm64-GH2T6W9K6H 2025-01-23 10:26:26 +01:00
c0dev0id
7a70f07a67 Update 2025-01-18 09:07 OpenBSD/amd64-t14 2025-01-18 09:10:20 +01:00
c0dev0id
33471962fb Update 2025-01-14 14:03 Linux/x86_64-ld5587 2025-01-14 14:03:34 +01:00
c0dev0id
cc3afde694 Update 2025-01-08 08:15 OpenBSD/amd64-t14 2025-01-08 08:15:25 +01:00
c0dev0id
685a3b4c8d Update 2025-01-07 21:24 OpenBSD/amd64-t14 2025-01-07 21:24:53 +01:00
c0dev0id
b0cc6ce138 Update 2025-01-05 14:15 OpenBSD/amd64-t14 2025-01-05 14:15:46 +01:00
c0dev0id
a992796635 Update 2025-01-05 12:56 OpenBSD/amd64-t14 2025-01-05 12:56:30 +01:00
c0dev0id
20f3483f9c Update 2025-01-05 11:02 OpenBSD/amd64-t14 2025-01-05 11:02:20 +01:00
c0dev0id
87a300f0c4 Update 2025-01-05 10:36 OpenBSD/amd64-t14 2025-01-05 10:36:09 +01:00
c0dev0id
908090c41b Update 2025-01-05 09:22 OpenBSD/amd64-t14 2025-01-05 09:22:42 +01:00
c0dev0id
5f346e4848 Update 2025-01-03 14:45 OpenBSD/amd64-t14 2025-01-03 14:45:33 +01:00
c0dev0id
45969796dc Update 2025-01-03 14:41 OpenBSD/amd64-t14 2025-01-03 14:41:35 +01:00
c0dev0id
fa6a52b1a3 Update 2025-01-03 14:38 OpenBSD/amd64-t14 2025-01-03 14:38:07 +01:00
c0dev0id
02239e52a3 Update 2025-01-02 23:53 OpenBSD/amd64-t14 2025-01-02 23:53:34 +01:00
c0dev0id
767ba27c2b Update 2025-01-01 10:48 OpenBSD/amd64-t14 2025-01-01 10:48:50 +01:00
c0dev0id
08aaf050a6 Update 2025-01-01 10:06 OpenBSD/amd64-t14 2025-01-01 10:06:17 +01:00
c0dev0id
1c9a2b446a Update 2025-01-01 10:04 OpenBSD/amd64-t14 2025-01-01 10:04:08 +01:00
c0dev0id
6b2b5ae779 Update 2024-12-31 15:03 OpenBSD/amd64-t14 2024-12-31 15:03:55 +01:00
c0dev0id
d8fff6ec32 Update 2024-12-31 14:34 OpenBSD/amd64-t14 2024-12-31 14:34:23 +01:00
c0dev0id
26abaf99b2 Update 2024-12-31 13:15 OpenBSD/amd64-t14 2024-12-31 13:15:25 +01:00
c0dev0id
0bda01c32e Update 2024-12-31 13:12 OpenBSD/amd64-t14 2024-12-31 13:12:46 +01:00
c0dev0id
6db769365d Update 2024-12-31 12:24 OpenBSD/amd64-t14 2024-12-31 12:24:23 +01:00
c0dev0id
9f55042b33 Update 2024-12-31 10:47 OpenBSD/amd64-t14 2024-12-31 10:47:38 +01:00
c0dev0id
9ffce7022e Update 2024-12-26 20:41 OpenBSD/amd64-t14 2024-12-26 20:41:45 +01:00
c0dev0id
7c5d1f298f Update 2024-12-26 17:21 OpenBSD/amd64-t14 2024-12-26 17:21:55 +01:00
c0dev0id
3768436e21 Update 2024-12-26 15:09 OpenBSD/amd64-t14 2024-12-26 15:09:32 +01:00
c0dev0id
8d1878581b Update 2024-12-26 14:49 OpenBSD/amd64-t14 2024-12-26 14:49:00 +01:00
c0dev0id
e9581ec17d Update 2024-12-26 14:23 OpenBSD/amd64-t14 2024-12-26 14:23:38 +01:00
c0dev0id
7eb3f826fb Update 2024-12-25 21:13 OpenBSD/amd64-t14 2024-12-25 21:13:51 +01:00
c0dev0id
2357c34813 Update 2024-12-25 18:06 OpenBSD/amd64-t14 2024-12-25 18:06:24 +01:00
c0dev0id
1f15f715a6 Update 2024-12-25 15:43 OpenBSD/amd64-t14 2024-12-25 15:43:38 +01:00
c0dev0id
346463127c Update 2024-12-25 14:31 OpenBSD/amd64-t14 2024-12-25 14:31:11 +01:00
c0dev0id
3e58a36599 Update 2024-12-24 08:58 OpenBSD/amd64-t14 2024-12-24 08:58:49 +01:00
c0dev0id
6a240c970c Update 2024-12-23 22:17 OpenBSD/amd64-t14 2024-12-23 22:17:58 +01:00
c0dev0id
e548ab67c8 Update 2024-12-23 22:15 OpenBSD/amd64-t14 2024-12-23 22:15:16 +01:00
c0dev0id
b86b992a6a Update 2024-12-23 21:31 OpenBSD/amd64-t14 2024-12-23 21:31:59 +01:00
c0dev0id
31c62ae69a Update 2024-12-23 18:49 OpenBSD/amd64-t14 2024-12-23 18:49:14 +01:00
c0dev0id
ec7fbad49f Update 2024-12-23 18:34 OpenBSD/amd64-t14 2024-12-23 18:34:22 +01:00
c0dev0id
1bb57985ca Update 2024-12-23 18:21 OpenBSD/amd64-t14 2024-12-23 18:21:09 +01:00
c0dev0id
ac58f6baa9 Update 2024-12-23 17:32 OpenBSD/amd64-t14 2024-12-23 17:32:40 +01:00
c0dev0id
b2c7bcd12a Update 2024-12-23 16:38 OpenBSD/amd64-t14 2024-12-23 16:38:04 +01:00
c0dev0id
e2edc9d2b6 Update 2024-12-23 16:36 OpenBSD/amd64-t14 2024-12-23 16:36:55 +01:00
c0dev0id
70c63ad427 Update 2024-12-23 15:26 OpenBSD/amd64-t14 2024-12-23 15:26:32 +01:00
c0dev0id
ae5183fa58 Update 2024-12-23 14:32 OpenBSD/amd64-t14 2024-12-23 14:32:10 +01:00
c0dev0id
19fc60ef8b Update 2024-12-23 13:03 OpenBSD/amd64-t14 2024-12-23 13:03:14 +01:00
c0dev0id
0701e19f1e Update 2024-12-23 12:49 OpenBSD/amd64-t14 2024-12-23 12:49:42 +01:00
c0dev0id
1ecd621a69 Update 2024-12-23 12:39 OpenBSD/amd64-t14 2024-12-23 12:39:36 +01:00
c0dev0id
b3b69a682a Update 2024-12-23 11:45 OpenBSD/amd64-t14 2024-12-23 11:45:57 +01:00
c0dev0id
180588879c Update 2024-12-23 11:30 OpenBSD/amd64-t14 2024-12-23 11:30:16 +01:00
c0dev0id
0582999ac9 Update 2024-12-23 02:01 OpenBSD/amd64-t14 2024-12-23 02:01:54 +01:00
c0dev0id
fa50579054 Update 2024-12-23 00:29 OpenBSD/amd64-t14 2024-12-23 00:29:22 +01:00
c0dev0id
e27a96f17e Update 2024-12-22 22:44 OpenBSD/amd64-t14 2024-12-22 22:44:47 +01:00
c0dev0id
ebae25d46e Update 2024-12-22 21:08 OpenBSD/amd64-t14 2024-12-22 21:08:35 +01:00
c0dev0id
a145968b49 Update 2024-12-22 19:37 OpenBSD/amd64-t14 2024-12-22 19:37:24 +01:00
c0dev0id
7948d7cd1d Update 2024-12-22 19:14 OpenBSD/amd64-t14 2024-12-22 19:14:43 +01:00
c0dev0id
e304b53c34 Update 2024-12-22 17:20 OpenBSD/amd64-t14 2024-12-22 17:20:59 +01:00
c0dev0id
2e1234e383 Update 2024-12-22 16:36 OpenBSD/amd64-t14 2024-12-22 16:36:59 +01:00
c0dev0id
d0c4c84117 Update 2024-12-22 11:01 OpenBSD/amd64-t14 2024-12-22 11:09:14 +01:00
c0dev0id
4ec4facf23 Update 2024-12-22 09:05 OpenBSD/amd64-t14 2024-12-22 11:09:14 +01:00
c0dev0id
d49eb5d52f Update 2024-12-17 17:56 OpenBSD/amd64-dalek 2024-12-17 17:56:30 +01:00
c0dev0id
e4b33a77ba Update 2024-12-16 19:13 OpenBSD/amd64-t14 2024-12-16 19:13:26 +01:00
c0dev0id
6d6f0e9a46 Update 2024-12-15 14:45 OpenBSD/amd64-t14 2024-12-15 14:45:59 +01:00
c0dev0id
beac7b226a Update 2024-12-15 12:31 OpenBSD/amd64-t14 2024-12-15 12:31:05 +01:00
c0dev0id
885b928622 Update 2024-12-14 16:17 OpenBSD/amd64-t14 2024-12-14 16:17:20 +01:00
c0dev0id
a9e21a78f6 Update 2024-12-13 09:10 OpenBSD/amd64-t14 2024-12-13 09:10:05 +01:00
c0dev0id
0d5b1947e1 Update 2024-12-13 09:08 OpenBSD/amd64-t14 2024-12-13 09:08:21 +01:00
c0dev0id
ca92c8badb Update 2024-12-13 08:54 OpenBSD/amd64-t14 2024-12-13 08:54:27 +01:00
c0dev0id
17325bb534 Update 2024-12-12 18:58 OpenBSD/amd64-t14 2024-12-12 18:58:31 +01:00
c0dev0id
fc5e2de67a Update 2024-12-12 18:58 OpenBSD/amd64-t14 2024-12-12 18:58:22 +01:00
c0dev0id
6a8edca474 Update 2024-12-12 18:56 OpenBSD/amd64-t14 2024-12-12 18:56:36 +01:00
c0dev0id
f652704039 Update 2024-12-08 17:45 OpenBSD/amd64-t14 2024-12-08 17:45:44 +01:00
c0dev0id
0e4f11ee5a Update 2024-11-28 17:26 Darwin/arm64-GH2T6W9K6H 2024-11-28 17:26:19 +01:00
c0dev0id
03f01fbf0c Update 2024-11-27 16:24 Darwin/arm64-GH2T6W9K6H 2024-11-27 16:24:35 +01:00
c0dev0id
a9cbd03d71 Update 2024-11-25 08:21 Linux/x86_64-ld5587 2024-11-25 08:22:01 +01:00
c0dev0id
ed33e478fd Update 2024-11-23 16:01 OpenBSD/amd64-t14 2024-11-23 16:01:51 +01:00
c0dev0id
381dec3be2 Update 2024-11-23 15:58 OpenBSD/amd64-t14 2024-11-23 15:58:56 +01:00
c0dev0id
e42bedae7b Update 2024-11-22 15:56 Linux/x86_64-ld5587 2024-11-22 15:56:30 +01:00
c0dev0id
b6589af9f8 Update 2024-11-22 15:45 Linux/x86_64-ld5587 2024-11-22 15:45:48 +01:00
c0dev0id
5c502b46d4 Update 2024-11-22 13:42 Linux/x86_64-ld5587 2024-11-22 13:42:28 +01:00
c0dev0id
c2c7a0b304 Update 2024-11-11 21:19 OpenBSD/amd64-t14 2024-11-11 21:19:04 +01:00
c0dev0id
c3749d841a Update 2024-11-11 21:08 OpenBSD/amd64-t14 2024-11-11 21:08:22 +01:00
c0dev0id
93fb45fd3c Update 2024-11-04 07:13 OpenBSD/amd64-t14 2024-11-04 07:13:46 +01:00
c0dev0id
bcacac1029 Update 2024-10-24 00:06 OpenBSD/amd64-t14 2024-10-24 00:06:31 +02:00
c0dev0id
de5b108398 Update 2024-10-20 18:21 OpenBSD/amd64-t14 2024-10-20 18:21:51 +02:00
c0dev0id
634ce7bc79 Update 2024-10-20 07:57 OpenBSD/amd64-t14 2024-10-20 07:57:26 +02:00
c0dev0id
2dfb4eadd2 Update 2024-10-15 11:04 Linux/x86_64-ld5587 2024-10-15 11:04:10 +02:00
c0dev0id
c94167cb73 Update 2024-10-11 15:39 Linux/x86_64-ld5587 2024-10-11 15:39:51 +02:00
c0dev0id
2cfd87665a Update 2024-10-10 16:47 Linux/x86_64-ld5587 2024-10-10 16:47:42 +02:00
1401 changed files with 220459 additions and 211455 deletions

View File

@@ -1,7 +1,6 @@
! -- CURSOR --!
!Xcursor.size: 32
Xcursor.size: 32
Xcursor.theme:
Xcursor.size: 48
Xcursor.theme: Adwaita
xterm.cursorTheme:
! -- XFT -- !
@@ -207,10 +206,10 @@ Zutty.altScroll: true
Zutty.boldColors: false
Zutty.font: JetBrainsMono
Zutty.dwfont: JetBrainsMono
Zutty.fontsize: 18
Zutty.fontsize: 32
Zutty.fontpath: /home/sdk/.fonts
Zutty.bg: #001010
Zutty.cr: #008080
Zutty.bg: #000000
Zutty.cr: #AF5F00
! URxvt specific
URxvt*font: xft:Terminus-18

View File

@@ -1,14 +0,0 @@
#!/bin/sh
ZONE=codevoid.de
if [ ! -z $1 ]
then
ZONE=$1
fi
ssh -t dns.codevoid.de \
"doas vim /var/nsd/zones/master/$ZONE \
&& doas nsd-control reload"
sleep 2

View File

@@ -1,4 +0,0 @@
#!/bin/sh
set -xe
f="$(readlink -f "$1")"
vim "$f.gpg" && gpg -qd "$f.gpg" > "$f"

View File

@@ -1,20 +0,0 @@
#!/bin/sh
. $HOME/.bin/_config
print "Tarsnap Restore:"
if [ -z "$1" ]; then
doas tarsnap --list-archives | sort
printf "Usage: restore <key_id>\n"
exit 2
fi
_backup="$(doas tarsnap --list-archives | grep "$1")"
if [ -z "$_backup" ]; then
print "No backup with key id $1 found."
exit 1
fi
mkdir "restore_$1"
doas tarsnap --humanize-numbers -xvf "$_backup" -C "restore_$1"
print "Data restored in $(readlink -f "restore_$1")"

View File

@@ -69,7 +69,8 @@ needs() {
|| add="$add $x"
done
[ ! -z "$add" ] \
&& doas pkg_add -- $add
&& doas pkg_add -- $add \
|| true
}
#

85
.bin/aria Executable file
View File

@@ -0,0 +1,85 @@
#!/bin/sh
DIR="/home/sdk/.aria2"
mkdir -p "$DIR"
SECOPTS="\
--bt-enable-lpd=false
--enable-peer-exchange=false
--enable-dht=false
--enable-dht6=false
"
PUBLIC="\
--dht-listen-port=55500
--bt-enable-lpd=true
--enable-peer-exchange=true
--enable-dht=true
--enable-dht6=true
"
DEFAULT="\
--auto-save-interval=60
--listen-port=55500
--disk-cache=256M
--bt-save-metadata=true
--bt-load-saved-metadata=true
--bt-prioritize-piece=head=10M,tail=10M
--content-disposition-default-utf8=true
--dht-file-path=$DIR/dht.dat
--dht-file-path6=$DIR/dht6.dat
--save-cookies=$DIR/cookies.dat
--save-session=$DIR/session.dat
"
for cmd in $@
do
case $cmd in
seed|upload|up)
OPTS="$OPTS
--seed-ratio=0.0
--max-overall-upload-limit=5M
--max-overall-download-limit=200K
--check-integrity=true
--bt-hash-check-seed=true
--bt-seed-unverified=true
-j 100
"
shift ;;
download|dl)
OPTS="$OPTS
--max-overall-upload-limit=200K
--max-overall-download-limit=85M
--seed-time=0
--lowest-speed-limit=30K
--bt-request-peer-speed-limit=100K
--file-allocation=trunc
-j 6
"
shift ;;
overwrite|force)
OPTS="$OPTS
--allow-overwrite=true
"
shift ;;
enc|encrypt) OPTS="$OPTS
--bt-require-crypto
--bt-min-crypto-level=arc4
"
shift ;;
pub|public) SECOPTS="$PUBLIC"
shift ;;
seq|1) OPTS="$OPTS
-j 1 -Z
"
shift ;;
esac
done
set -x
if [ -z "$@" ]
then
aria2c $DEFAULT $OPTS $SECOPTS *.torrent
else
aria2c $DEFAULT $OPTS $SECOPTS "$@"
fi

150
.bin/blog Executable file
View File

@@ -0,0 +1,150 @@
#!/bin/sh
# hugo cli frontend
# needs: sh, fzf, grep, cat, cut tr, date (bsd date...), hugo, vim
# deployments are handled using a Makefile (bring your own...)
cd "$HOME/blog"
for _arg
do
case $_arg in
update)
make update
exit 0
;;
esac
done
# extra options appended to the menu
_extra="---
maintenance * Maintenance Mode
new * New Post
quit * Quit Main Menu"
# main loop
while [ -z "$_quit" ]
do
# parse csv, build and show list
_selection=$(hugo list all \
| grep -Ev ^path \
| while read _line
do
# csv fields:
# 1: path
# 2: slug
# 3: title
# 4: date
# 5: expiryDate
# 6: publishDate
# 7: draft
# 8: permalink
# 9: kind
# 10: section
_file="$(echo $_line | cut -d"," -f1)"
_title="$(echo $_line | cut -d"," -f3)"
_draft=$(echo $_line | cut -d"," -f7)
_draft_fmt=$([ "$_draft" == "true" ] && echo "(draft)")
_date="$(echo $_line | cut -d"," -f4)"
_date_fmt=$(date -f "%Y-%m-%dT%H:%M:%S" -j "$_date" +"%Y-%m-%d %H:%M")
_type=$(echo "$_file" | grep -q "_index.md$" && echo "page" || echo "post")
echo "$_file * $_date_fmt | $_type | $_title $_draft_fmt"
done | (sort -t" " -k 2; echo "$_extra") \
| fzf -e --tac +s --with-nth 2.. \
| cut -d" " -f1)
### functions
_new() {
unset _newquit
while [ -z "$_newquit" ]
do
unset _newtitle
unset _filename
echo "Enter Post Title"
echo -n ": "
read _newtitle
if [ -n "$_newtitle" ]
then
# Welcome to my awful filename generator / sanitizer.
# Improvements are welcome!
_filename=$(echo "$_newtitle" \
| tr -d '?!%$:\\' \
| tr ' ./' '_' \
| tr -s '_' \
| tr '[:upper:]' '[:lower:]' \
| sed 's/_$//g;s/^_//g')
fi
if [ -n "$_filename" ]
then
echo "Creating:"
echo "File: content/posts/$_filename.md"
echo "Title: $_newtitle"
echo -n "Ok? [Y/n]: "
read _ok
case "$_ok" in
[nN]) ;;
*) hugo new content --editor=vim "content/posts/$_filename.md"
_newquit=1
;;
esac
else
echo "No title entered. Returning to menu."
_newquit=1
sleep 1
fi
done
}
_edit_entry() {
unset _quitmenu
while [ -z "$_quitmenu" ]
do
clear
_f="${_newname:-$1}"
echo "--- $_f:"
echo
head -15 "$_f"
echo "---"
echo
echo "Filename: $(basename "$_f")"
echo "Options: [E]dit, [D]elete, [R]ename, [T]oggle draft, [Q]uit Edit Menu"
echo -n ": "
read _opt
case $_opt in
[dD]) mkdir -p .trash; mv -f "$_f" .trash/
_quitmenu=1 ;;
[qQ]) return ;;
[tT]) grep -qE '^draft.*=.*false' "$_f" \
&& sed -i 's/^draft.*=.*false/draft = true/' "$_f" \
|| sed -i 's/^draft.*=.*true/draft = false/' "$_f" ;;
[rR]) echo "old: $(basename "$_f")"
echo -n "new: "
read _newname;
echo -n "ok? [Y/n]: "
read _ok
case "$_ok" in
[nN]) unset _newname ;;
*) _newname="content/posts/$_newname"
mv -vf "$_f" "$_newname"
;;
esac
;;
*) vim "$_f" ;;
[qQ]) _quitmenu=1 ;;
esac
done
}
case "$_selection" in
new) _new ;;
---) ;;
maintenance) make maintenance ;;
quit) _quit=1; echo "Good bye." ;;
*) [ -n "$_selection" ] \
&& _edit_entry "$_selection" \
|| _quit=1 ;;
esac
done

10
.bin/bupstash-backup Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
hostname=$(hostname)
year=$(date +%Y)
month=$(date +%m)
day=$(date +%d)
timestamp="$year-$month-$day $(date +"%H:%M")"
set -x
bupstash put --print-file-actions --print-stats hostname="$hostname" timestamp="$timestamp" year="$year" month="$month" day="$day" $@

101
.bin/cam
View File

@@ -1,4 +1,101 @@
#!/bin/sh
#ffplay -f v4l2 -list_formats all -i /dev/video0
_SWM_WS=-1 ffplay -loglevel quiet -f v4l2 -input_format mjpeg -video_size 424x240 -i /dev/video0 $@ &
# defaults
_format="-input_format mjpeg"
_dev="/dev/video0"
# loop through arguments
for arg in $@
do
# set values based of arguments found
case $arg in
s|start) _start=1 ;;
k|kill|stop) _stop=1 ;;
l|list) _list=1 ;;
30) _fps="-framerate 30" ;;
60) _fps="-framerate 60" ;;
raw) _format="-input_format yuyv422" ;;
nv12) _format="-input_format nv12" ;;
fullhd) _res="-video_size 1920x1080" ;;
hd) _res="-video_size 1280x720" ;;
sd) _res="-video_size 640x360" ;;
max) _res="max" ;;
[0-9]*x[0-9]*) _res="-video_size $arg" ;;
[0-9]) _dev="/dev/video$arg" ;;
*) _unknown="$_unknown $arg" ;;
esac
shift;
done
if [ ! -z "$_unknown" ]
then
echo "unknown parameter(s): $_unknown"
fi
# set resolution
if [ x"$_res" == x"max" ]
then
_res="-video_size $(ffplay -f v4l2 -list_formats all -i $_dev 2>&1 \
| grep mjpeg \
| xargs \
| cut -d":" -f4 \
| tr ' ' '\n' \
| sort -n \
| tail -1
)"
_format="-input_format mjpeg"
fi
# list supported formats + resolutions
if [ ! -z "$_list" ]
then
command="$(echo "ffplay -f v4l2 -list_formats all -i $_dev")"
echo "starting: $command"
$command 2>&1 \
| grep '^\[video4linux2' \
| cut -d: -f3,4 \
| sed -e 's/^[ \t]*//;s/ : /: /'
exit 0
fi
if [ ! -z "$_start" ]
then
command="ffplay -loglevel quiet -f v4l2 $_fps $_format $_res -i $_dev"
echo "starting: $command" | xargs
_SWM_WS=-1 $command > /dev/null 2>&1 &
[ $? -ne 0 ] \
&& echo "ffplay couldn't start"
exit 0
fi
if [ ! -z "$_stop" ]
then
echo "stopping: ffplay -loglevel quiet -f v4l2"
pkill -qf "ffplay -loglevel quiet -f v4l2"
exit 0
fi
if [ $(( _start + _stop + _list )) -eq 0 ]
then
echo "usage: cam command [framerate] [format] [resolution] [device]"
echo " commands:"
echo " start - start camera"
echo " stop - stop camera"
echo " list - list supported formats and resolutions"
echo " formats:"
echo " raw - reads the yuyv422 stream (instead of mjpeg)"
echo " nv12 - reads the nv12 stream (instead of mjpeg)"
echo " resolutions:"
echo " sd - set video size to 640x360"
echo " hd - set video size to 1280x720"
echo " fullhd - set video size to 1920x1080"
echo " max - set maximum video size (implies mjpeg format)"
echo " <width>x<height> - manually set resolution (see list command)"
echo " framerates:"
echo " 30 - set framerate to 30 fps"
echo " 60 - set framerate to 60 fps"
echo " <device> - set video device number (defaults to 0)"
echo
echo " Note: ffplay may not start or fall back to internal defaults when options (or combinations thereof) are not supported by the camera."
exit 2
fi

11
.bin/cdrip2flac Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
set -xe
alias flac_encode="flac -e --best --delete-input-file"
doas chown sdk /dev/rcd0* /dev/cd0*
cdio cdrip
for i in *.wav;
do
flac_encode "$i" -o "${i%%.wav}.flac";
done
picard *.flac
cdio eject

View File

@@ -1,61 +1,146 @@
#!/bin/sh
#/usr/local/bin/ungoogled-chromium \
#export DBUS_SESSION_BUS_ADDRESS="unix:path=/dev/null"
/usr/local/bin/chrome \
--no-first-run \
--disable-crash-reporter \
--disable-logging \
--disable-login-animations \
--disable-notifications \
--disable-infobars \
--disable-dev-shm-usage \
--log-level=0 \
--hide-crash-restore-bubble \
--no-default-browser-check \
--high-dpi-support=1 \
--force-device-scale-factor=1.5 \
--new-window "$@"
# --bwsi \
# --disable-auto-reload \
# --disable-breakpad \
# --disable-client-side-phishing-detection \
# --disable-component-cloud-policy \
# --disable-component-update \
# --disable-crash-reporter \
# --disable-device-discovery-notifications \
# --disable-logging \
# --disable-login-animations \
# --disable-notifications \
# --disable-pinch \
# --disable-software-rasterizer \
# --disable-chrome-browser-cloud-management \
# --disable-field-trial-config \
# --disable-cookie-encryption \
# --disable-cloud-print-proxy \
# --dbus-stub \
# --cros-disks-fake \
# --disable-stack-profiler \
# --disable-touch-drag-drop \
# --disable-usb-keyboard-detect \
# --disable-default-apps \
# --disable-histogram-customizer \
# --disable-in-process-stack-traces \
# --no-service-autorun \
# --no-experiments \
# --use-gl=egl \
# --force-dark-mode \
# --enable-features=WebUIDarkMode \
# --hide-crash-restore-bubble \
# --no-default-browser-check \
# --no-proxy-server \
# --no-recovery-component \
# --password-store=basic \
# --structured-metrics-disabled \
# --wm-window-animations-disabled \
# #--enable-features=RunVideoCaptureServiceInBrowserProcess,WebUIDarkMode \
# #--use-gl=egl \
# --disable-yuv-image-decoding \
# --use-gl=desktop \
# --high-dpi-support=1 \
# --force-device-scale-factor=1.5 \
# flag documentation:
# https://peter.sh/experiments/chromium-command-line-switches/
# helper functions
addflag() { FLAGS="$FLAGS $1"; }
enable() { ENABLED_FEATURES="$ENABLED_FEATURES $1"; }
disable() { DISABLED_FEATURES="$DISABLED_FEATURES $1"; }
###
### SETUP ENVIRONMENT
###
# disable WASM (OpenBSD specific)
#export ENABLE_WASM=0
# Nuke DBUS
# some webpages suggest value "disabled:"
export DBUS_SESSION_BUS_ADDRESS="unix:path=/dev/null"
###
### CHROMIUM FLAGS
###
# disable pledge (OpenBSD specific)
#addflag "--no-sandbox"
# disable unveil (OpenBSD specific)
#addflag "--disable-unveil"
# Skip First Run tasks as well as not showing additional dialogs,
# prompts or bubbles. Suppressing dialogs, prompts, and bubbles is
# important as this switch is used by automation (including performance
# benchmarks) where it's important only a browser window is shown. This
# may not actually be the first run or the What's New page. Overridden
# by kForceFirstRun (for FRE) and kForceWhatsNew (for What's New). This
# does not drop the First Run sentinel and thus doesn't prevent first run
# from occurring the next time chrome is launched without this flag. It
# also does not update the last What's New milestone, so does not prevent
# What's New from occurring the next time chrome is launched without this
# flag.
addflag "--no-first-run"
# Enables TLS/SSL errors on localhost to be ignored (no interstitial, no
# blocking of requests).
addflag "--allow-insecure-localhost"
# If present animations are disabled
addflag "--wm-window-animations-disabled"
# Select which implementation of GL the GPU process should use.
# Options are:
# desktop: whatever desktop OpenGL the user has installed (Linux and Mac default).
# egl: whatever EGL / GLES2 the user has installed (Windows default - actually ANGLE).
# swiftshader: The SwiftShader software renderer.
addflag "--use-gl=desktop"
# Disable structured metrics logging of cros actions.
addflag "--structured-metrics-disabled"
# Enables cros disks fake behavior. If the switch is set, fake cros disk
# D-Bus client is initialized and USB events do not reach chrome.
addflag "--cros-disks-fake"
# Specifies which encryption storage backend to use. Possible values are
# kwallet, kwallet5, kwallet6, gnome-libsecret, basic. Any other value
# will lead to Chrome detecting the best backend automatically.
addflag "--password-store=basic"
# Disables the service process from adding itself as an autorun process.
# This does not delete existing autorun registrations, it just prevents
# the service from registering a new one.
addflag "--no-service-autorun"
# Prevent downloading and running the recovery component.
addflag "--no-recovery-component"
addflag "--no-proxy-server"
addflag "--no-experiments"
addflag "--no-default-browser-check"
addflag "--log-level=0"
addflag "--high-dpi-support=1"
addflag "--hide-crash-restore-bubble"
addflag "--force-device-scale-factor=1.5"
addflag "--force-dark-mode"
addflag "--enable-gpu-rasterization"
addflag "--enable-zero-copy"
# addflag "--enable-unsafe-webgpu" # leads to banner "stability and security will suffer
addflag "--ignore-gpu-blocklist"
# fix webcam issues?
# addflag "--disable-yuv-image-decoding"
#
addflag "--disable-usb-keyboard-detect"
addflag "--disable-touch-drag-drop"
addflag "--disable-stack-profiler"
#addflag "--disable-software-rasterizer"
addflag "--disable-pinch"
addflag "--disable-notifications"
addflag "--disable-login-animations"
addflag "--disable-logging"
addflag "--disable-infobars"
addflag "--disable-in-process-stack-traces"
addflag "--disable-histogram-customizer"
addflag "--disable-field-trial-config"
addflag "--disable-device-discovery-notifications"
# addflag "--disable-dev-shm-usage"
addflag "--disable-default-apps"
# Disable crash reporting
addflag "--disable-crash-reporter"
addflag "--disable-cookie-encryption"
addflag "--disable-component-update"
addflag "--disable-component-cloud-policy"
addflag "--disable-cloud-print-proxy"
addflag "--disable-client-side-phishing-detection"
addflag "--disable-chrome-browser-cloud-management"
addflag "--disable-breakpad"
addflag "--disable-auto-reload"
# addflag "--dbus-stub" # default on non chrome-os
addflag "--bwsi" # force guest mode (no sign-in)
###
### ENABLE / DISABLE PROCESS FEATURES
###
enable "WebUIDarkMode" # enables dark mode
# enable RunVideoCaptureServiceInBrowserProcess # fixes webcam issues by avoiding multiple /dev/video opens
enable "VaapiVideoDecoder"
enable "VaapiVideoEncoder"
disable "IndexedDBCompressValuesWithSnappy" # disable indexdb compression, speeds up facebook
disable "Vulkan"
disable "UseChromeOSDirectVideoDecoder"
enable "VaapiVideoDecodeLinuxGL"
enable "VaapiIgnoreDriverChecks"
disable "UseSkiaRenderer"
# add features to flag list
addflag "--enable-features=$(echo "$ENABLED_FEATURES" | tr -s " " | sed 's/^ //g' | tr ' ' ',')"
addflag "--enable-features=$(echo "$DISABLED_FEATURES" | tr -s " " | sed 's/^ //g' | tr ' ' ',')"
# finally start chrome...
set -x
/usr/local/bin/chrome $FLAGS --new-window "$@"

12
.bin/create-torrent Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# source https://github.com/aria2/aria2/issues/663
export PATH=$HOME/.cargo/bin:$PATH
[ ! -f $HOME/.cargo/bin/imdl ] \
&& cargo install -f imdl
set -x
imdl torrent create --input "$1"
imdl torrent show --input "$1.torrent"
imdl torrent verify --input "$1.torrent" --content "$1"
imdl torrent link --input "$1.torrent"

6
.bin/cvs-update Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh -ex
CVSROOT="sdk@cvs.openbsd.org:/cvs"
export CVSROOT
doas -u sdk cvs -d $CVSROOT -z1 -q up -Pd -A $@

View File

@@ -21,7 +21,7 @@ touch "${HISTFILE}"
read_input() {
local S=$( { echo "paste_from_clipboard"; tail -r ${HISTFILE}; } \
| awk '!seen[$0]++' \
| ${DMENU_CMD} -p "Bookmarks" -l 20)
| ${DMENU_CMD} -p "Bookmarks")
case "${S}" in
paste_from_clipboard) S=$(xclip -o | head -n 1); ;;
@@ -87,11 +87,11 @@ Zalando"
*.io|*.sh|*.pw|*.party) DEFAULT="OPEN (default)"; C="http://${C}"; ;;
*.coffee|*.me|*.cloud) DEFAULT="OPEN (default)"; C="http://${C}"; ;;
*.[a-zA-Z]*/*) DEFAULT="OPEN (default)"; C="http://${C}"; ;;
*) DEFAULT="Kagi Web Search (default)"; ;;
*) DEFAULT="DuckDuckGo Web Search (default)"; ;;
esac
local S="$(printf "%s\n%s" "${DEFAULT}" "${SE}" \
| ${DMENU_CMD} -p "Search Where?" -l 20)"
| ${DMENU_CMD} -p "Search Where?")"
C=$(echo "$C" | sed 's/ /%20/g')
case "${S}" in
OPEN*) URI="${C}"; ;;
@@ -136,7 +136,12 @@ choose_browser() {
gopher://*) DEFAULT="Lagrange (default)"; ;;
gemini://*) DEFAULT="Lagrange (default)"; ;;
*console.hetzner.cloud*) DEFAULT="Firefox (default)"; ;;
*youtube.com/watch*) DEFAULT="Mpv (default)"; ;;
*amazon.com*) DEFAULT="Chrome (default)"; ;;
*club.de*) DEFAULT="Chrome (default)"; ;;
*life.com*) DEFAULT="Chrome (default)"; ;;
*videos.com*) DEFAULT="Chrome (default)"; ;;
*comdirect.de*) DEFAULT="Chrome (default)"; ;;
*youtube.com*) DEFAULT="Chrome (default)"; ;;
*media.ccc.de/v/*) DEFAULT="Mpv (default)"; ;;
*.pdf|*.cb|*.ps) DEFAULT="Zathura (default)"; ;;
*.mp4|*.m4v|*.mkv) DEFAULT="Mpv (default)"; ;;
@@ -151,7 +156,7 @@ choose_browser() {
[Qq]uteb*r*) BROWSER="qutebrowser -R" ;;
[Ss]urf*) BROWSER=surf ;;
[Oo]tter*r*) BROWSER=otter-browser ;;
[Ll]uakit*) BROWSER="luakit -Un" ;;
[Ll]uakit*) BROWSER="luakit -v -U" ;;
[Cc]hrome*) BROWSER=chrome ;;
[Ff]irefox*) BROWSER=firefox ;;
[Tt]or-B*r*) BROWSER=tor-browser ;;
@@ -170,6 +175,6 @@ save_history() {
# main program starts here.
read_input
choose_wrapper
# choose_browser
#choose_browser
save_history
$BROWSER "$(printf '%s' "${URI}" | sed 's/ /%20/g')" &
$BROWSER "$(printf '%s' "${URI}" | sed 's/ /%20/g')" > /home/sdk/browser.log 2>&1 &

11
.bin/dexec_man Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
. $HOME/.bin/_config
SEL=$(man -k any= | $DMENU_CMD -l 10 -p "Man")
[ -z "$SEL" ] && exit 0
N=$(echo "$SEL" | cut -d"(" -f2 | cut -d")" -f1)
M=$(echo "$SEL" | cut -d"(" -f1 | cut -d"," -f1)
sterm -e man -s $N $M

14
.bin/dl-clear Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
find . -maxdepth 1 \
| grep -v ^.$ \
| grep -v "Telegram" \
| grep -v "Screenshots" \
| grep -v "OLD-"\
| while read file
do
date="$(stat -f "%Sm" -t %Y-%m "$file" )"
[ -f "OLD-$date" ] && mkdir -p OLD-$date
mv "$file" OLD-$date/
done
echo done.

View File

@@ -3,6 +3,7 @@
needs git--
cd ${PIMDIR}
git pull --autostash
git add *
git commit -am "Update $(date +"%Y-%m-%d %H:%M")"
git fetch

78
.bin/fb-getip.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/sh
# needs: curl, yq (xq)
# usage: fb-getip.sh [ip address]
#
# Endpoints & Services:
# http://fritz.box:49000/tr64desc.xml
# AVM TR064 Documentation:
# https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_TR-064_first_steps.pdf
# https://www.broadband-forum.org/technical/download/TR-064.pdf
FBHOST="fritz.box"
[ ! -z "$1" ] && FBHOST="$1"
# Variable parts, which can be looked up in the TR-064 documentation
SERVICE=WANIPConnection
ACTION=GetExternalIPAddress
# Endpoints supported by the fritzbox, can be looked up at the
# "Endpoint & Services" URL.
ENDPOINT=WANIPConn1
# SOAP protocol payload (https://en.wikipedia.org/wiki/SOAP)
# This is the language the fritzbox is "speaking". So we create this
# payload with the appropriage Service, Action variables.
PAYLOAD=\
'<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:'$ACTION' xmlns:u="urn:schemas-upnp-org:service:'$SERVICE':1" />
</s:Body>
</s:Envelope>'
# We use curl to send the payload with the appropriate soap+upnp header
# to the fritzbox and receive the SOAP response.
#
# Header explanation:
#
# - Header: Content-Type - describes that we send format text/xml with utf8 encoding.
# See HTTP Specification:
# https://www.rfc-editor.org/rfc/rfc9110.html#name-content-type
# (Chapter 8.3)
#
# - Header: SoapAction... - it's redundant with the payload information.
# See SoapAction specification:
# https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528
# (Chapter 6.1.1)
#
# - SoapAction:<parameter>... - This <parameter> is "urn:schemas-upnp-org:<service>
# Each <service> has it's own specifcation.
# WANIPConnection Service Specification:
# https://upnp.org/specs/gw/UPnP-gw-WANIPConnection-v1-Service.pdf
# (Chapter 2.1)
RESPONSE="$(curl -s "http://$FBHOST:49000/igdupnp/control/$ENDPOINT" \
-H "Content-Type: text/xml; charset=utf-8" \
-H "SoapAction:urn:schemas-upnp-org:service:$SERVICE:1#$ACTION" \
-d "$PAYLOAD")"
# The SOAP response is ugly XML (just like the requst), so we use "xq",
# which converts XML to JSON and allows us to operate on it with "jq"
# syntax.
# yq/xq documentation: https://kislyuk.github.io/yq
# jq documentation: https://jqlang.github.io/jq/manual
# Tutorial: https://www.ashbyhq.com/blog/engineering/jq-and-yq
#
# (once understood, these tools are _very_ powerful! - worth to learn)
# This "case" is only there so we can do a different kind parsing for
# other endpoints. Like when the ACTION variable is changed the parsing
# needs to be adapted.
case "$ACTION" in
GetExternalIPAddress) printf '%s' "$RESPONSE" \
| xq -r '."s:Envelope"."s:Body"."u:GetExternalIPAddressResponse".NewExternalIPAddress'
;;
*) printf '%s' "$RESPONSE"
;;
esac

View File

@@ -1,5 +1,9 @@
#!/bin/sh
export XDG_CACHE_HOME=/tmp firefox
export XDG_CACHE_HOME=/tmp
export MOZ_X11_EGL=1
export MOZ_PLUGIN_PATH=/usr/local/lib/mozilla/plugins
unset _SWM_WS
/usr/local/bin/firefox "$@"
pgrep -qf bin/firefox && args="--new-window"
/usr/local/bin/firefox $args "$@"

29
.bin/format-exfat.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh -e
_dev="$1"
[ -z $_dev ] && printf "usage: %s <sd2>\n" "$(basename $0)" && exit 2
[ $(id -u) -gt 0 ] && printf "you need superuser rights\n" && exit 2
dmesg | grep "$_dev" | grep -A1 scsibus | tail -n 2
printf "Format ${_dev} [y/N]? "
read
case $REPLY in
[yY]) ;;
*) exit 0; ;;
esac
printf "Overwriting first MBs with zeros:"
dd of=/dev/r${_dev}c if=/dev/zero bs=1M count=1 > /dev/null 2>&1
printf " ✅\n"
printf "Creating exFAT / NTFS partition:"
echo "edit 0\n07\n\n2048\n*\nw\nq\n" | fdisk -e "$_dev" > /dev/null 2>&1
printf " ✅\n"
printf "Creating exFAT file system (this may take a while)...\n"
mkexfatfs -s 2048 "/dev/${_dev}i"
printf "Creating exFAT file system: ✅\n"
printf "Mount:\ndoas mount.exfat /dev/%si /mnt\n" "$_dev"

View File

@@ -19,11 +19,11 @@ dd of=/dev/r${_dev}c if=/dev/zero bs=1M count=1 > /dev/null 2>&1
printf " ✅\n"
printf "Creating FAT32 partition:"
echo "edit 0\n0B\n\n512\n*\nw\nq\n" | fdisk -e "$_dev" > /dev/null 2>&1
echo "edit 0\n0B\n\n1024\n*\nw\nq\n" | fdisk -e "$_dev" > /dev/null 2>&1
printf " ✅\n"
printf "Creating FAT32 file system (this may take a while)...\n"
newfs_msdos -F32 -b65536 "${_dev}i"
printf "Creating FAT32 file system: ✅\n"
printf "Mount:\ndoas mkdir -p /mnt/%s && doas mount_msdos /dev/%si /mnt/%s\n" "$_dev" "$_dev" "$_dev"
printf "Mount:\ndoas mount_msdos /dev/%si /mnt\n" "$_dev"

81
.bin/g Executable file
View File

@@ -0,0 +1,81 @@
#!/bin/sh
# check if there's .git dir in a parent dir
isgit() {
_path="$PWD"
while [ -n "$_path" ]
do
if [ -d "$_path/.git" ]
then
return 0
fi
_path="${_path%/*}"
done
return 1
}
if ! isgit
then echo "no git repository"
return
fi
_width=$(tput cols)
if [ -z "$_width" ]
then
_width=60
fi
[ $_width -lt 43 ] \
&& _width=43 \
|| _width=$(( _width - 3 ))
_origin=$(git remote get-url origin \
2> /dev/null)
[ -n "$_origin" ] \
&& echo "# origin: $_origin"
_upstream=$(git remote get-url upstream \
2> /dev/null)
[ -n "$_upstream" ] \
&& echo "# upstream: $_upstream"
_base=$(git --no-pager log \
--abbrev-commit \
--pretty=format:'%h | %an: %s' \
HEAD~2...origin/HEAD~1 \
2> /dev/null)
_branch=$(git --no-pager branch \
--no-color \
--show-current \
2> /dev/null)
[ -n "$_base" ] \
&& printf '%s\n' "# branch ($_branch) fork point: $_base" \
| sed "s/\(.\{$_width\}\).*/\1.../"
_log=$(git --no-pager log \
--reverse \
--abbrev-commit \
--date=format:'%d.%m.%y %H:%S' \
--pretty=format:'%h|%ad|%an: %s' \
...origin/HEAD \
2>/dev/null)
if [ -n "$_log" ]
then
echo "# local commits"
printf '%s\n' "$_log" | sed "s/\(.\{$_width\}\).*/\1.../"
else
echo "# no local commits"
fi
_stat=$(git --no-pager status \
--short 2>/dev/null)
if [ -n "$_stat" ]
then
echo "# local changes:"
echo "$_stat"
else
echo "# no local changes"
fi

23
.bin/got-notes Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/cat
init: got init luakit.git
download: got clone git@github.com:luakit/luakit luakit.git
checkout: got checkout luakit.git luakit
commit: got commit
diff changes: got diff
diff branch main with patch: got diff main patch
list branches: got branch -l
switch/create branch: got branch testbranch
interactive revert: got revert -p -R .
rebase current branch on top of master: got update -b master
add file: got add
repo info: got info
import from CVS:
got import -r /var/git/src.git -I CVS -I obj /tmp/src

137
.bin/gpgfile.sh Executable file
View File

@@ -0,0 +1,137 @@
#!/bin/sh
# for shellrc:
# alias encrypt-kasse="gpgfile.sh -k 52BE43BA -k 7A97EAD5 -k 8AFDAD2D -e /path/to/kassenbuch.odt"
# alias decrypt-kasse="gpgfile.sh -d -e /path/to/kassenbuch.odt.gpg"
# alias encrypt-documents="gpgfile.sh -k 7A97EAD5 -e /path/to/documents"
# alias decrypt-documents"gpgfile.sh -d -e /path/to/documents.tar.gpg"
### functions
usage() {
echo "usage: $(basename $0) <options> <files/dirs>"
echo "options:"
echo " -k <key_id> key id (can be supplied multiple times)"
echo " -e encrypt files or directories (requires -k)"
echo " -d decrypt files or directories"
echo "note: directories will be wrapped in tar(1)"
exit 2
}
### main program
# parse arguments
while getopts 'k:edh' arg
do
case ${arg} in
k) keylist="$keylist -r $OPTARG" ;;
e) encrypt=1 ;;
d) encrypt=0 ;;
h) usage ;;
?) usage ;;
esac
done
# shift parsed arguments out of the way $1 starts now with files/dirs
shift $(($OPTIND - 1))
# print usage, if no file/dir argument is provided
[ -z "$1" ] \
&& echo "ERROR: No files/dirs argument provided." \
&& usage
# print usage, if no option argument was provided
[ "$OPTIND" == "1" ] \
&& echo "ERROR: No option provided (needs -d, or -e and -k)" \
&& usage
### handle encryption (set by -e)
if [ "$encrypt" -eq "1" ]
then
# no key?
[ -z "$keylist" ] \
&& echo "ERROR: Encryption mode (-e) needs a key (-k), which was not provided." \
&& exit 1
# loop at provided files
for item in "$@"
do
# Work in a subshell so dir changes won't be persistent.
# Due to this, we "return" instead of "continue".
# This is needed because we don't want to include the
# basedir hierarchy in tar files.
(
# change working directory
cd "$(dirname "$item")"
item="$(basename "$item")"
# don't handle non existant files
readlink -f "$item" > /dev/null 2>&1 \
|| { echo "$item: skipped: file not found" \
&& return; }
# don't re-encrypt gpg files
[ "${item##*.}" == "gpg" ] \
&& echo "$item: skipped: already gpg encrypted" \
&& return
# handle directory: tar + gpg, then remove original dir + tar
[ -d "$item" ] \
&& echo "$item -> $item.tar" \
&& tar -cf "$item.tar" "$item" \
&& rm -rf "$item" \
&& item="$item.tar"
# no return: fallthrough to next handler
# handle files: gpg, then remove original file
[ -f "$item" ] \
&& echo "$item -> $item.gpg" \
&& gpg -q -e $keylist -o "$item.gpg" "$item" \
&& rm -f "$item"
) # exit subshell
done
fi
### handle decryption (set by -d)
if [ $encrypt -eq 0 ]
then
for item in "$@"
do
# Work in a subshell so dir changes won't be persistent.
# Due to this, we "return" instead of "continue".
# This is needed because we don't want to include the
# basedir hierarchy in tar files.
(
# change working directory
cd "$(dirname "$item")"
item="$(basename "$item")"
# don't handle non existant files
readlink -f "$item" > /dev/null 2>&1 \
|| { echo "skipping: $item (reason: file not found)" \
&& return; }
# don't handle files that are not gpg encrypted
[ "${item##*.}" != "gpg" ] \
&& echo "skipping: $item (reason: not a gpg file)" \
&& return
# handle file: decrypt with gpg + delete encrypted version
[ "${item##*.}" == "gpg" ] \
&& echo "$item -> ${item%.*}" \
&& gpg -q -d -o "${item%.*}" "$item" \
&& rm -f "$item" \
&& item="${item%.*}"
# no return: fallthrough to next handler
# handle tar: if file ends in tar after decryption, untar it and delete the tar.
[ "${item##*.}" == "tar" ] \
&& echo "$item -> ${item%.*}" \
&& tar xf "$item" \
&& rm -f "$item"
) # exit subshell
done
fi

View File

@@ -1,296 +0,0 @@
#!/usr/bin/perl -w
my $debug = 0;
#
# ical2rem.pl -
# Reads iCal files and outputs remind-compatible files. Tested ONLY with
# calendar files created by Mozilla Calendar/Sunbird. Use at your own risk.
# Copyright (c) 2005, 2007, Justin B. Alcorn
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# version 0.5.2 2007-03-23
# - BUG: leadtime for recurring events had a max of 4 instead of DEFAULT_LEAD_TIME
# - remove project-lead-time, since Category was a non-standard attribute
# - NOTE: There is a bug in iCal::Parser v1.14 that causes multiple calendars to
# fail if a calendar with recurring events is followed by a calendar with no
# recurring events. This has been reported to the iCal::Parser author.
# version 0.5.1 2007-03-21
# - BUG: Handle multiple calendars on STDIN
# - add --heading option for priority on section headers
# version 0.5 2007-03-21
# - Add more help options
# - --project-lead-time option
# - Supress printing of heading if there are no todos to print
# version 0.4
# - Version 0.4 changes all written or inspired by, and thanks to Mark Stosberg
# - Change to GetOptions
# - Change to pipe
# - Add --label, --help options
# - Add Help Text
# - Change to subroutines
# - Efficiency and Cleanup
# version 0.3
# - Convert to GPL (Thanks to Mark Stosberg)
# - Add usage
# version 0.2
# - add command line switches
# - add debug code
# - add SCHED _sfun keyword
# - fix typos
# version 0.1 - ALPHA CODE.
=head1 SYNOPSIS
cat /path/to/file*.ics | ical2rem.pl > ~/.ical2rem
All options have reasonable defaults:
--label Calendar name (Default: Calendar)
--lead-time Advance days to start reminders (Default: 3)
--todos, --no-todos Process Todos? (Default: Yes)
--heading Define a priority for static entries
--help Usage
--man Complete man page
Expects an ICAL stream on STDIN. Converts it to the format
used by the C<remind> script and prints it to STDOUT.
=head2 --label
ical2rem.pl --label "Bob's Calendar"
The syntax generated includes a label for the calendar parsed.
By default this is "Calendar". You can customize this with
the "--label" option.
=head2 --lead-time
ical2rem.pl --lead-time 3
How may days in advance to start getting reminders about the events. Defaults to 3.
=head2 --no-todos
ical2rem.pl --no-todos
If you don't care about the ToDos the calendar, this will surpress
printing of the ToDo heading, as well as skipping ToDo processing.
=head2 --heading
ical2rem.pl --heading "PRIORITY 9999"
Set an option on static messages output. Using priorities can made the static messages look different from
the calendar entries. See the file defs.rem from the remind distribution for more information.
=cut
use strict;
use iCal::Parser;
use DateTime;
use Getopt::Long 2.24 qw':config auto_help';
use Pod::Usage;
use Data::Dumper;
use vars '$VERSION';
$VERSION = "0.5.2";
# Declare how many days in advance to remind
my $DEFAULT_LEAD_TIME = 3;
my $PROCESS_TODOS = 1;
my $HEADING = "";
my $help;
my $man;
my $label = 'Calendar';
GetOptions (
"label=s" => \$label,
"lead-time=i" => \$DEFAULT_LEAD_TIME,
"todos!" => \$PROCESS_TODOS,
"heading=s" => \$HEADING,
"help|?" => \$help,
"man" => \$man
);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;
my $month = ['None','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
my @calendars;
my $in;
while (<>) {
$in .= $_;
if (/END:VCALENDAR/) {
push(@calendars,$in);
$in = "";
}
}
print STDERR "Read all calendars\n" if $debug;
my $startdate = DateTime->new( year => 2010,
month => 4,
day => 1,
time_zone => 'US/Eastern',
);
my $oneyear = DateTime::Duration->new( years => 1);
my $oneweek = DateTime::Duration->new( weeks => -1);
$startdate = DateTime->now + $oneweek;
my $enddate = DateTime->now + $oneyear;
print STDERR "About to parse calendars\n" if $debug;
my $parser = iCal::Parser->new('start' => $startdate,
'debug' => 0,
'end' => $enddate);
my $hash = $parser->parse_strings(@calendars);
print STDERR "Calendars parsed\n" if $debug;
##############################################################
#
# Subroutines
#
#############################################################
#
# _process_todos()
# expects 'todos' hashref from iCal::Parser is input
# returns String to output
sub _process_todos {
my $todos = shift;
my ($todo, @newtodos, $leadtime);
my $output = "";
$output .= 'REM '.$HEADING.' MSG '.$label.' ToDos:%"%"%'."\n";
# For sorting, make sure everything's got something
# To sort on.
my $now = DateTime->now;
for $todo (@{$todos}) {
# remove completed items
if ($todo->{'STATUS'} && $todo->{'STATUS'} eq 'COMPLETED') {
next;
} elsif ($todo->{'DUE'}) {
# All we need is a due date, everything else is sugar
$todo->{'SORT'} = $todo->{'DUE'}->clone;
} elsif ($todo->{'DTSTART'}) {
# for sorting, sort on start date if there's no due date
$todo->{'SORT'} = $todo->{'DTSTART'}->clone;
} else {
# if there's no due or start date, just make it now.
$todo->{'SORT'} = $now;
}
push(@newtodos,$todo);
}
if (! (scalar @newtodos)) {
return "";
}
# Now sort on the new Due dates and print them out.
for $todo (sort { DateTime->compare($a->{'SORT'}, $b->{'SORT'}) } @newtodos) {
my $due = $todo->{'SORT'}->clone();
my $priority = "";
if (defined($todo->{'PRIORITY'})) {
if ($todo->{'PRIORITY'} == 1) {
$priority = "PRIORITY 1000";
} elsif ($todo->{'PRIORITY'} == 3) {
$priority = "PRIORITY 7500";
}
}
if (defined($todo->{'DTSTART'}) && defined($todo->{'DUE'})) {
# Lead time is duration of task + lead time
my $diff = ($todo->{'DUE'}->delta_days($todo->{'DTSTART'})->days())+$DEFAULT_LEAD_TIME;
$leadtime = "+".$diff;
} else {
$leadtime = "+".$DEFAULT_LEAD_TIME;
}
$output .= "REM ".$due->month_abbr." ".$due->day." ".$due->year." $leadtime $priority MSG \%a $todo->{'SUMMARY'}\%\"\%\"\%\n";
}
$output .= 'REM '.$HEADING.' MSG %"%"%'."\n";
return $output;
}
#######################################################################
#
# Main Program
#
######################################################################
print _process_todos($hash->{'todos'}) if $PROCESS_TODOS;
my ($leadtime, $yearkey, $monkey, $daykey,$uid,%eventsbyuid);
print 'REM '.$HEADING.' MSG '.$label.' Events:%"%"%'."\n";
my $events = $hash->{'events'};
foreach $yearkey (sort keys %{$events} ) {
my $yearevents = $events->{$yearkey};
foreach $monkey (sort {$a <=> $b} keys %{$yearevents}){
my $monevents = $yearevents->{$monkey};
foreach $daykey (sort {$a <=> $b} keys %{$monevents} ) {
my $dayevents = $monevents->{$daykey};
foreach $uid (sort {
DateTime->compare($dayevents->{$a}->{'DTSTART'}, $dayevents->{$b}->{'DTSTART'})
} keys %{$dayevents}) {
my $event = $dayevents->{$uid};
if ($eventsbyuid{$uid}) {
my $curreventday = $event->{'DTSTART'}->clone;
$curreventday->truncate( to => 'day' );
$eventsbyuid{$uid}{$curreventday->epoch()} =1;
for (my $i = 0;$i < $DEFAULT_LEAD_TIME && !defined($event->{'LEADTIME'});$i++) {
if ($eventsbyuid{$uid}{$curreventday->subtract( days => $i+1 )->epoch() }) {
$event->{'LEADTIME'} = $i;
}
}
} else {
$eventsbyuid{$uid} = $event;
my $curreventday = $event->{'DTSTART'}->clone;
$curreventday->truncate( to => 'day' );
$eventsbyuid{$uid}{$curreventday->epoch()} =1;
}
}
}
}
}
foreach $yearkey (sort keys %{$events} ) {
my $yearevents = $events->{$yearkey};
foreach $monkey (sort {$a <=> $b} keys %{$yearevents}){
my $monevents = $yearevents->{$monkey};
foreach $daykey (sort {$a <=> $b} keys %{$monevents} ) {
my $dayevents = $monevents->{$daykey};
foreach $uid (sort {
DateTime->compare($dayevents->{$a}->{'DTSTART'}, $dayevents->{$b}->{'DTSTART'})
} keys %{$dayevents}) {
my $event = $dayevents->{$uid};
if (exists($event->{'LEADTIME'})) {
$leadtime = "+".$event->{'LEADTIME'};
} else {
$leadtime = "+".$DEFAULT_LEAD_TIME;
}
my $start = $event->{'DTSTART'};
print "REM ".$start->month_abbr." ".$start->day." ".$start->year." $leadtime ";
if ($start->hour > 0) {
print " AT ";
print $start->strftime("%H:%M");
# print " SCHED _sfun MSG %a %2 ";
# fix 2024-10-04
print " +15 MSG %a %2 ";
} else {
print " MSG %a ";
}
print "%\"$event->{'SUMMARY'}";
print " at $event->{'LOCATION'}" if $event->{'LOCATION'};
print "\%\"%\n";
}
}
}
}
exit 0;
#:vim set ft=perl ts=4 sts=4 expandtab :

View File

@@ -1,3 +1,3 @@
#!/bin/sh
ipmitool -U ADMIN -P $(pass Local/TweetyIPMI | head -1) \
-I lanplus -H 10.20.30.21 $@;
-I lanplus -H tweety-ipmi.home.codevoid.de $@;

108
.bin/lddcopy Executable file
View File

@@ -0,0 +1,108 @@
#!/bin/sh
# FIXME: does not work with space in filenames or directories
# (can be fixed by | while read ... the ldd output, but.. why?)
# FIXME: directory permissions are not copied
# (can be fixed with stat -f '%p %u %g' . and walk the path with mkdir -m ...)
##
## USAGE
##
_usage() {
echo "usage: mkchroot [-xn] [-u or executable] directory"
echo "options: -u - runs for all executables found in /bin/ directories"
echo " -x - copy stuff required to connect to X"
echo " -n - copy stuff required for networking"
}
##
## HANDLE ARGUMENTS
##
while getopts xnuh arg
do
case $arg in
x) _with_x=1 ;; # creates /tmp with X connection
n) _with_network=1 ;; # copies resolv.conf
u) _update_mode=1 ;; # updates the existing directory
h) _usage; exit 0 ;;
esac
done
shift $(($OPTIND - 1))
if [ -z "$1" ] && [ -z "$_update_mode" ]
then
_usage
exit 1
fi
if [ -z "$2" ] && [ -z "$_update_mode" ]
then
_usage
exit 1
fi
if [ "$_update_mode" == "1" ]
then
_indir="$1"
else
_infile="$1"
_indir="$2"
fi
###
### FUNCTIONS
###
_ldd_extract() {
for _file in $(ldd "$1" | awk '/\// { print $7 }' | xargs)
do
_name="$(basename "$_file")"
_dir="$2/$(dirname "$_file" | cut -b2-)"
if [ ! -d "$_dir" ]
then
echo "mkdir: $_dir"
mkdir -p "$_dir"
fi
if [ ! -f "$_dir/$_name" ]
then
echo "copy: $_file -> $_dir/$_name"
cp -af "$_file" "$_dir/$_name"
else
echo "skip: $_file -> $_dir/$_name (existing)"
fi
done
}
_find_binfile() {
# remove basedir
_f=$(echo "$1" | sed "s|${1%%/*}||g")
_ofile="$(readlink -f "$_f" 2> /dev/null)"
echo $_ofile
}
###
### MAIN PROGRAM
###
if [ -z "$_update_mode" ]
then
_ldd_extract "$_infile" "$_indir"
fi
if [ "$_update_mode" == "1" ]
then
_binfiles="$(find "$_indir" -type f -path "*/bin/*")"
for _binfile in $_binfiles
do
_infile=
_infile=$(_find_binfile "$_binfile")
if [ -z "$_infile" ]
then
echo "skip: $_binfile -> $_infile (not found)"
else
_ldd_extract "$_infile" "$_indir"
fi
done
fi

139
.bin/luakit-env Executable file
View File

@@ -0,0 +1,139 @@
#!/bin/sh
_dir="$1"
shift
# load config
. $HOME/.lenv
_action="$1"
shift
# validation
if [ -z "$_env" ] || [ -z "$_dir" ]
then
echo "Incomplete environment"
exit 1
fi
if [ -z "$_action" ]
then
echo "No action provided"
exit 1
fi
# now we can start...
echo "luakit-$_env: perform $_action $@ (in $_dir)" | xargs
# change into environment
mkdir -p "$_dir"
_oldpwd="$PWD"
cd "$_dir"
# perform actions
if [ "$_action" == "help" ] || [ "$_action" == "h" ]
then
echo "usage: l action [args]"
echo " actions:"
echo " make - build luakit"
echo " remake - make with -j1 (for debugging)"
echo " test [test] - run luakit test suite [specific test]"
echo " debug [luakit args] - start in gdb, stop in main"
echo " pr [numbers] - show [pull] PR from luakit/luakit repo"
echo " update - update/rebase repository"
echo " reset - recreate environment ($_dir)"
echo " diff file env - diff file with other environment"
echo " update-port - update openbsd port from last commit"
echo
fi
if [ "$_action" == "test" ]
then
export G_ENABLE_DIAGNOSTIC=1;
luajit tests/run_test.lua $@;
fi
if [ "$_action" == "make" ]
then
set -x
gmake clean
gmake options
gmake -j 8 luakit
gmake tests/util.so
fi
if [ "$_action" == "remake" ]
then
gmake -j1 luakit
fi
if [ "$_action" == "reset" ]
then
if [ "$_env" == "dev" ]
then
cd /tmp
rm -rf "$_dir"
git clone git@github.com:c0dev0id/luakit "$_dir"
cd "$_dir"
set -xe
git remote add upstream git@github.com:luakit/luakit
git fetch upstream
git checkout develop
git rebase upstream/develop
git switch -c patch
set +xe
else
cd /tmp
rm -rf "$_dir"
git clone git@github.com:luakit/luakit "$_dir"
cd "$_dir"
fi
fi
if [ "$_action" == "update" ]
then
set -xe
if [ "$_env" == "dev" ]
then
git fetch --all
git checkout develop
git rebase upstream/develop --autostash
git checkout -
else
git checkout develop
git fetch --all
git rebase origin/develop
fi
set +xe
fi
if [ "$_action" == "diff" ]
then
if test -z "$1" || test -z "$2"
then
echo "args: <file> <env>"
exit 1
fi
set -x
f="$(readlink -f $_oldpwd/$1)"
f="${f#$_dir}"
vimdiff "$_dir/$f" "${_dir%$_env}$2/$f"
fi
if [ "$_action" == "pr" ]
then
if [ -n "$1" ]
then
for pr in $@
do gh pr checkout $pr
done
else
gh pr --repo luakit/luakit list $@ | cat
fi
fi
if [ "$_action" == "update-port" ]
then
export DEVELOPMENT_PATHS=0
cd /usr/ports/mystuff/www/luakit
./update.sh
fi

2
.bin/luakit-formfiller Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
sterm "vim $HOME/.local/share/luakit/forms.lua" &

View File

@@ -1,9 +1,60 @@
#!/bin/sh
set -xe
# Figure out what's the best directory to put tag files in.
# This is usually the top level of the project / source directory.
# We can figure this out in a source controlled directories.
# git: the top level dir is the one that contains the .git
# directory, so we traverse the directory hierarchy backwards and
# look for it.
# cvs: the top level dir is the first dir that still contains a CVS
# directory. So we traverse back the directory hierarchy and check
# it the parent directory has no CVS directory. Then it's the current
# one.
gitdir() {
set -x
_path="$PWD"
while [ -n "$_path" ]
do [ -d "$_path/.git" ] \
&& echo "$_path" \
&& break
_path="${_path%/*}"
done
}
cvsdir() {
set -x
_path="$PWD"
while [ -n "$_path" ]
do
[ ! -d "$_path/../CVS" ] \
&& echo "$_path" \
&& break
_path="${_path%/*}"
done
}
_gitdir="$(gitdir)"
_cvsdir="$(cvsdir)"
if [ -n "$_gitdir" ]
then
_tagdir=".git"
_wrkdir="$_gitdir"
elif [ -n "$_cvsdir" ]
then
_wrkdir="$_cvsdir"
_tagdir=".tags"
else
_wrkdir=${PWD}
_tagdir=".tags"
fi
echo "Creating tags in $_wrkdir/$_tagdir"
mkdir -p "$_wrkdir/$_tagdir"
# create files list
find "${PWD}/"* -type f \
find "${_wrkdir}/"* -type f \
\( -iname "*.c" \
-o -iname "*.cc" \
-o -iname "*.cpp" \
@@ -17,7 +68,7 @@ find "${PWD}/"* -type f \
-o -iname "*.pl" \
-o -iname "*.sh" \
-o -name "Makefile" \
\) > ${PWD}/.git/files
\) > ${_wrkdir}/${_tagdir}/files
# include extra directories
if [ ! -z "$1" ]
@@ -36,11 +87,11 @@ then
-o -iname "*.pl" \
-o -iname "*.sh" \
-o -name "Makefile" \
\) >> ${PWD}/.git/files
\) >> ${_wrkdir}/${_tagdir}/files
fi
# create cscope database
cscope -qbkCRv -P${PWD} -f ${PWD}/.git/cscope.out -i${PWD}/.git/files
cscope -qbkCRv -P${_wrkdir} -f ${_wrkdir}/${_tagdir}/cscope.out -i${_wrkdir}/${_tagdir}/files
# create tags file
ectags --sort=yes \
@@ -50,6 +101,6 @@ ectags --sort=yes \
--fields=+K \
--totals=yes \
--fields=fkst \
--exclude=.git \
-L ${PWD}/.git/files \
-f ${PWD}/.git/tags
--exclude=${_tagdir} \
-L ${_wrkdir}/${_tagdir}/files \
-f ${_wrkdir}/${_tagdir}/tags

32
.bin/mount-cryptoffs Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
_dev=${1:-sd2}
if mount | grep -q "/mnt"
then
echo "already mounted"
mount | grep "/mnt"
exit 1
fi
# check if already decrypted
_biodev=$(doas bioctl softraid0 | grep -B1 $_dev | head -1 | awk '{print $5}' \
|| exit 1)
# if not
if [ -z "$_biodev" ]
then
# decrypt
pass Local/hagibis-usb-nvme | doas bioctl -s -c C -l ${_dev}a softraid0
# and read again
_biodev=$(doas bioctl softraid0 | grep -B1 $_dev | head -1 | awk '{print $5}' \
|| exit 1)
fi
# it still might not be there (wrong password etc..)
if [ -n "$_biodev" ]
then
echo "${_dev}a attached as $_biodev"
# mount biodev
doas mount /dev/${_biodev}a /mnt \
&& echo "${_biodev}a mounted to /mnt"
fi

3
.bin/mount-exfat Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh -x
_dev=${1:-sd2i}
doas mount.exfat-fuse -o nodev,nosuid,noatime,uid=1000,gid=1000 /dev/${_dev} /mnt

3
.bin/mount-fat32 Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh -x
_dev=${1:-sd2}
doas /sbin/mount_msdos -o nodev,nosuid,noatime -u 1000 -g 1000 /dev/${_dev}i /mnt

3
.bin/mount-ffs Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh -x
_dev=${1:-sd2}
doas /sbin/mount_ffs /dev/${_dev}a /mnt

View File

@@ -1,2 +0,0 @@
#/bin/sh
doas /sbin/mount_msdos -o nodev,nosuid,noatime -u 1000 -g 1000

9
.bin/mount_rsync Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/sh
if mount | fgrep '/rsync.net' -q
then
echo "already mounted"
exit 1
fi
doas sshfs -o idmap=user,allow_other,uid=1000,gid=1000 zh4870@zh4870.rsync.net: /rsync.net

View File

@@ -1,6 +1,6 @@
#!/bin/sh
if mount | fgrep '/tank/' -q
if mount | fgrep -q '/tank/'
then
echo "already mounted"
exit 1

21
.bin/myxmenu Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/sh
get_catgirl() {
cd ~/.config/catgirl && ls * | xargs -n1 \
| while read line
do
print "\t$line\ttexec \"catgirl $line\""
done
}
IRC="$(get_catgirl)"
xmenu -i <<EOF | sh &
IRC
$IRC
Applications
IMG:./web.png Web Browser firefox
IMG:./gimp.png Image editor gimp
Terminal (xterm) xterm
Terminal (st) sterm
EOF

38
.bin/network Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/sh
### DEFAULTS
### ARGUMENTS
for arg in "$@"
do
case "$arg" in
start) _start=1 ;;
stop) _stop=1 ;;
status) _status=1 ;;
route) _route=1 ;;
wifi) _wifi=1 ;;
hotspot) _hotspot=1 ;;
adhoc) _adhoc=1 ;;
esac
shift
done
### FUNCTIONS
_ifconfig() {
[ -z "$_ifdata" ] \
&& _ifdata="$(ifconfig)"
echo "$_ifdata"
}
### DATA
_interfaces="$(_ifconfig | egrep "^[a-z]" | cut -d: -f1 | egrep -v "lo0|enc0|pflog0" | xargs)"
### MAIN PROGRAM
if [ -n "$_status" ]
then
for _dev in $_interfaces
do
# something with awk
done
fi

View File

@@ -1,19 +1,18 @@
#!/bin/ksh
#!/bin/ksh -x
f=$1
f="$1"
if [ -z "$f" ];
then
f="$(find $PWD $HOME $HOME/Downloads -maxdepth 1 -type f \
| sort -u \
| fzf -e -x -i)"
echo "no argument given"
exit 2
fi
###################################################
# URLS
# SSH
###################################################
if print "$f" | egrep -qi '^shell:|^ushell:|^cvs:';
if print "$f" | egrep -qi '^shell:|^ushell:|^cvs:|^home:';
then
_server=${f%%:*}
_dir=${f#*:}
@@ -21,84 +20,81 @@ then
exit 0
fi
###################################################
# TRY TO FIND MIME TYPE
###################################################
if print "$f" | egrep -qi '^http[s]{0,1}://';
then
case "$f" in
*.mkv) mpv "$f"; ;;
*.mp4) mpv "$f"; ;;
*.webm) mpv "$f"; ;;
*) sacc "$f"; ;;
esac
${BROWSER:=vimb} "$f"
exit 0
MIME="$(webmime "$f")"
TYPE="http"
fi
if print "$f" | egrep -qi '^gopher://';
if print "$f" | egrep -qi '^gopher[s]{0,1}://';
then
case "$f" in
*.mkv) mpv "$f"; ;;
*.mp4) mpv "$f"; ;;
*.webm) mpv "$f"; ;;
*) sacc "$f"; ;;
esac
exit 0
MIME=""
TYPE="gopher"
fi
###################################################
# REAL FILES
###################################################
if [ ! -f "$f" ];
if [ -f "$f" ]
then
print "Parameter is not a file."
exit 1
MIME="$(file -ib "$f")"
TYPE="file"
fi
###################################################
# EXTENSIONS
# TRANSLATE MIME TYPES TO EXTENSIONS
###################################################
EXT="$(print "${f##*.}" | tr '[:upper:]' '[:lower:]')"
case "$MIME" in
# full qualified
application/ogg) EXT=ogg; ;;
application/pdf) EXT=pdf; ;;
application/postscript) EXT=ps; ;;
application/vnd.oasis.opendocument.*) EXT=docx; ;;
audio/mpeg) EXT=mp3; ;;
audio/midi) EXT=midi; ;;
image/webp) EXT=webp; ;;
application/x-gzip) EXT=gz; ;;
# with wildcards
audio/*) EXT=generic_audio; ;;
video/*) EXT=generic_video; ;;
image/*) EXT=generic_image; ;;
# vim can handle a lot!
text/*) EXT=generic_text; ;;
esac
# no extension yet? Extract from file
[ -z "$EXT" ] && EXT="$(print "${f##*.}" | tr '[:upper:]' '[:lower:]')"
case "$EXT" in
docx) libreoffice "$f"; ;;
xlsx) libreoffice "$f"; ;;
txt) vim "$f"; ;;
m2ts) mpv "$f"; ;;
flv) mpv "$f"; ;;
mp3) aplay "$f"; ;;
aiff) mpva "$f"; ;;
sid) sidplay "$f"; ;;
out) kdump -RTf "$f" | less; ;;
torrent) aria2c "$f"; ;;
*) unset EXT; ;;
aiff) EXEC="mpv"; ;;
mkv) EXEC="mpv"; ;;
docx) EXEC="libreoffice"; ;;
flv) EXEC="mpv"; ;;
m2ts) EXEC="mpv"; ;;
mp3) EXEC="mpv"; ;;
mp4) EXEC="mpv"; ;;
pdf) EXEC="zathura"; ;;
out) EXEC="kdump -RTf"; ;;
sid) EXEC="sidplay"; ;;
torrent) EXEC="aria2c"; ;;
txt) EXEC="vim"; ;;
webm) EXEC="mpv"; ;;
xlsx) EXEC="libreoffice"; ;;
jpg) EXEC="nsxiv"; ;;
generic_text) EXEC="vim"; ;;
generic_video) EXEC="mpv"; ;;
generic_image) EXEC="nsxiv"; EXEC_HTTP="$BROWSER"; ;;
generic_audio) EXEC="mpv"; ;;
esac
if [ ! -z "$EXT" ];
then
exit 0;
fi
echo "TYPE=$TYPE | MIME=$MIME | EXT=$EXT | EXEC=$EXEC"
###################################################
# MIME TYPES
###################################################
case "$(file -ib "$f")" in
# full qualified
application/ogg) aplay "$f"; ;;
application/pdf) zathura "$f"; ;;
application/postscript) zathura "$f"; ;;
application/vnd.oasis.opendocument.*) libreoffice "$f"; ;;
audio/mpeg) aplay "$f"; ;;
audio/midi) timidity "$f"; ;;
# with wildcards
audio/*) aplay "$f"; ;;
video/*) mpv "$f"; ;;
image/webp) mpv "$f"; ;;
image/*) nsxiv -N floating -g 1280x720+300+180 -ab "$f"; ;;
# can't handle
application/octet-stream) print "Sorry, can't handle: $f"; ;;
# vim can handle a lot!
*) vim "$f"; ;;
case "$TYPE" in
gopher) exec $EXEC_GOPHER "$f"; ;;
http) exec $EXEC_HTTP "$f"; ;;
file) exec $EXEC "$f"; ;;
esac
exit 0

35
.bin/obsd-route Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/sh
[ $(id -u) -ne 0 ] && echo "root?" && exit 0
usage() {
echo "obsd-route [start,stop]"
exit 0
}
do_start() {
set -x
sysctl net.inet.ip.forwarding=1
ifconfig trunk0 destroy
ifconfig qwx0 inet autoconf
ifconfig re0 inet 192.168.23.1 netmask 255.255.255.0
rcctl enable dhcpd
rcctl set dhcpd flags re0
rcctl start dhcpd
}
do_stop() {
set -x
sysctl net.inet.ip.forwarding=0
ifconfig qwx0 -inet
ifconfig re0 -inet
rcctl stop dhcpd
rcctl disable dhcpd
sh /etc/netstart
}
case $1 in
start) do_start; ;;
stop) do_stop; ;;
*) usage;
esac

View File

@@ -7,6 +7,9 @@ trap abort 1 2 3 6 9 11
abort() { echo "Abort with >$0 $ARGS< on $(date)" >> /tmp/obsdmake.log; }
JOBS="${JOBS:=$(sysctl -n hw.ncpuonline)}"
JOBS=1
LOG="/home/sdk/obsdmake.log"
export CCACHE_DIR="/var/ccache"
export CCACHE_SLOPPINESS="locale,time_macros,random_seed,file_stat_matches,pch_defines"
@@ -24,12 +27,13 @@ if [ -z "$1" ]; then
exit 2
fi
echo "Start with >$0 $ARGS< on $(date)" >> /tmp/obsdmake.log
echo "Start with >$0 $ARGS< on $(date)" >> $LOG
doas mkdir -p /usr/obj /usr/xobj
doas chown build /usr/obj /usr/xobj
mkkernel() {
echo "Step: kernel start ($(date))" >> $LOG
set -xe
cd /sys/arch/$(machine)/compile/GENERIC.MP
doas make clean
@@ -39,9 +43,11 @@ mkkernel() {
doas make install
doas what /bsd
doas ln -f /bsd.booted /bsd.backup
echo "Step: kernel done ($(date))" >> $LOG
}
mkbase() {
echo "Step: base start ($(date))" >> $LOG
set -xe
cd /usr/src
doas make obj
@@ -50,9 +56,11 @@ mkbase() {
doas sysmerge
cd /dev
doas ./MAKEDEV all
echo "Step: base done ($(date))" >> $LOG
}
mkxenocara() {
echo "Step: xenocara start ($(date))" >> $LOG
set -xe
doas chown -R sdk /usr/xenocara
cd /usr/xenocara
@@ -61,9 +69,11 @@ mkxenocara() {
doas make obj
doas make -j${JOBS} build
doas make install
echo "Step: xenocara done ($(date))" >> $LOG
}
mkrelease() {
echo "Step: release start ($(date))" >> $LOG
set -xe
doas mkdir -p /data/{OpenBSD,Release}
doas chown -R build /data
@@ -86,6 +96,7 @@ mkrelease() {
cd /usr/src/distrib/$(machine)/iso
doas make
doas make install
echo "Step: release done ($(date))" >> $LOG
}
kernelclean() {
@@ -127,5 +138,5 @@ case "$1" in
all) mkkernel; mkbase; mkxenocara; ;;
esac
echo "Finished with >$0 $ARGS< on $(date)" >> /tmp/obsdmake.log
echo "Finished with >$0 $ARGS< on $(date)" >> $LOG
sync

26
.bin/osmc Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
USBDISK=/mnt/1TB
case "$1" in
mount) shift; ssh -tt osmc "sudo /sbin/cryptdisks_start usbdisk" \
&& ssh osmc "sudo mount /mnt/1TB" ;;
put|push) shift; rsync -rv --progress --append-verify "$@" osmc:$USBDISK/ ;;
df) shift; ssh osmc "df -h $USBDISK" ;;
ls) shift; ssh osmc "cd $USBDISK && ls $@ | grep -v lost+found" ;;
lls) shift; ssh osmc "cd $USBDISK && ls -lh | grep -v lost+found" ;;
del) shift; ssh osmc "cd $USBDISK && rm -v $@" ;;
ren) shift; ssh osmc "cd $USBDISK && mv \"$1\" \"$2\"" ;;
at) shift; ssh -tt osmc "tmux at" ;;
*) echo "usage: osmc <command> <args>"
echo " mount - mount USB disk"
echo " df - show disk space allocation"
echo " ls - list files"
echo " lls - list files with details"
echo " put <files> - copy files to USB disk"
echo " ren <old> <new> - rename file"
echo " del <files> - delete file"
echo " at - attach to tmux session"
exit 2
;;
esac

169
.bin/pkg-depends Executable file
View File

@@ -0,0 +1,169 @@
#!/bin/sh
# lazy config
_sqlports="/usr/local/share/sqlports"
_pkgpath="$(head -1 /etc/installurl)/$(uname -r)/packages/$(uname -m)"
# parameters can be freely combined
_usage() {
echo "usage: pkg-depends [options] <pkgpath>"
echo "options: -r - list run dependencies (default)"
echo " -l - list lib dependencies (default)"
echo " -b - list build dependencies"
echo " -t - list test dependencies"
echo " -p - show packges names (default)"
echo " -P - show port paths"
echo " -d <dir> - download packages to <dir>"
echo
echo "Only one flavor / subpackage in pkgpath(7) is supported."
exit 2
}
while getopts rlbtpPd: arg
do
case $arg in
l) _deps="$_deps 0" ;;
r) _deps="$_deps 1" ;;
b) _deps="$_deps 2" ;;
t) _deps="$_deps 3" ;;
p) _showmode=$(( _showmode + 1 )) ;;
P) _showmode=$(( _showmode + 2 )) ;;
d) _dldir=$OPTARG ;;
h) _usage ;;
?) _usage ;;
esac
done
shift $(($OPTIND - 1))
[ -z "$1" ] \
&& _usage
if [ ! -f "$_sqlports" ]
then
echo "$_sqlports not found. Install \"sqlports\" to use this script."
exit 1
fi
### FUNCTIONS
# a little helper in case no pkgpath is provided
_do_pkg() {
echo "pkg-depends needs pkgpath(7) as argument, pkg_info -P can help."
echo "Here, I'm calling it for you:"
echo
echo "$ pkg_info -P $1"
pkg_info -P "$1"
exit 0
}
_do_sql() {
# XXX: This lists all dependencies for the dependencies for the
# dependencies. I haven't encountert an endless loop here (yet?).
# I guess sqlite takes care or that?
# I'm sure the performance can be improved by not using the big
# ports view to grab the pkgname. But it's late and it works and
# this is a problem for another day.
_query="
WITH RECURSIVE pkg(x) AS (
SELECT \"$1\"
UNION
SELECT distinct dependspath FROM canonical_depends
JOIN pkg ON fullpkgpath=x WHERE type in ($2)
) SELECT x, fullpkgname FROM pkg
JOIN ports ON fullpkgpath=x;
"
echo "SQL QUERY: $_query" > $HOME/pkg-depends.log
echo "RESULT:" >> $HOME/pkg-depends.log
sqlite3 "$_sqlports" "$_query" | tee -a $HOME/pkg-depends.log
}
_handle_list() {
# build the comma sparated list that descibes the types
# to include in the list. Used in the sql query.
# _deps are set in getops, with a leading space when 0
# is not set. FIXME: I'm sure there's a better way to do this.
if [ -z "$_deps" ]
then
_deps="0,1"
else
_deps="$(echo "$_deps" \
| tr -s " " \
| sed 's/^ //g' \
| tr ' ' ',')"
fi
# download mode: create directory provided in -d <dir>
if [ -n "$_dldir" ]
then
mkdir -p "$_dldir"
fi
echo "Figuring out recursive dependencies, this may take some time..."
# FIXME: even though the list ist sorted -u this is only true for
# pkgpath, as textproc/libical and textproc/libical,-main are the
# going to be the same package. Simply stripping off all ,-main
# could fix it.. but it doesn't feel right.
_do_sql "$1" "$_deps" | sort -u | while read line
do
_portpath=$(echo "$line" | cut -d"|" -f1)
_pkgname=$(echo "$line" | cut -d"|" -f2)
# download mode: -d <dir>
if [ -n "$_dldir" ]
then
_extra="(downloading)"
fi
# showmode:
# unset: shows pkgpath and pkgname
# 1: shows pkgname only
# 2: shows pkgpath only
# 3: equals unset # FIXME: set 3 as default and don't handle unset.
# default || both on
if [ -z "$_showmode" ] || [ "$_showmode" == "3" ]
then
echo "$_portpath ($_pkgname) $_extra"
fi
# pkgname only
if [ "$_showmode" == "1" ]
then
echo "$_pkgname $_extra"
fi
# portpath only
if [ "$_showmode" == "2" ]
then
echo "$_portpath $_extra"
fi
# download mode: download file from mirror
# note: this needs sqlports information and the mirror to be
# in sync, which only the case on -release.
# FIXME: figure out a way to do this in snaps.
# Naive idea: cut off the version, get index list from mirror with
# match agains the non-version name and download everything found.
if [ -n "$_dldir" ]
then
ftp -MV -C -o $_dldir/$_pkgname.tgz $_pkgpath/$_pkgname.tgz
fi
done
if [ -n "$_dldir" ]
then
# XXX: Are both variables needed?
echo "Set the following environmane variables to enable offline installation:"
echo "$ export TRUSTED_PKG_PATH=\"$(readlink -f "$_dldir")\""
echo "$ export PKG_PATH=\"$(readlink -f "$_dldir")\""
# FIXME: name the package that has been downloaded. But to translate $1
# to the package name, another sqlports db call would be necessary.
# There is also pkg_info -e ..., but that only works for alread installed
# packages.
echo "$ pkg_add <package>"
fi
}
### MAIN PROGRAM :)
case "$1" in
*/*) _handle_list "$1" ;;
*) _do_pkg "$1" ;;
esac

View File

@@ -1,6 +1,9 @@
#!/bin/sh -x
cd /usr/ports
doas rm -rf pobj/* plist logs packages bulk update distfiles/*
doas rm -rf pobj/* plist logs packages bulk update
case "$1" in
-a) doas rm -rf distfiles/* ;;
esac
mkdir -p plist logs packages bulk update
doas make fix-permissions

View File

@@ -6,6 +6,6 @@ PN="${N[0]}${N[1]:+v${N[1]}}${N[2]:+p${N[2]}}"
PD=$(pwd | cut -d"/" -f4,5)
cd /usr/ports
cvs -d $CVSROOT diff -uNp "${PD}" > ~sdk/diffs/${PN}.diff
echo ~/diffs/${PN}.diff
cvs -d $CVSROOT diff -uNp "${PD}" > ~sdk/Diffs/${PN}.diff
echo ~/Diffs/${PN}.diff

8
.bin/port-go-modules-update Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
. ~/.bin/_config
set -x
needs go--
make MODGO_VERSION=latest modgo-gen-modules > modules.inc

18
.bin/port-jump Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
find /usr/ports/ \
-not \( -path "/usr/ports/pobj" -prune \
-o -path "*/distfiles" -prune \
-o -path "*/packages" -prune \
-o -path "*/logs" -prune \
-o -path "*/CVS" -prune \
-o -path "*/pkg" -prune \
-o -path "*/patches" -prune \
-o -path "*/files" -prune \
-o -path "*/openbsd-wip" -prune \
-o -path "*/mystuff" -prune \
-o -path "*/.git" -prune \
\) \
-maxdepth 4 \
-type d \
-iname "*$1*"

12
.bin/port-notes Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/cat
Update go:
make MODGO_VERSION=v1.49.0 modgo-gen-modules > modules.inc
make MODGO_VERSION=latest modgo-gen-modules > modules.inc
Update cargo:
make modcargo-gen-crates > crates.inc
make modcargo-gen-crates-licenses > crates.lic && mv crates.lic crates.inc
Distfile name change:
newname-${V}{oldname}${EXTRACT_SUFX}

2
.bin/port-notes-edit Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
vim /home/sdk/.bin/port-notes

25
.bin/port-search Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh -x
if [ -z "$1" ]
then
echo "usage: port-search [file pattern] <search term>"
exit 2
fi
if [ -n "$2" ]
then
_filter="-iname *$1*" \
_term="$2"
else
_term="$1"
fi
find /usr/ports/ \
-not \( -path "/usr/ports/pobj" -prune \
-o -path "*/distfiles" -prune \
-o -path "*/packages" -prune \
-o -path "*/logs" -prune \
-o -path "*/CVS" -prune \
\) \
-type f \
$_filter \
-exec ugrep -i -F -- "$_term" {} +

24
.bin/rec_scr_hw_noaudio.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
set -e
# configuration
_vidfile="/home/sdk/rec-screen.mkv"
_outfile="/home/sdk/rec-encoded-$(date "+%Y-%m-%d_%H%M%S").mp4"
_res="2880x1800"
_fps="60"
printf 'Press q to stop.\n'
set -x
ffmpeg -y -loglevel error -hide_banner \
-vaapi_device /dev/dri/renderD128 \
-framerate ${_fps} \
-f x11grab \
-video_size ${_res} \
-i :0 \
-vf 'hwupload,scale_vaapi=format=nv12' \
-c:v h264_vaapi \
-qp 24 \
-framerate ${_fps} \
"${_outfile}"

69
.bin/rtservermon.pl Executable file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/perl
use strict;
use warnings;
#
# ONLY OpenBSD modules included with the default installation are permitted!
#
use HTTP::Tiny;
use Net::Ping;
use Time::HiRes;
# Configuration hash (editable)
my %config = (
'timeout' => 0.20, # How long to wait before giving up on server response, in seconds
'debug' => 1, # Debug output?
'top' => 3, # How many entries to return?
'protocol' => 'tcp', # tcp, udp, icmp, et al
'port' => 'http', # (used in getservbyname sub)
);
# hash to store servers and response times to protocol/port requests
my %serverstats;
# create HTTP::Tiny instance
my $http = HTTP::Tiny->new;
# Get a list of all current OpenBSD FTP servers
my $response = $http->get('http://ftp.eu.openbsd.org/pub/OpenBSD/ftplist');
die "Failed!\n" unless $response->{success};
# Iterate through server list and get TCP/80 response time in ms
foreach my $line (split("\n", $response->{content})) {
if ($line !~ /(cdn)/) {
if ($line =~ /(http:\/\/)(.+?)(\/\S+)/) {
my $response = &httping($2);
$serverstats{$1.$2.$3} = $response if ($response);
}
}
}
# Sort & print servers by response time in ms
my $i = 0;
foreach my $key (sort {$serverstats{$a} <=> $serverstats{$b} } keys %serverstats) {
$i++;
print "$key\n";
last if $i eq $config{'top'};
}
#
# Ping TCP/80 and return response time or 0 if unresponsive + some diagnostic output
#
sub httping ($) {
my $host = shift;
my $ping = Net::Ping->new($config{'protocol'});
$ping->hires();
$ping->{port_num} = getservbyname($config{'port'}, $config{'protocol'});
print ("Trying $host... ") if $config{'debug'};
my ($retval, $duration, $ip) = $ping->ping($host, $config{'timeout'});
$ping->close();
$duration = int($duration * 1000);
if ($retval) {
print ("$duration ms\n") if $config{'debug'};
return $duration;
} else {
print ("unresponsive\n") if $config{'debug'};;
return 0;
}
}

2
.bin/samba Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
doas doas rcctl -f $1 smbd nmbd;

View File

@@ -1,3 +1,80 @@
#!/bin/sh
[ -z $1 ] && doas wsconsctl -n display.brightness \
|| doas wsconsctl display.brightness=$1
# devices
_primary=$(xrandr | grep -v ^Screen | head -1 | cut -d" " -f1)
_max_res=$(xrandr | grep "^ " | head -1 | xargs | cut -d" " -f1)
_con_dev=$(xrandr | grep " connected" | grep -v "$_primary" | cut -d" " -f1 | xargs)
_dis_dev=$(xrandr | grep "disconnected" | cut -d" " -f1 | xargs)
if [ "$1" == "auto" ]
then
xrandr --output $_primary --auto
fi
if [ "$1" == "mirror" ]
then
for _dev in $_con_dev
do
xrandr --output $_dev --same-as $_primary
done
fi
_loop() {
set -x
for _dev in $1
do xrandr --output $_dev $2
done
}
[ "$1" == "left" ] \
&& _loop "$_con_dev" "--left-of $_primary"
[ "$1" == "right" ] \
&& _loop "$_con_dev" "--right-of $_primary"
[ "$1" == "above" ] \
&& _loop "$_con_dev" "--above $_primary"
[ "$1" == "auto" ] \
&& _loop "$_con_dev $_primary" "--auto"
[ "$1" == "off" ] \
&& _loop "$_con_dev" "--off"
[ "$1" == "fullhd" ] \
&& xrandr --output $_primary --mode "1920x1080"
[ "$1" == "hd" ] \
&& xrandr --output $_primary --mode "1280x720"
[ "$1" == "max" ] \
&& xrandr --output $_primary --mode "$_max_res"
case "$1" in
[0-9]*) doas wsconsctl display.brightness=$1 ;;
esac
[ "$1" == "r" ] && [ -n "$2" ] \
&& xrandr --output $_primary --mode "$2"
if [ -z "$1" ]
then
echo "usage: res [mode]"
echo " auto - sets prefered mode for all connected displays"
echo " left - put screen left of primary screen"
echo " right - put screen right of primary screen"
echo " above - put screen above of primary screen"
echo " off - turn all connected screens off (except primary)"
echo " fullhd - set primary display resolution to FullHD (1920x1080)"
echo " hd - set primary display resolution to HD (1280x720)"
echo " max - set primary display to highest resolution ($_max_res)"
echo " r <res> - set primary display resolution"
echo " b <%> - display / set screen brightness"
echo
echo "Primary: $_primary"
echo "Connected: $_con_dev"
echo "Brightness: $(doas wsconsctl -n display.brightness)%"
echo
fi
exit 0

13
.bin/selfhost-update.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
# Selfhost DynDns Update
# Usage:
# IPv4 Update: selfhost-update.sh
# IPv6 Update: selfhost-update.sh -6
# Note, min 30 seconds between calls! (rate limit)
ID=$(pass Internet/selfhost.de | grep DynDnsUser | cut -d" " -f2)
PW=$(pass Internet/selfhost.de | grep DynDnsPass | cut -d" " -f2)
set -x
curl $1 "https://$ID:$PW@carol.selfhost.de/nic/update?textmodi=1"

View File

@@ -2,6 +2,9 @@
. ${HOME}/.bin/_config
unset QT_FONT_DPI
unset GDK_DPI_SCALE
trap cleanup 1 2 3 6
cleanup() { rm -f "$file"; }

97
.bin/subsonic Executable file
View File

@@ -0,0 +1,97 @@
#!/bin/sh
# subsonic
alias subsonic-cli="\subsonic-cli -c $HOME/.subsonic-cli.conf"
subsonic-play() {
# $1 songId
for song in $@
do
echo $song > /tmp/.playing
subsonic-cli stream -p id $song \
| mpv --force-window=no --loop=no - || exit 0
done
}
subsonic-random() {
while true;
do
echo "Fetching moar dataaa.."
subsonic-play $(subsonic-cli getRandomSongs \
| jq -r '.randomSongs[][].id')
done
}
subsonic-favorites() {
while true;
do
echo "Fetching moar dataaa.."
subsonic-play $(subsonic-cli getStarred \
| jq -r '.starred[][].id' \
| sort -r)
done
}
subsonic-search() {
{
echo "|ALBUMID|ID|ALBUM|ARTIST|TITLE|GENRE|"
printf "|%s|%s|%s|%s|%s|%s|\n" "--------------------------------"\
"--------------------------------"\
"--------" "--------" "--------" "--------"
subsonic-cli search3 \
-p songcount 200 \
-p query "$@" \
| jq -r '.searchResult3[][]|select(.contentType!=null)|[.albumId,.id,.album,.title,.artist,.genre]' \
| tr -d '", ' \
| awk '/^\[/ { S++ } \
/^\]/ { S-- } \
S==0 { NR=0 } \
NR==2 { AID=$0 } \
NR==3 { ID=$0 } \
NR==4 { ALBUM=$0 } \
NR==5 { TITLE=$0 } \
NR==6 { ARTIST=$0 } \
NR==7 { GENRE=$0 } \
NR==0 { printf("|%s|%s|%s|%s|%s|%s|\n", AID, ID, ALBUM, ARTIST, TITLE, GENRE) }'
} | column -s'|' -t
}
subsonic-star() {
[ -f /tmp/.playing ] \
&& subsonic-cli star -p id $(cat /tmp/.playing | tail -1) \
|| echo bruh.
}
subsonic-unstar() {
[ -f /tmp/.playing ] \
&& subsonic-cli unstar -p id $(cat /tmp/.playing | tail -1) \
|| echo bruh.
}
subsonic-download() {
# $1 albumId
NAME=$(subsonic-cli getAlbum -p id $1 \
| jq -r '.album.artist,.album.name' | xargs | tr ' ' '-')
printf "Downloading to %s/subsonic-download/%s.zip\n" "$HOME" "$NAME"
mkdir -p "$HOME/subsonic-download"
subsonic-cli download -p id $1 | pv > "$HOME/subsonic-download/$NAME.zip"
}
if [ -z $1 ]
then
cat <<"EOF"
usage: subsonic <command> <args>
play <song id> - play song with id
download <album id> - download album with id
[un]star - [un]star currently playing song
search <term> - show song/album for term
favorites - play starred songs
random - play random songs
EOF
else
subsonic-$1 $2
fi

7
.bin/tailscale-tunnel Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/ksh
# doas tailscale up --auth-key=tskey-auth-kx3Lf18kgg11CNTRL-5QJ7tUCJ8KAoPqVtJKY6MAzghyuCoaR9F
doas tailscale up \
--reset \
--advertise-exit-node \
--accept-routes \
--accept-dns=true

6
.bin/tailscale-tunnel-client Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/ksh
# doas tailscale up --auth-key=tskey-auth-kx3Lf18kgg11CNTRL-5QJ7tUCJ8KAoPqVtJKY6MAzghyuCoaR9F
doas tailscale up \
--reset \
--accept-dns=true \
--exit-node=dalek

View File

@@ -1,13 +1,22 @@
#!/bin/sh
. $HOME/.bin/_config
[ -d "$1" ] || ( printf "Usage: backup <target>\n" && exit 2; )
_target=$(readlink -f "$1" 2> /dev/null)
[ ! "$_target" ] \
&& printf "Usage: backup <target>\n" \
&& exit 2;
print "pass Internet/Tarsnap.key > /root/tarsnap.key ..."
pass Internet/Tarsnap.key | doas tee /root/tarsnap.key > /dev/null
doas chown root:sdk /root/tarsnap.key
doas chmod 640 /root/tarsnap.key
doas chmod 750 /root
print "Tarsnap Backup:"
_target=$(readlink -f "$1")
_key=$(pwgen -n1 8)
_date=$(date "+%Y-%m-%d %H:%M")
_host=$(uname -n)
doas tarsnap --humanize-numbers --checkpoint-bytes 52428800 --exclude "*/.git/*" -cvf "$_host: $_target $_date ($_key)" "$_target"
doas tarsnap --humanize-numbers --checkpoint-bytes 52428800 --exclude "*/.git/*" -cvf "$_host: $_target $_date ($_key)" "$_target"

38
.bin/tarsnap-restore Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/sh
. $HOME/.bin/_config
print "Tarsnap Restore:"
if [ -z "$1" ]; then
doas tarsnap --list-archives | sort
printf "Usage: restore <key_id>\n"
exit 2
fi
_backup="$(doas tarsnap --list-archives | grep "$1")"
if [ -z "$_backup" ]; then
print "No backup with key id $1 found."
exit 1
fi
print "Found Backup: $_backup"
mkdir -p "restore_$1"
print "Extracting to: $(readlink -f $PWD/restore_$1)"
if [ -f "restore_$1/.done" ]
then
print "Skipping, because restore_$1/.done file exists."
else
doas tarsnap -tf "$_backup" \
| xargs -P 50 -n 1 -t \
doas tarsnap --humanize-numbers --resume-extract --chroot -xf "$_backup" -C "restore_$1" --
if [ $? -eq 0 ]
then
print "Data restored in $(readlink -f "restore_$1")"
touch "restore_$1/.done"
else
print "Restore aborted..."
fi
fi
print ""

10
.bin/umount-cryptoffs Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
_dev=${1:-sd3}
doas umount /mnt 2>&1 | grep -q busy && echo "/mnt is busy" && exit 1
_biodev=$(doas bioctl softraid0 | grep -C1 sd3 | grep CRYPTO | awk '{ print $5 }')
if [ -n "$_biodev" ]
then
doas bioctl -d ${_biodev} && echo "bioctl: $_dev detached"
else
echo "bioctl: $_dev: currently not attached"
fi

2
.bin/umount_rsync Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
doas umount /rsync.net

View File

@@ -1,4 +1,6 @@
#!/bin/sh
echo "Updating abook addressbook"
cat /home/sdk/.isync/contacts/*.vcf \
| abook --convert --informat vcard --outformat abook \
> /home/sdk/.abook/addressbook

137
.bin/update-adlist Executable file
View File

@@ -0,0 +1,137 @@
#!/bin/sh -e
trap _restore_all 1 2 3 6
# list of filenames can can be fetched from $_url
_list=/etc/unwind/blocklistproject.txt
_url=https://blocklistproject.github.io/Lists/alt-version
# download blocklists here
_dir=/etc/unwind/lists
# combined, sorted and filtered list of all lists configured in $_list
# configure in /etc/unwind.conf:
# block list "/etc/unwind/_assembled.txt" log
_unwind_blocklist="/etc/unwind/_assembled.txt"
if [ ! -f $_list ]
then
echo "Creating new adlist /etc/unwind/blocklistproject.txt:"
doas mkdir -p $_dir
doas tee $_list <<EOF
## from https://github.com/blocklistproject/Lists
## ## => comment
## # => disabled list (will be deleted if present)
abuse-nl.txt
adobe-nl.txt
ads-nl.txt
basic-nl.txt
crypto-nl.txt
drugs-nl.txt
#everything-nl.txt
facebook-nl.txt
fortnite-nl.txt
fraud-nl.txt
gambling-nl.txt
malware-nl.txt
phishing-nl.txt
piracy-nl.txt
porn-nl.txt
ransomware-nl.txt
redirect-nl.txt
scam-nl.txt
smart-tv-nl.txt
tiktok-nl.txt
torrent-nl.txt
tracking-nl.txt
twitter-nl.txt
vaping-nl.txt
whatsapp-nl.txt
youtube-nl.txt
EOF
fi
_restore_all() {
echo "Signal received, aborting..."
for _f in $_dir/*.old
do
echo "Restore: $(basename $_f)"
doas mv -f "$_f" "${_f%%.old}"
done
_assemble
_restart_unwind
exit 1
}
_backup() {
_f=$(basename "$1")
if [ -f "$_dir/$_f" ]
then
echo "Backup: $_f -> $_f.old"
doas mv -f "$_dir/$_f" "$_dir/$_f.old"
fi
}
_restore() {
_f=$(basename "$1")
if [ -f "$_dir/$_f.old" ]
then
echo "Restore: $_f.old -> $_f"
doas mv -f "$_dir/$_f" "$_dir/$_f.old"
fi
}
_download() {
echo "Download: $_file"
doas ftp -V -o "$_dir/$_file" "$_url/$_file" > /dev/null \
&& doas rm -f "$_dir/$_file.old"
}
_disabled() {
if echo "$1" | grep -q "^#"
then
_f=$(basename "$1" | tr -d '# ')
echo "Skip (disabled): $_f"
doas rm -f $_dir/$_f
return 0
fi
return 1
}
_domainfilter() {
# chain grep commands used in assemble pipe
grep -Ev "torrent|tattoo|xhamster|xvideos|porn|motherless|redgifs" \
| grep -Ev "whatsapp\.net|whatsapp\.com|instagram\.com" \
| grep -Ev "adobe\.com|adobelogin\.com" \
| grep -Ev "microsoft\.com|archive\.org|sony\.com|playstation|psn|fotostelvio"
}
_assemble() {
echo "Assemble blocklist: $_unwind_blocklist"
cat $_dir/*.txt \
| tr -d " " \
| grep -v '^#' \
| grep -v '^-' \
| grep -v '^$' \
| cut -d "#" -f1 \
| sed 's/\.$//g' \
| _domainfilter \
| doas sort -uo $_unwind_blocklist
}
_restart_unwind() {
doas rcctl restart unwind
}
for _file in $(grep -v "^##" $_list \
| cut -d "#" -f1 \
| xargs)
do
if ! _disabled $_file
then
_backup $_file
_download || _restore
fi
done
_assemble
_restart_unwind

View File

@@ -1,6 +1,6 @@
#!/bin/ksh
FILE="$HOME/.ksh.complete"
FILE="$HOME/.kshrc.autocomplete"
rm -f "${FILE}"
@@ -37,12 +37,27 @@ add "set -A complete_kill_1 -- " "-9 -HUP -INFO -KILL -TERM"
#
add "set -A complete_ifconfig_1 -- " "$(ifconfig | grep ^[a-z] | cut -d: -f1)"
#
# manpages
#
S1="$(man -s 1 -k any= | cut -d"(" -f1 | tr -d "," | xargs)"
S2="$(man -s 2 -k any= | cut -d"(" -f1 | tr -d "," | xargs)"
S3="$(man -s 3 -k any= | cut -d"(" -f1 | tr -d "," | xargs)"
S4="$(man -s 4 -k any= | cut -d"(" -f1 | tr -d "," | xargs)"
S5="$(man -s 5 -k any= | cut -d"(" -f1 | tr -d "," | xargs)"
S8="$(man -s 8 -k any= | cut -d"(" -f1 | tr -d "," | xargs)"
add "set -A complete_man_1 -- " "$S1 $S5 $S8"
#
# AMUSED
#
ARGS="add flush jump load monitor next pause play prev repeat restart show status stop toggle"
add "set -A complete_amused_1 -- " "$ARGS"
add "set -A complete_l_1 -- " "make remake test debug pr update reset diff update-port"
add "set -A complete_upload_1 -- " "rm rml ls last ren renl fixl sh ksh txt log gz tgz"
#
# GOT
#

10
.bin/update-luakit-adlist Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh -xe
for list in easylist/easylist \
easylist/easyprivacy \
easylist/fanboy-social \
easylistgermany/easylistgermany
do
ftp -o $HOME/.local/share/luakit/adblock/$(basename $list).txt \
https://easylist.to/${list}.txt
done

14
.bin/update-mystuff Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh -xe
mystuff="
/usr/ports/mystuff/x11/st-sdk
/usr/ports/mystuff/sysutils/libtree
/usr/ports/sysutils/tarsnap
"
for p in $mystuff
do
cd $p
make clean=all
make reinstall
done

39
.bin/update-pim-all Executable file
View File

@@ -0,0 +1,39 @@
#/bin/sh -xe
. ~/.bin/_config
needs vdirsyncer-- mu-- isync-- git-- p5-iCal-Parser-- remind--
# snapshot
cd /home/sdk/.reminders
git add *
git commit -m "Update $(date +"%Y-%m-%d %H:%M:%S")" || true
# copy uugrn calendard to dalek
scp -q vorstand@vorstand.uugrn.org:private/Kalender/uugrn.rem \
sdk@home.codevoid.de:.reminders/uugrn.rem
# copy all calendars from dalek to local
scp -q sdk@home.codevoid.de:.reminders/\*.rem \
/home/sdk/.reminders/
# download vcal/vcard from icloud / radical
vdirsyncer sync
# create import.rem from ical events (XXX fix this mess)
find ~/.isync -name "*.ics" -exec cat {} + \
| ical2rem --no-todos \
| fgrep -v "REM MSG" \
| sed 's,\\n, ,g' \
| tr -d '\' \
| sed 's/ / /g' \
> /home/sdk/.reminders/import.rem
# create abook addressbook
cat /home/sdk/.isync/contacts/*.vcf \
| abook --convert --informat vcard --outformat abook \
> /home/sdk/.abook/addressbook
# sync email to offline
mbsync -a
# index email
mu index

View File

@@ -1,25 +1,267 @@
#!/bin/sh -e
file="$1"
# manage files in a webroot
# needs:
# - sh: cp, rm, mv, echo, basename, dirname
# - openssh: ssh, scp
# - coreutils: chmod, sed, tail
# - archivers: gzip, tar
# - xclip
[ -z $file ] \
&& file="$(find $PWD $HOME $HOME/Downloads -maxdepth 2 -type f \
| fgrep -v "/." \
| sort -u \
| fzf -e -x -i)"
###
### CONFIGURATION
###
[ -z $file ] \
&& exit 0
# remote patch uploaded files should go
_rpath="/home/www/htdocs/ptrace/paste"
scp "$file" \
sdk@home.codevoid.de:make-web/src/paste/
# web url where the uploaded files can be accessed
_weburi="https://ptrace.org"
ssh sdk@home.codevoid.de \
"cd ~/make-web && make install"
# ssh user@host
_sshhost="sdk@codevoid.de"
echo "https://ptrace.org/$(basename "$file")" \
| sed 's/ /%20/g' \
| xclip -f -r
# permissions (for the fixl command)
_chown="sdk:www"
_chmod="u+rw,g+r"
echo
###
### SET ARGUMENT SWITCHES
###
for arg in "$@"
do
case "$arg" in
# extensions
sh) _ext=".sh" ;;
ksh) _ext=".ksh" ;;
txt) _ext=".txt" ;;
log) _ext=".log" ;;
# archive mode
gz) _gz=1 ;;
tgz) _tgz=1 ;;
# commands
rm) _rm=1 ;;
rml) _rmlast=1 ;;
ls) _ls=1 ;;
l|last) _last="-1" ;;
-[0-9]*) _last="$arg" ;;
fixl) _fixperm=1 ;;
ren|mv) _mv=1 ;;
renl|mvl) _mvlast=1 ;;
-h) ;; # swallow
*) break; ;;
esac
shift;
done
###
### FUNCTIONS
###
# fetches remote file list
remote_list() {
ssh $_sshhost \
"cd $_rpath/ \
&& ls -1tr"
}
# formats file list output
remote_list_print() {
while read f
do
echo "$_weburi/$(echo "$f" \
| sed 's/ /%20/g') ($f)"
done
}
copy_and_print() {
echo "$_weburi/$(basename "$1")" \
| sed 's/ /%20/g' \
| xclip -f -r
echo
}
###
### MAIN PROGRAM
###
# HANDLE CASE: "standard input"
# upload with provided or generated filename
if [[ ! -t 0 ]]
then
fname="$1"
[ -z "$fname" ] \
&& fname="$(date +"%Y-%m-%d_%H%M%S").txt"
cat - | ssh $_sshhost "cat - > \"$_rpath/$fname\""
copy_and_print "$fname"
exit 0
fi
# HANDLE CASE: "list all remote files"
if [ -n "$_ls" ]
then
remote_list \
| remote_list_print
exit 0
fi
# HANDLE CASE: "list last N remote files"
if [ -n "$_last" ]
then
remote_list \
| tail $_last \
| remote_list_print
exit 0
fi
# HANDLE CASE: rename remote file
if [ -n "$_mv" ]
then
_arg1=$(basename "$1")
_arg2=$(basename "$2")
ssh $_sshhost \
"cd $_rpath/ \
&& mv -v \"$_arg1\" \"$_arg2\""
echo "$_arg2" | remote_list_print
exit 0
fi
# HANDLE CASE: rename the last uploaded remote file
if [ -n "$_mvlast" ]
then
_arg1=$(basename "$1")
lastfile="$(remote_list | tail -1)"
ssh $_sshhost \
"cd $_rpath/ \
&& mv -v \"$lastfile\" \"$_arg1\""
echo "$_arg1" | remote_list_print
exit 0
fi
# HANDLE CASE: delete remote file
if [ -n "$_rm" ]
then
for file in "$@"
do
ssh $_sshhost \
"cd $_rpath/ \
&& rm -v \"$(basename "$file")\"" \
|| true
done
exit 0
fi
# HANDLE CASE: delete last uploaded remote file
if [ -n "$_rmlast" ]
then
lastfile="$(remote_list | tail -1)"
echo "rm $lastfile"
ssh $_sshhost \
"cd $_rpath/ \
&& rm -f \"$lastfile\"" \
|| true
exit 0
fi
# HANDLE CASE: fix permission of last file
if [ -n "$_fixperm" ]
then
lastfile="$(remote_list | tail -1)"
echo "Fixing: $lastfile"
ssh $_sshhost "cd $_rpath/; \
chown $_chown \"$lastfile\"; \
chmod $_chmod \"$lastfile\"; \
ls -lh \"$lastfile\""
exit 0
fi
# HANDLE CASE: upload of files and folders
if [ $# -gt 0 ]
then
for item in "$@"
do
# the whole handling shall run in a subshell so all variables
# are reset when we leave the scope. Note, that this requires
# us to "return", instead of "continue" skip to the next loop
# iteration
(
[ ! -e "$item" ] \
&& echo "File or directory not found: $item" \
&& return
# target filename
file="$(basename "$item")$_ext"
# CASE "file" "no archive mode"
if [ -f "$item" ] && [ -z "$_tgz" ] && [ -z "$_gz" ]
then
echo "Uploading $item as $file"
scp -q "$item" $_sshhost:"$_rpath/$file"
copy_and_print "$file"
return
fi
# CASE "folder"
[ -d "$item" ] && _tgz=1
# CASE "tgz archive mode"
if [ -n "$_tgz" ]
then
file="$file.tgz"
echo "Uploading $item as $file"
# moving closer to the item to not archive the whole path
cd $(dirname "$item")
tar czf - "$(basename "$item")" \
| ssh $_sshhost "cat - > \"$_rpath/$file\""
copy_and_print "$file"
return
fi
# CASE "gz archive mode"
if [ -f "$item" ] && [ -n "$_gz" ]
then
file="$file.gz"
echo "Uploading \"$item\" as \"$file\""
cat "$item" | gzip \
| ssh $_sshhost "cat - > \"$_rpath/$file\""
copy_and_print "$file"
return
fi
# hopefully never reached
echo "Unhandled situation for: $item"
) # leave scope & reset variables
done
fi
# USAGE
if [ $# -eq 0 ]
then
echo "usage: upload [command] [ext] [<files>]"
echo " upload [filename] < file"
echo " cat file | upload [filename]"
echo
echo " Commands:"
echo " rm <files> - remove files"
echo " rml - remove last upload"
echo " ls - list files"
echo " l|last - list last file"
echo " -0..N - list N last files"
echo " mv|ren <oldname> <newname> - rename file"
echo " mvl|renl <newname> - rename last uploaded file"
echo " fixl - fix permission of last uploaded file"
echo
echo " Extensions:"
echo " sh, ksh, txt, log - add extension to file"
echo " gz, tgz - uploads file as archive (tgz is always used for folders)"
echo
echo " <files> - files or directories to upload (needs to be the last argument)"
echo
echo "Special Case:"
echo " When data is piped to the script it expects only one"
echo " optional argument, which would be the target filename."
echo
exit 2
fi

View File

@@ -18,7 +18,7 @@ nature
essen
🍏🍎🍐🍊🍋🍌🍉🍇🍓🍈🍒🍑🍍🍅🍆🌽🍠🍞🍳🍗🍖 🍔🍟🍕🍝🍜🍲🍛🍣🍱🍤🍚🍧🍨🍦🍮🍭🍬🍫🍩🍪🌰
🍯🍼☕🍵🍶🍺🍻🍷🍸🍹🍴
🍯🍼☕🍵🍶🍺🍻🍷🍸🍹🍴🥂🍾
activity

26
.bin/webmime Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
if [ -z "$1" ]
then
>&2 echo "webmime: no argument given"
exit 2
fi
URL="$(echo "$1" | grep -i ^http)"
if [ -z "$URL" ]
then
>&2 echo "webmime: argument is not a http url ($1)"
exit 1
fi
>&2 echo "webmime: reading content-type from: $1"
R="$(curl --connect-timeout 5 -sI "$URL" | grep -i "^content-type:" | tr -d ' ' | awk -F'[:;]' '{ print $2 }')"
if [ -z "$R" ]
then
>&2 echo "webmime: no content-type header found ($1)"
exit 1
fi
echo "$R" | col -b

1
.bin/xdg-open Symbolic link
View File

@@ -0,0 +1 @@
nnn.sh

View File

@@ -5,8 +5,21 @@ then
exit 2
fi
mkdir -p "$HOME/ytdl/$1/"
ksh-update-completions &
if [ ! -d "$HOME/ytdl/$1/" ]
then
mkdir -p "$HOME/ytdl/$1/"
update-ksh-completions
. $HOME/.kshrc.autocomplete
fi
cd "$HOME/ytdl/$1/"
yt-dlp --cookies-from-browser chromium "$2"
shift
yt-dlp \
--print filename \
--cookies-from-browser firefox \
--user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0" \
--preset-alias mp4 \
--embed-metadata \
--embed-subs \
--restrict-filenames \
-o "%(channel&{} - |)s%(uploader&{} - |)s%(playlist|&{} - )s%(playlist_index&{} - |)s%(title)s.%(ext)s" \
"$@"

4
.config/gopass/config Normal file
View File

@@ -0,0 +1,4 @@
[mounts]
path = /home/sdk/.password-store
[audit]
concurrency = 1

View File

@@ -4,8 +4,8 @@
require "lfs"
local unique_instance = require "unique_instance"
unique_instance.open_links_in_new_window = true
-- local unique_instance = require "unique_instance"
-- unique_instance.open_links_in_new_window = true
-- Set the number of web processes to use. A value of 0 means 'no limit'.
-- luakit.process_limit = 1
@@ -57,10 +57,10 @@ local binds = require "binds"
local settings = require "settings"
local settings_chrome = require "settings_chrome"
settings.window.home_page = "luakit://newtab"
-- settings.window.scroll_step = 20
-- settings.window.home_page = "luakit://newtab"
-- settings.window.scroll_step = 600
settings.window.zoom_step = 0.2
settings.webview.zoom_level = 100
settings.webview.zoom_level = 90
settings.window.close_with_last_tab = true
-- search engines
@@ -79,19 +79,19 @@ settings.window.search_engines.default = settings.window.search_engines.ddg
-- local adblock_chrome = require "adblock_chrome"
-- Enable Developer Tools
-- local webinspector = require "webinspector"
local webinspector = require "webinspector"
-- Add uzbl-like form filling
-- local formfiller = require "formfiller"
-- formfiller.extend({
-- pass = function(s) return io.popen("pass " .. s):read() end
-- })
local formfiller = require "formfiller"
formfiller.extend({
pass = function(s) return io.popen("pass " .. s):read() end
})
-- Add proxy support & manager
-- local proxy = require "proxy"
local proxy = require "proxy"
-- Add quickmarks support & manager
-- local quickmarks = require "quickmarks"
local quickmarks = require "quickmarks"
-- Add session saving/loading support
-- local session = require "session"
@@ -100,20 +100,20 @@ settings.window.search_engines.default = settings.window.search_engines.ddg
local gopher = require "gopher"
-- Delete website data
-- local clear_data = require "clear_data"
local clear_data = require "clear_data"
-- Add command to list closed tabs & bind to open closed tabs
local undoclose = require "undoclose"
-- Add command to list tab history items
-- local tabhistory = require "tabhistory"
local tabhistory = require "tabhistory"
-- Add greasemonkey-like javascript userscript support
--- local userscripts = require "userscripts"
local userscripts = require "userscripts"
-- Add bookmarks support
-- local bookmarks = require "bookmarks"
-- local bookmarks_chrome = require "bookmarks_chrome"
local bookmarks = require "bookmarks"
local bookmarks_chrome = require "bookmarks_chrome"
-- Add download support
local downloads = require "downloads"
@@ -121,7 +121,7 @@ local downloads_chrome = require "downloads_chrome"
downloads.default_dir = os.getenv("HOME") .. "/Downloads"
-- Add automatic PDF downloading and opening
local viewpdf = require "viewpdf"
-- local viewpdf = require "viewpdf"
-- Add vimperator-like link hinting & following
local follow = require "follow"
@@ -133,7 +133,7 @@ local cmdhist = require "cmdhist"
local search = require "search"
-- Add ordering of new tabs
-- local taborder = require "taborder"
local taborder = require "taborder"
-- Save web history
local history = require "history"
@@ -149,14 +149,17 @@ local completion = require "completion"
-- Press Control-E while in insert mode to edit the contents of the currently
-- focused <textarea> or <input> element, using `xdg-open`
-- local open_editor = require "open_editor"
-- local editor = require "editor"
-- editor.editor_cmd = "hterm vim {file}"
local editor = require "editor"
editor.editor_cmd = "sterm vim {file}"
-- NoScript plugin, toggle scripts and or plugins on a per-domain basis.
-- `,ts` to toggle scripts, `,tp` to toggle plugins, `,tr` to reset.
-- If you use this module, don't use any site-specific `enable_scripts` or
-- `enable_plugins` settings, as these will conflict.
-- require "noscript"
local noscript = require "noscript"
noscript.enable_scripts = false
noscript.enable_plugins = false
local follow_selected = require "follow_selected"
local go_input = require "go_input"
@@ -164,7 +167,7 @@ local go_next_prev = require "go_next_prev"
local go_up = require "go_up"
-- Filter Referer HTTP header if page domain does not match Referer domain
-- require_web_module("referer_control_wm")
require_web_module("referer_control_wm")
local error_page = require "error_page"
@@ -187,9 +190,9 @@ follow.stylesheet = follow.stylesheet .. [===[
-- local vertical_tabs = require "vertical_tabs"
-- Add a stylesheet when showing images
-- local image_css = require "image_css"
local image_css = require "image_css"
-- Add a new tab page
-- -- Add a new tab page
local newtab_chrome = require "newtab_chrome"
newtab_chrome.new_tab_src = [==[
<html>
@@ -207,7 +210,7 @@ local tab_favicons = require "tab_favicons"
-- tablist.min_width = 100
-- Add :view-source command
-- local view_source = require "view_source"
local view_source = require "view_source"
-- Use "asdfqwerzxcv" for generating labels
local select = require "select"
@@ -217,75 +220,75 @@ end
follow.pattern_maker = follow.pattern_styles.match_label
-- -- social media enhancer
-- local webview = require "webview"
-- webview.add_signal('init', function (view)
-- view:add_signal('navigation-request', function(v, uri)
-- if v.uri:match('https://www.reddit.com') then
-- v.uri = v.uri:gsub('%www.reddit.com', 'old.reddit.com')
-- return true
-- end
-- if v.uri:match('https://new.reddit.com') then
-- v.uri = v.uri:gsub('%new.reddit.com', 'old.reddit.com')
-- return true
-- end
-- -- if v.uri:match('https://old.reddit.com') then
-- -- v.uri = v.uri:gsub('%old.reddit.com', 'libreddit.kylrth.com')
-- -- return true
-- -- end
-- -- if v.uri:match('https://old.reddit.com') then
-- -- v.uri = v.uri:gsub('%old.reddit.com', 'libreddit.kylrth.com')
-- -- return true
-- -- end
-- if v.uri:match('https://www.twitter.com') then
-- v.uri = v.uri:gsub('%www.twitter.com', 'nitter.net')
-- return true
-- end
-- if v.uri:match('https://twitter.com') then
-- v.uri = v.uri:gsub('%twitter.com', 'nitter.net')
-- return true
-- end
-- if v.uri:match('https://www.youtube.com') then
-- v.uri = v.uri:gsub('%www.youtube.com', 'tube.cadence.moe')
-- return true
-- end
-- if v.uri:match('https://youtube.com') then
-- v.uri = v.uri:gsub('%youtube.com', 'tube.cadence.moe')
-- return true
-- end
-- if v.uri:match('https://youtu.be') then
-- v.uri = v.uri:gsub('%youtu.be/', 'tube.cadence.moe/watch?v=')
-- return true
-- end
-- end)
-- end)
-- social media enhancer
local webview = require "webview"
webview.add_signal('init', function (view)
view:add_signal('navigation-request', function(v, uri)
if v.uri:match('https://www.reddit.com') then
v.uri = v.uri:gsub('%www.reddit.com', 'old.reddit.com')
return true
end
if v.uri:match('https://new.reddit.com') then
v.uri = v.uri:gsub('%new.reddit.com', 'old.reddit.com')
return true
end
if v.uri:match('https://old.reddit.com') then
v.uri = v.uri:gsub('%old.reddit.com', 'redlib.kylrth.com')
return true
end
if v.uri:match('https://old.reddit.com') then
v.uri = v.uri:gsub('%old.reddit.com', 'redlib.kylrth.com')
return true
end
if v.uri:match('https://www.twitter.com') then
v.uri = v.uri:gsub('%www.twitter.com', 'nitter.net')
return true
end
if v.uri:match('https://twitter.com') then
v.uri = v.uri:gsub('%twitter.com', 'nitter.net')
return true
end
if v.uri:match('https://www.youtube.com') then
v.uri = v.uri:gsub('%www.youtube.com', 'tube.cadence.moe')
return true
end
if v.uri:match('https://youtube.com') then
v.uri = v.uri:gsub('%youtube.com', 'tube.cadence.moe')
return true
end
if v.uri:match('https://youtu.be') then
v.uri = v.uri:gsub('%youtu.be/', 'tube.cadence.moe/watch?v=')
return true
end
end)
end)
-- social media blocker
-- local webview = require "webview"
-- webview.add_signal('init', function (view)
-- view:add_signal('navigation-request', function(v, uri)
-- local blocklist_pattern = {
-- "facebook.com",
-- ".fb.com",
-- ".fbcdn.com",
-- ".fbsbx.com",
-- ".fbcdn.net",
-- ".tfbnw.net",
-- "whatsapp.com",
-- "online-metrix.net",
-- ".fb.me",
-- "facebook-web-clients.appspot.com",
-- "fbcdn-profile-a.akamaihd.net"
-- }
-- for key,value in ipairs(blocklist_pattern)
-- do
-- if v.uri:match(value) then
-- print("Navigation request to " .. v.uri .. " blocked.")
-- return false
-- end
-- end
-- end)
-- end)
local webview = require "webview"
webview.add_signal('init', function (view)
view:add_signal('navigation-request', function(v, uri)
local blocklist_pattern = {
"facebook.com",
".fb.com",
".fbcdn.com",
".fbsbx.com",
".fbcdn.net",
".tfbnw.net",
"whatsapp.com",
"online-metrix.net",
".fb.me",
"facebook-web-clients.appspot.com",
"fbcdn-profile-a.akamaihd.net"
}
for key,value in ipairs(blocklist_pattern)
do
if v.uri:match(value) then
print("Navigation request to " .. v.uri .. " blocked.")
return false
end
end
end)
end)
-----------------------------
-- End user script loading --

View File

@@ -5,7 +5,7 @@
local theme = {}
-- Default settings
theme.font = "16px Terminess"
theme.font = "20px IosevkaTerm"
theme.fg = "#D8D8D8"
theme.bg = "#181818"

View File

@@ -16,6 +16,12 @@ upload_to_paste() {
| xclip -selection clipboard
}
pick_image() {
mkdir -p $HOME/pick
printf '%s\n' "Copy $1 to $HOME/pick/"
cp -v "${1%.*}."* "$HOME/pick/"
}
save_image() {
if [ -z "$SXIVDIR" ]
then
@@ -103,8 +109,8 @@ remove_set() {
while read file
do
case "$1" in
"Left") jpegtran -rotate 270 -outfile "$file" "$file" ;;
"Right") jpegtran -rotate 90 -outfile "$file" "$file" ;;
"Right") jpegtran -rotate 270 -outfile "$file" "$file" ;;
"Left") jpegtran -rotate 90 -outfile "$file" "$file" ;;
"c") copy_to_clipboard "$file" ;;
"d") rm -f "$file" ;;
"e") edit_image "$file" ;;
@@ -114,6 +120,7 @@ do
"s") save_image "$file" ;;
"q") remove_set "$file" ;;
"x") texec "website-add-image-to-gallery \"$file\"" ;;
"y") pick_image "$file" ;;
"k") keep "$file" ;;
esac
done

View File

@@ -21,6 +21,7 @@ color_focus_free = rgb:AF/5F/00
color_unfocus = rgb:44/44/44
color_unfocus_free = rgb:55/35/00
disable_border = 0
disable_padding = 1
maximize_hide_bar = 0
# +--------------------------------------------------
@@ -68,7 +69,7 @@ bar_at_bottom = 0
# ++ A literal +
# +@ Prefix for text markup sequences
bar_format = +S +@bg=2;+L+@bg=0; +W +|R +A
bar_format = +S +@bg=2;+L+@bg=0; i:+M +W +|R +A
# +--------------------------------------------------
# | WORKSPACE LAYOUT
@@ -96,7 +97,7 @@ name = ws[6]:6
name = ws[7]:7
name = ws[8]:8
name = ws[9]:9
name = ws[10]:10
name = ws[10]:0
workspace_limit = 10
stack_mark_horizontal = 'v'
@@ -193,13 +194,13 @@ program[xconsole] = xcons
bind[xconsole] = MOD+Shift+minus
program[screenshot_wind] = sshot
bind[screenshot_wind] = Print
bind[screenshot_wind] = MOD+Super_L
program[xcolor] = xcolorcopy
bind[xcolor] = MOD+Print
# program[xcolor] = xcolorcopy
# bind[xcolor] = MOD+Super_L
program[xmenu] = myxmenu
bind[xmenu] = Super_L
#program[xmenu] = myxmenu
#bind[xmenu] = MOD+Super_L
program[lock] = /usr/bin/false
@@ -216,6 +217,7 @@ bind[bar_toggle_ws] = MOD+Shift+b
# LAYOUT
bind[cycle_layout] = MOD+l
bind[flip_layout] = MOD+Shift+l
bind[center_layout] = MOD+Shift+c
bind[float_toggle] = MOD+space
bind[free_toggle] = MOD+Shift+space

79
.config/zim/style.conf Normal file
View File

@@ -0,0 +1,79 @@
[TextView]
bullet_icon_size=GTK_ICON_SIZE_MENU
indent=30
tabs=None
linespacing=3
wrapped-lines-linespacing=0
<<<<<<< Updated upstream
font=FuraCode Nerd Font Mono weight=450 14
=======
font=.AppleSystemUIFont 17
>>>>>>> Stashed changes
justify=
background=#cccccc
[Tag strong]
weight=PANGO_WEIGHT_BOLD
[Tag emphasis]
style=PANGO_STYLE_ITALIC
[Tag mark]
background=yellow
[Tag strike]
strikethrough=True
foreground=grey
[Tag code]
foreground=#444444
family=monospace
[Tag pre]
foreground=#2e3436
family=monospace
wrap-mode=GTK_WRAP_NONE
indent=20
[Tag link]
[Tag tag]
foreground=#ce5c00
[Tag h1]
foreground=#4e9a06
underline=PANGO_UNDERLINE_SINGLE
weight=PANGO_WEIGHT_BOLD
scale=1.75
[Tag h2]
foreground=#4e9a06
weight=PANGO_WEIGHT_BOLD
scale=1.52
[Tag h3]
foreground=#4e9a06
style=PANGO_STYLE_ITALIC
weight=PANGO_WEIGHT_BOLD
scale=1.32
[Tag h4]
foreground=#4e9a06
weight=PANGO_WEIGHT_BOLD
scale=1.15
[Tag h5]
foreground=#4e9a06
weight=PANGO_WEIGHT_BOLD
[Tag h6]
foreground=#4e9a06
[Tag checked-checkbox]
[Tag xchecked-checkbox]
[Tag migrated-checkbox]
[Tag transmigrated-checkbox]

View File

@@ -1 +1,4 @@
set startup-quietly on
set follow-fork-mode parent
set detach-on-fork off
set schedule-multiple on

View File

@@ -6,7 +6,7 @@ python
# License ----------------------------------------------------------------------
# Copyright (c) 2015-2023 Andrea Cardaci <cyrus.and@gmail.com>
# Copyright (c) 2015-2024 Andrea Cardaci <cyrus.and@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -346,7 +346,7 @@ def fetch_breakpoints(watchpoints=False, pending=False):
parsed_breakpoints[number] = [address_info], is_pending, ''
elif len(fields) >= 5 and fields[1] == 'catchpoint':
# only take before comma, but ignore commas in quotes
what = catch_what_regex.search(' '.join(fields[4:]))[0].strip()
what = catch_what_regex.search(' '.join(fields[4:])).group(0).strip()
parsed_breakpoints[number] = [], False, what
elif len(fields) >= 3 and number in parsed_breakpoints:
# add this address to the list of multiple locations

View File

@@ -18,8 +18,8 @@
name = Stefan Hagen
email = sh+github@codevoid.de
[user]
name = c0dev0id
email = sh+git@codevoid.de
name = Stefan Hagen
email = stefan.hagen@sap.com
[hub]
host = github.wdf.sap.corp
protocol = git
@@ -36,3 +36,18 @@
tool = vimdiff2
[rerere]
enabled = true
[credential "https://github.wdf.sap.corp"]
helper =
helper = !/usr/bin/gh auth git-credential
[difftool]
prompt = false
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[credential]
helper =
helper = /usr/local/share/gcm-core/git-credential-manager
[credential "https://dev.azure.com"]
useHttpPath = true

126
.kshrc
View File

@@ -27,7 +27,7 @@ export LANG LC_MESSAGES LC_NUMERIC LC_TIME
### SOFTWARE PREFERENCES
EDITOR="vim"
VISUAL="vim"
BROWSER="chrome"
BROWSER="firefox"
PAGER="less"
export EDITOR VISUAL BROWSER PAGER
@@ -86,8 +86,8 @@ TOG_COLORS=1
export GOT_AUTHOR TOG_COLORS
# BUPSTASH
BUPSTASH_REPOSITORY=ssh://sdk@storage.bupstash.io
BUPSTASH_KEY_COMMAND="pass Internet/bupstash-key"
BUPSTASH_REPOSITORY=ssh://default@storage.bupstash.io
BUPSTASH_KEY_COMMAND="pass Internet/storage.bupstash.io-key"
export BUPSTASH_REPOSITORY BUPSTASH_KEY_COMMAND
# PASSWORD-STORE
@@ -107,7 +107,7 @@ set bell-style none
# LOAD COMPLETION FILE
########################################################################
[ -f ~/.ksh.complete ] && . ~/.ksh.complete
[ -f ~/.kshrc.autocomplete ] && . ~/.kshrc.autocomplete
########################################################################
# PROMPT
@@ -127,11 +127,26 @@ RED="\[$(tput setaf 196)\]"
GREY="\[$(tput setaf 248)\]"
RESET="\[$(tput op)\]"
gitstatus() {
_path="$PWD"
while [ -n "$_path" ]
do [ -d "$_path/.git" ] \
&& echo "($(git --no-pager branch --no-color --show-current))" \
&& break
_path="${_path%/*}"
done
}
if [ $(id -u) -eq 0 ]
then
PS1="${x}${RED}\${?}|\w\\$ ${RESET}${x}"
PS1="${x}${RED}$(hostname -s) \${?}|\w\\$ ${RESET}${x}"
else
PS1="${x}${GREY}\${?}|\w\\$ ${RESET}${x}"
if command -v git > /dev/null
then
PS1="${x}${GREY}$(hostname -s) \${?}|\w\$(gitstatus)\\$ ${RESET}${x}"
else
PS1="${x}${GREY}$(hostname -s) \${?}|\w\\$ ${RESET}${x}"
fi
fi
########################################################################
@@ -147,19 +162,28 @@ alias luakitrc="vim ~/.config/luakit/rc.lua"
alias spectrwmrc="vim ~/.config/spectrwm/spectrwm.conf"
alias vifmrc="vim ~/.config/vifm/vifmrc"
alias tmuxrc="vim ~/.tmux.conf"
alias annex="git annex"
pastebinvim() {
vim "https://pastebin.com/raw/$(basename "$1")";
}
# task warrior
alias t=task
alias ta="t add"
alias tm="t mod"
alias tc="t completed"
alias tlog="t log +LOG"
#alias t=task
#alias ta="t add"
#alias tm="t mod"
#alias tc="t completed"
#alias tlog="t log +LOG"
alias mc="/usr/local/bin/mc -d"
# social media
alias tuta="tut -u 'sh@bsd.network uugrn@chaos.social'"
# servers
alias x="ssh -t sdk@home.codevoid.de 'tmux -u new-session -d -s main; tmux -u new-session -t main \; set-option destroy-unattached'"
alias x="ssh -t sdk@home.codevoid.de \
'tmux -u new-session -d -s main; \
tmux -u new-session -t main \; \
set-option destroy-unattached'"
alias inssh="ssh -o HostKeyAlgorithms=+ssh-rsa \
-o KexAlgorithms=+diffie-hellman-group1-sha1 \
@@ -168,9 +192,71 @@ alias inssh="ssh -o HostKeyAlgorithms=+ssh-rsa \
myps() { ps -fU $(whoami); }
mytop() { top -u $(whoami); }
alias portroach="portroach-cli -m codevoid"
alias pkg-readmes="cd /usr/local/share/doc/pkg-readmes; ls"
alias notes="cd $HOME/Documents/notes; nnn"
# git
alias mygit-commit="git commit"
alias mygit-rebase="git rebase -i"
alias mygit-stage="git add"
alias mygit-unstage="git restore --staged"
alias mygit-untrack="git rm --cached"
alias mygit-track="git add --intent-to-add"
alias mygit-update="git fetch --all"
alias mygit-diff="git difftool -y ..origin/HEAD"
alias mygit-log="git log --graph"
alias mygit-list-branches="git --no-pager branch --all"
alias mygit-delete-branch="git branch -D"
mygit-upstream-sync() {
if [ -z "$1" ]
then
echo "sync with which upstream branch?"
return
fi
set -xe
git fetch upstream
git checkout $1
git merge upstream/$1
git push origin $1
}
mygit-checkout() {
_local="$(echo "$1" | sed 's,remotes/,,g;s,origin/,,g;')"
git checkout -b $_local $1
}
alias mygit-changed-files="git --no-pager whatchanged origin/HEAD..HEAD | grep -E '^:' | awk '{ print \$6; }'"
mygot-clone() {
if test -z "$1" || test -z "$2"
then echo "mygot clone <url> <dir>"
else
_src="${1%*.git}.git"
_dst="${2%*.git}"
got clone "$_src" "$_dst.git"
got checkout "$_dst.git" "$_dst"
cd "$_dst"
fi
}
# other
alias portroach="portroach-cli -m codevoid"
alias ugrep="\ugrep -nI --exclude=tags --exclude=.tags --exclude='cscope.*'"
alias tarsnap="doas \tarsnap"
alias vpn-on="doas wg-quick up wg0"
alias vpn-off="doas wg-quick down wg0"
alias edit-pf="doas vim /etc/pf.conf && doas pfctl -f /etc/pf.conf"
alias edit-wg="doas vim /etc/hostname.wg0 && doas sh /etc/netstart wg0"
alias log-wg="doas ifconfig wg0 debug; doas tail -f /var/log/messages | grep wg0"
alias log-wg-remote="ssh shell.codevoid.de 'doas ifconfig wg0 debug; doas tail -f /var/log/messages | grep wg0'"
mystuff() {
cd /usr/ports/mystuff
g
}
wip() {
cd /usr/ports/openbsd-wip
g
}
########################################################################
# AMUSED
@@ -291,8 +377,8 @@ obsd-full-system-update() {(
# REMIND
########################################################################
alias rem="remind -@1,1,1 -c+cu4 -wt ~sdk/.reminders.rem"
alias remy="remind -@1,1,1 -c+cu52 -wt ~sdk/.reminders.rem | less"
alias rem="remind -@1,1,1 -c+cu4 -wt -m ~sdk/.reminders.rem"
alias remy="remind -@1,1,1 -c+cu52 -wt -m ~sdk/.reminders.rem | less"
alias rems="remind -n ~sdk/.reminders | sort -n | head -10"
alias remc="remindcal ~sdk/.reminders"
alias rem-personal="rem-edit personal"
@@ -304,11 +390,13 @@ rem-edit() {
scp -q sdk@home.codevoid.de:.reminders/$1.rem ~sdk/.reminders/$1.rem
}
rem-edit-uugrn() {
vim sftp://vorstand@vorstand.uugrn.org/.reminders/uugrn.rem
scp -q vorstand@vorstand.uugrn.org:.reminders/uugrn.rem ~sdk/.reminders/uugrn.rem
scp -q ~sdk/.reminders/uugrn.rem vorstand@vorstand.uugrn.org:private/Kalender/uugrn.rem
# edit remote file
vim sftp://vorstand@vorstand.uugrn.org/private/Kalender/uugrn.rem
# update local file
scp -q sdk@vorstand.uugrn.org:~vorstand/private/Kalender/uugrn.rem ~sdk/.reminders/uugrn.rem
# run update script
ssh sdk@vorstand.uugrn.org sh \
~sdk/.bin/make_calendar.sh \
~vorstand/private/Kalender/scripts/make_calendar.sh \
|| true
}

View File

@@ -1,46 +0,0 @@
@-moz-document domain(old.reddit.com) {
* {
background-color: #181818 !important;
color: #CCC !important;
border-color: #555 !important;
border-width: 0px !important;
}
.premium-banner-outer, .premium-banner {
display: none !important;
}
#header-img.default-header, .side {
display: none !important;
}
.link.promotedlink.promoted, .link.promotedlink.external {
display: none !important;
}
.footer-parent {
display: none !important;
}
.happening-now-wrap {
display: none !important;
}
.stickied {
display: none !important;
}
input, textarea, button {
background-color: #282828 !important;
}
a {
font-style: oblique !important;
}
.expando-button, .thumbnail, .rank, .midcol {
display: none !important;
}
.top-matter, .top-matter > *, .top-matter > * > *, .top-matter > * > * > *, .top-matter > * > * > * > * {
background-color: #222 !important;
}
.linkflairlabel, .linkflairlabel > * {
background-color: #999 !important;
color: #121212 !important;
}
.entry {
border-left: 5px solid darkred !important;
padding-left: 5px !important;
}
}

View File

@@ -33,3 +33,5 @@ color body green default "^\\+"
color body green default "^\\+.*"
color body green default "> \\+.*"
color index red default '~F' # flagged
color index green default '@~f .' # aliased

View File

@@ -27,7 +27,7 @@ text/html; w3m -I %{charset} -T %t -cols "$COLUMNS" -s -no-graph -o display_link
message/*; cat %s; needsterminal;
# documents
application/pdf; ~/.mutt/scripts/call.sh mupdf %s; nametemplate=%s.pdf;
application/pdf; ~/.mutt/scripts/call.sh zathura %s; nametemplate=%s.pdf;
application/vnd.openxmlformats-officedocument.wordprocessingml.document; ~/.mutt/scripts/call.sh libreoffice %s;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; ~/.mutt/scripts/call.sh libreoffice %s;
application/vnd.openxmlformats-officedocument.presentationml.presentation; ~/.mutt/scripts/call.sh libreoffice %s;

View File

@@ -211,18 +211,16 @@ unalternative_order *
alternative_order text/plain text/enriched text/html
auto_view text/html text/enriched text/calendar
# Preview HTML
macro pager,attach \cs "<pipe-message>cat > /tmp/muttpatch.diff<enter><shell-escape>~/.mutt/scripts/portpatch2.sh /tmp/muttpatch.diff<enter>"
# Save Patch
#macro pager \cs "<shell-escape>rm -f /tmp/mutt-patch.diff<enter><copy-message>/tmp/mutt-patch.diff<enter><enter-command>echo 'Saved as /tmp/mutt-patch.diff'<enter><shell-escape>~/.mutt/scripts/portpatch.sh /tmp/mutt-patch.diff<enter>"
# apply inline patch
macro index,pager,attach \cs "| ~/.mutt/scripts/patch.sh patch<enter>"
macro index,pager,attach \ca "| ~/.mutt/scripts/patch.sh git<enter>"
# pipe-message
set pipe_decode_weed = no
set pipe_decode = yes # when piping via pipe-message command, strip headers and decode
set pipe_split = yes # if several msgs are tagged, do the pipe-message command for each
set prompt_after = no # promt if external pager exits
set wait_key = no # wait for a key-press after performing shell/external commands
set wait_key = yes # wait for a key-press after performing shell/external commands
set beep_new = no # beep if new message arrives
set check_new = no # check for new mails, while the mailbox is open
set auto_tag = yes # function will applied to all tagged messages in the index
@@ -321,4 +319,9 @@ set crypt_opportunistic_encrypt_strong_keys = yes # autoselect key with trust fu
set autocrypt = no
set pgp_use_gpg_agent = yes
set alias_file=~/.mutt/aliases
set sort_alias = alias
set reverse_alias = yes
source ~/.mutt/aliases
source ~/.mutt/colors/codevoid

View File

@@ -1,20 +0,0 @@
#!/bin/sh
strip=0
clear
printf '\n---------------------------------------------------------------------\n'
egrep '^Index|^RCS|^diff --git|^file +' "$1" | sed 's,/cvs,/usr,g'
printf '---------------------------------------------------------------------\n\n'
printf "Path for patch [/usr/ports]? "
read _path
[ -z "$_path" ] && _path=/usr/ports
egrep -q '^diff --git a/' "$1" && strip=1
#print "Trying to apply patch"
#qprint -d "$1" "$1.out"
doas patch -Ep"$strip" -d $_path < "$1"
cd $_path && ksh

68
.mutt/scripts/patch.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/bin/ksh -e
# needs converters/qprint
if [ -t 0 ] || [ -z "$1" ]
then
echo "usage: patch.sh [git|patch] < patchfile.diff"
exit 2
fi
echo "Shortcuts:"
echo "ld - luakit-dev"
echo "lt - luakit-test"
echo "ltmp - luakit-tmp"
echo "src - /usr/src"
echo "sys - /usr/src/sys"
echo "ports - /usr/ports"
echo "www - /usr/www"
echo
printf "Path [$PWD]: "
read _reply < /dev/tty
if [ -z "$_reply" ]
then
_path="$PWD"
else
_path="$_reply"
fi
# shortcuts!!!
case "$_path" in
ld) _path="/home/sdk/src/luakit-dev" ;;
lt) _path="/home/sdk/src/luakit-test" ;;
ltmp) _path="/home/sdk/src/luakit-tmp" ;;
src) _path="/usr/src" ;;
sys) _path="/usr/src/sys" ;;
ports) _path="/usr/ports" ;;
esac
if [ ! -d "$_path" ]
then
_path="$(port-jump "$_path")"
fi
print "Using: $_path"
if [ ! -d "$_path" ]
then
echo "Error with path: $_path"
exit 2
fi
cd "$_path"
if [ "$1" == "git" ]
then
cat /dev/stdin | git am
fi
if [ "$1" == "patch" ]
then
printf "Strip [0]: "
read _strip < /dev/tty
_strip=${_strip:=0}
cat /dev/stdin | doas -u sdk patch -E -N -p$_strip -d "$_path"
fi
echo "$_path" | xclip

View File

@@ -1,32 +0,0 @@
#!/bin/ksh -e
# needs converters/qprint
# mutt: macro pager,attach \cs "<pipe-message>cat > /tmp/muttpatch.diff<enter><shell-escape>~/.mutt/scripts/portpatch2.sh /tmp/muttpatch.diff<enter>"
clear
printf '\n---------------------------------------------------------------------\n'
grep -E 'Subject: |^Index|^RCS|^diff --git|^file +|^[-+]{3} ' "${1}"
printf '---------------------------------------------------------------------\n\n'
printf "Apply patch on path? "
read -r _path
_path="$(port-jump $_path | fzf)"
cd $_path
print "Using: $_path"
printf "Fix quoted-printable mangeled patch? [y/N]: "
read -r _qprint
case ${_qprint} in
[y|Y]) _catcmd="qprint -d"; ;;
*) _catcmd="cat"; ;;
esac
printf "Strip? [0]: "
read -r _strip
echo "CMD: ${_catcmd} "${1}" | doas -u sdk patch -E -pp${_strip:=0} -d ${_path}"
${_catcmd} "${1}" | doas -u sdk patch -E -N -p${_strip:=0} -d ${_path}
echo ${_path} > /var/cache/pmark

View File

@@ -53,18 +53,27 @@ Host home.codevoid.de
Hostname home.codevoid.de
User sdk
Host backup-fsn.codevoid.de
User u475462-sub1
Port 23
Host dalek
Hostname dalek.home.codevoid.de
User sdk
Host tweety
Hostname tweety.home.codevoid.de
#Hostname tweety.home.codevoid.de
Hostname 10.20.30.20
User sdk
Host cvs
Hostname cvs.openbsd.org
User sdk
Host rsync.net
Hostname zh4870.rsync.net
User zh4870
Host osmc
Hostname osmc.home.codevoid.de
User osmc

View File

@@ -68,7 +68,7 @@ set-option -g allow-rename off
set -g set-titles off
# Reduce delay for escape key press
set -sg escape-time 1000
set -sg escape-time 50
set -g default-terminal "tmux-256color"

35
.vim/bin/findtagsdir Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/sh
gitdir() {
_path="$PWD"
while [ -n "$_path" ]
do [ -d "$_path/.git" ] \
&& echo "$_path" \
&& break
_path="${_path%/*}"
done
}
cvsdir() {
_path="$PWD"
while [ -n "$_path" ]
do
[ ! -d "$_path/../CVS" ] \
&& echo "$_path" \
&& break
_path="${_path%/*}"
done
}
_gitdir="$(gitdir)"
_cvsdir="$(cvsdir)"
if [ -n "$_gitdir" ]
then
echo "$_gitdir/.git"
elif [ -n "$_cvsdir" ]
then
echo "$_cvsdir/.tags"
else
echo "$PWD/.tags"
fi

View File

@@ -1,4 +0,0 @@
GitHub Copilot is offered under the [GitHub Terms of
Service](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot).
Copyright (C) 2023 GitHub, Inc. - All Rights Reserved.

View File

@@ -1,64 +0,0 @@
# Copilot.vim
GitHub Copilot uses OpenAI Codex to suggest code and entire functions in
real-time right from your editor. Trained on billions of lines of public
code, GitHub Copilot turns natural language prompts including comments and
method names into coding suggestions across dozens of languages.
Copilot.vim is a Vim/Neovim plugin for GitHub Copilot.
To learn more, visit
[https://github.com/features/copilot](https://github.com/features/copilot).
## Subscription
GitHub Copilot requires a subscription. It is free for verified students and
maintainers of popular open source projects on GitHub.
GitHub Copilot is subject to the [GitHub Additional Product
Terms](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features).
## Getting started
1. Install [Neovim][] or the latest patch of [Vim][] (9.0.0185 or newer).
2. Install [Node.js][].
3. Install `github/copilot.vim` using vim-plug, packer.nvim, or any other
plugin manager. Or to install manually, run one of the following
commands:
* Vim, Linux/macOS:
git clone https://github.com/github/copilot.vim.git \
~/.vim/pack/github/start/copilot.vim
* Neovim, Linux/macOS:
git clone https://github.com/github/copilot.vim.git \
~/.config/nvim/pack/github/start/copilot.vim
* Vim, Windows (PowerShell command):
git clone https://github.com/github/copilot.vim.git `
$HOME/vimfiles/pack/github/start/copilot.vim
* Neovim, Windows (PowerShell command):
git clone https://github.com/github/copilot.vim.git `
$HOME/AppData/Local/nvim/pack/github/start/copilot.vim
4. Start Neovim and invoke `:Copilot setup`.
[Node.js]: https://nodejs.org/en/download/
[Neovim]: https://github.com/neovim/neovim/releases/latest
[Vim]: https://github.com/vim/vim
Suggestions are displayed inline and can be accepted by pressing the tab key.
See `:help copilot` for more information.
## Troubleshooting
Wed love to get your help in making GitHub Copilot better! If you have
feedback or encounter any problems, please reach out on our [Feedback
forum](https://github.com/orgs/community/discussions/categories/copilot).

View File

@@ -1,4 +0,0 @@
If you discover a security issue in this repo, please submit it through the
[GitHub Security Bug Bounty](https://hackerone.com/github).
Thanks for helping make GitHub Copilot safe for everyone.

View File

@@ -1,815 +0,0 @@
scriptencoding utf-8
let s:has_nvim_ghost_text = has('nvim-0.6') && exists('*nvim_buf_get_mark')
let s:vim_minimum_version = '9.0.0185'
let s:has_vim_ghost_text = has('patch-' . s:vim_minimum_version) && has('textprop')
let s:has_ghost_text = s:has_nvim_ghost_text || s:has_vim_ghost_text
let s:hlgroup = 'CopilotSuggestion'
let s:annot_hlgroup = 'CopilotAnnotation'
if s:has_vim_ghost_text && empty(prop_type_get(s:hlgroup))
call prop_type_add(s:hlgroup, {'highlight': s:hlgroup})
endif
if s:has_vim_ghost_text && empty(prop_type_get(s:annot_hlgroup))
call prop_type_add(s:annot_hlgroup, {'highlight': s:annot_hlgroup})
endif
function! s:Echo(msg) abort
if has('nvim') && &cmdheight == 0
call v:lua.vim.notify(a:msg, v:null, {'title': 'GitHub Copilot'})
else
echo a:msg
endif
endfunction
function! s:EditorConfiguration() abort
let filetypes = copy(s:filetype_defaults)
if type(get(g:, 'copilot_filetypes')) == v:t_dict
call extend(filetypes, g:copilot_filetypes)
endif
return {
\ 'enableAutoCompletions': empty(get(g:, 'copilot_enabled', 1)) ? v:false : v:true,
\ 'disabledLanguages': map(sort(keys(filter(filetypes, { k, v -> empty(v) }))), { _, v -> {'languageId': v}}),
\ }
endfunction
function! s:StatusNotification(params, ...) abort
let status = get(a:params, 'status', '')
if status ==? 'error'
let s:agent_error = a:params.message
else
unlet! s:agent_error
endif
endfunction
function! copilot#Init(...) abort
call timer_start(0, { _ -> s:Start() })
endfunction
function! s:Running() abort
return exists('s:agent.job') || exists('s:agent.client_id')
endfunction
function! s:Start() abort
if s:Running()
return
endif
let s:agent = copilot#agent#New({'methods': {
\ 'statusNotification': function('s:StatusNotification'),
\ 'PanelSolution': function('copilot#panel#Solution'),
\ 'PanelSolutionsDone': function('copilot#panel#SolutionsDone'),
\ 'copilot/openURL': function('s:OpenURL'),
\ },
\ 'editorConfiguration' : s:EditorConfiguration()})
endfunction
function! s:Stop() abort
if exists('s:agent')
let agent = remove(s:, 'agent')
call agent.Close()
endif
endfunction
function! copilot#Agent() abort
call s:Start()
return s:agent
endfunction
function! copilot#RunningAgent() abort
if s:Running()
return s:agent
else
return v:null
endif
endfunction
function! s:NodeVersionWarning() abort
if exists('s:agent.node_version') && s:agent.node_version =~# '^16\.'
echohl WarningMsg
echo "Warning: Node.js 16 is approaching end of life and support will be dropped in a future release of copilot.vim."
echohl NONE
elseif exists('s:agent.node_version_warning')
echohl WarningMsg
echo 'Warning:' s:agent.node_version_warning
echohl NONE
endif
endfunction
function! copilot#Request(method, params, ...) abort
let agent = copilot#Agent()
return call(agent.Request, [a:method, a:params] + a:000)
endfunction
function! copilot#Call(method, params, ...) abort
let agent = copilot#Agent()
return call(agent.Call, [a:method, a:params] + a:000)
endfunction
function! copilot#Notify(method, params, ...) abort
let agent = copilot#Agent()
return call(agent.Notify, [a:method, a:params] + a:000)
endfunction
function! copilot#NvimNs() abort
return nvim_create_namespace('github-copilot')
endfunction
function! copilot#Clear() abort
if exists('g:_copilot_timer')
call timer_stop(remove(g:, '_copilot_timer'))
endif
if exists('b:_copilot')
call copilot#agent#Cancel(get(b:_copilot, 'first', {}))
call copilot#agent#Cancel(get(b:_copilot, 'cycling', {}))
endif
call s:UpdatePreview()
unlet! b:_copilot
return ''
endfunction
function! s:Reject(bufnr) abort
try
let dict = getbufvar(a:bufnr, '_copilot')
if type(dict) == v:t_dict && !empty(get(dict, 'shown_choices', {}))
call copilot#Request('notifyRejected', {'uuids': keys(dict.shown_choices)})
let dict.shown_choices = {}
endif
catch
call copilot#logger#Exception()
endtry
endfunction
function! copilot#Dismiss() abort
call s:Reject('%')
call copilot#Clear()
call s:UpdatePreview()
return ''
endfunction
let s:filetype_defaults = {
\ 'yaml': 0,
\ 'markdown': 0,
\ 'help': 0,
\ 'gitcommit': 0,
\ 'gitrebase': 0,
\ 'hgcommit': 0,
\ 'svn': 0,
\ 'cvs': 0,
\ '.': 0}
function! s:BufferDisabled() abort
if &buftype =~# '^\%(help\|prompt\|quickfix\|terminal\)$'
return 5
endif
if exists('b:copilot_disabled')
return empty(b:copilot_disabled) ? 0 : 3
endif
if exists('b:copilot_enabled')
return empty(b:copilot_enabled) ? 4 : 0
endif
let short = empty(&l:filetype) ? '.' : split(&l:filetype, '\.', 1)[0]
let config = {}
if type(get(g:, 'copilot_filetypes')) == v:t_dict
let config = g:copilot_filetypes
endif
if has_key(config, &l:filetype)
return empty(config[&l:filetype])
elseif has_key(config, short)
return empty(config[short])
elseif has_key(config, '*')
return empty(config['*'])
else
return get(s:filetype_defaults, short, 1) == 0 ? 2 : 0
endif
endfunction
function! copilot#Enabled() abort
return get(g:, 'copilot_enabled', 1)
\ && empty(s:BufferDisabled())
\ && empty(copilot#Agent().StartupError())
endfunction
function! copilot#Complete(...) abort
if exists('g:_copilot_timer')
call timer_stop(remove(g:, '_copilot_timer'))
endif
let params = copilot#doc#Params()
if !exists('b:_copilot.params') || b:_copilot.params !=# params
let b:_copilot = {'params': params, 'first':
\ copilot#Request('getCompletions', params)}
let g:_copilot_last = b:_copilot
endif
let completion = b:_copilot.first
if !a:0
return completion.Await()
else
call copilot#agent#Result(completion, a:1)
if a:0 > 1
call copilot#agent#Error(completion, a:2)
endif
endif
endfunction
function! s:HideDuringCompletion() abort
return get(g:, 'copilot_hide_during_completion', 1)
endfunction
function! s:SuggestionTextWithAdjustments() abort
try
if mode() !~# '^[iR]' || (s:HideDuringCompletion() && pumvisible()) || !exists('b:_copilot.suggestions')
return ['', 0, 0, '']
endif
let choice = get(b:_copilot.suggestions, b:_copilot.choice, {})
if !has_key(choice, 'range') || choice.range.start.line != line('.') - 1 || type(choice.text) !=# v:t_string
return ['', 0, 0, '']
endif
let line = getline('.')
let offset = col('.') - 1
let choice_text = strpart(line, 0, copilot#doc#UTF16ToByteIdx(line, choice.range.start.character)) . choice.text
let typed = strpart(line, 0, offset)
let end_offset = copilot#doc#UTF16ToByteIdx(line, choice.range.end.character)
if end_offset < 0
let end_offset = len(line)
endif
let delete = strpart(line, offset, end_offset - offset)
let uuid = get(choice, 'uuid', '')
if typed =~# '^\s*$'
let leading = matchstr(choice_text, '^\s\+')
let unindented = strpart(choice_text, len(leading))
if strpart(typed, 0, len(leading)) == leading && unindented !=# delete
return [unindented, len(typed) - len(leading), strchars(delete), uuid]
endif
elseif typed ==# strpart(choice_text, 0, offset)
return [strpart(choice_text, offset), 0, strchars(delete), uuid]
endif
catch
call copilot#logger#Exception()
endtry
return ['', 0, 0, '']
endfunction
function! s:Advance(count, context, ...) abort
if a:context isnot# get(b:, '_copilot', {})
return
endif
let a:context.choice += a:count
if a:context.choice < 0
let a:context.choice += len(a:context.suggestions)
endif
let a:context.choice %= len(a:context.suggestions)
call s:UpdatePreview()
endfunction
function! s:GetSuggestionsCyclingCallback(context, result) abort
let callbacks = remove(a:context, 'cycling_callbacks')
let seen = {}
for suggestion in a:context.suggestions
let seen[suggestion.text] = 1
endfor
for suggestion in get(a:result, 'completions', [])
if !has_key(seen, suggestion.text)
call add(a:context.suggestions, suggestion)
let seen[suggestion.text] = 1
endif
endfor
for Callback in callbacks
call Callback(a:context)
endfor
endfunction
function! s:GetSuggestionsCycling(callback) abort
if exists('b:_copilot.cycling_callbacks')
call add(b:_copilot.cycling_callbacks, a:callback)
elseif exists('b:_copilot.cycling')
call a:callback(b:_copilot)
elseif exists('b:_copilot.suggestions')
let b:_copilot.cycling_callbacks = [a:callback]
let b:_copilot.cycling = copilot#Request('getCompletionsCycling',
\ b:_copilot.first.params,
\ function('s:GetSuggestionsCyclingCallback', [b:_copilot]),
\ function('s:GetSuggestionsCyclingCallback', [b:_copilot]),
\ )
call s:UpdatePreview()
endif
return ''
endfunction
function! copilot#Next() abort
return s:GetSuggestionsCycling(function('s:Advance', [1]))
endfunction
function! copilot#Previous() abort
return s:GetSuggestionsCycling(function('s:Advance', [-1]))
endfunction
function! copilot#GetDisplayedSuggestion() abort
let [text, outdent, delete, uuid] = s:SuggestionTextWithAdjustments()
return {
\ 'uuid': uuid,
\ 'text': text,
\ 'outdentSize': outdent,
\ 'deleteSize': delete}
endfunction
function! s:ClearPreview() abort
if s:has_nvim_ghost_text
call nvim_buf_del_extmark(0, copilot#NvimNs(), 1)
elseif s:has_vim_ghost_text
call prop_remove({'type': s:hlgroup, 'all': v:true})
call prop_remove({'type': s:annot_hlgroup, 'all': v:true})
endif
endfunction
function! s:UpdatePreview() abort
try
let [text, outdent, delete, uuid] = s:SuggestionTextWithAdjustments()
let text = split(text, "\n", 1)
if empty(text[-1])
call remove(text, -1)
endif
if empty(text) || !s:has_ghost_text
return s:ClearPreview()
endif
if exists('b:_copilot.cycling_callbacks')
let annot = '(1/…)'
elseif exists('b:_copilot.cycling')
let annot = '(' . (b:_copilot.choice + 1) . '/' . len(b:_copilot.suggestions) . ')'
else
let annot = ''
endif
call s:ClearPreview()
if s:has_nvim_ghost_text
let data = {'id': 1}
let data.virt_text_win_col = virtcol('.') - 1
let append = strpart(getline('.'), col('.') - 1 + delete)
let data.virt_text = [[text[0] . append . repeat(' ', delete - len(text[0])), s:hlgroup]]
if len(text) > 1
let data.virt_lines = map(text[1:-1], { _, l -> [[l, s:hlgroup]] })
if !empty(annot)
let data.virt_lines[-1] += [[' '], [annot, s:annot_hlgroup]]
endif
elseif len(annot)
let data.virt_text += [[' '], [annot, s:annot_hlgroup]]
endif
let data.hl_mode = 'combine'
call nvim_buf_set_extmark(0, copilot#NvimNs(), line('.')-1, col('.')-1, data)
else
call prop_add(line('.'), col('.'), {'type': s:hlgroup, 'text': text[0]})
for line in text[1:]
call prop_add(line('.'), 0, {'type': s:hlgroup, 'text_align': 'below', 'text': line})
endfor
if !empty(annot)
call prop_add(line('.'), col('$'), {'type': s:annot_hlgroup, 'text': ' ' . annot})
endif
endif
if !has_key(b:_copilot.shown_choices, uuid)
let b:_copilot.shown_choices[uuid] = v:true
call copilot#Request('notifyShown', {'uuid': uuid})
endif
catch
return copilot#logger#Exception()
endtry
endfunction
function! s:HandleTriggerResult(result) abort
if !exists('b:_copilot')
return
endif
let b:_copilot.suggestions = get(a:result, 'completions', [])
let b:_copilot.choice = 0
let b:_copilot.shown_choices = {}
call s:UpdatePreview()
endfunction
function! copilot#Suggest() abort
try
call copilot#Complete(function('s:HandleTriggerResult'), function('s:HandleTriggerResult'))
catch
call copilot#logger#Exception()
endtry
return ''
endfunction
function! s:Trigger(bufnr, timer) abort
let timer = get(g:, '_copilot_timer', -1)
if a:bufnr !=# bufnr('') || a:timer isnot# timer || mode() !=# 'i'
return
endif
unlet! g:_copilot_timer
return copilot#Suggest()
endfunction
function! copilot#IsMapped() abort
return get(g:, 'copilot_assume_mapped') ||
\ hasmapto('copilot#Accept(', 'i')
endfunction
function! copilot#Schedule(...) abort
if !s:has_ghost_text || !copilot#Enabled() || !copilot#IsMapped()
call copilot#Clear()
return
endif
call s:UpdatePreview()
let delay = a:0 ? a:1 : get(g:, 'copilot_idle_delay', 15)
call timer_stop(get(g:, '_copilot_timer', -1))
let g:_copilot_timer = timer_start(delay, function('s:Trigger', [bufnr('')]))
endfunction
function! copilot#OnInsertLeave() abort
return copilot#Clear()
endfunction
function! copilot#OnInsertEnter() abort
return copilot#Schedule()
endfunction
function! copilot#OnCompleteChanged() abort
if s:HideDuringCompletion()
return copilot#Clear()
else
return copilot#Schedule()
endif
endfunction
function! copilot#OnCursorMovedI() abort
return copilot#Schedule()
endfunction
function! copilot#OnBufUnload() abort
call s:Reject(+expand('<abuf>'))
endfunction
function! copilot#OnVimLeavePre() abort
endfunction
function! copilot#TextQueuedForInsertion() abort
try
return remove(s:, 'suggestion_text')
catch
return ''
endtry
endfunction
function! copilot#Accept(...) abort
let s = copilot#GetDisplayedSuggestion()
if !empty(s.text)
unlet! b:_copilot
let text = ''
if a:0 > 1
let text = substitute(matchstr(s.text, "\n*" . '\%(' . a:2 .'\)'), "\n*$", '', '')
endif
if empty(text)
let text = s.text
endif
call copilot#Request('notifyAccepted', {'uuid': s.uuid, 'acceptedLength': copilot#doc#UTF16Width(text)})
call s:ClearPreview()
let s:suggestion_text = text
return repeat("\<Left>\<Del>", s.outdentSize) . repeat("\<Del>", s.deleteSize) .
\ "\<C-R>\<C-O>=copilot#TextQueuedForInsertion()\<CR>" . (a:0 > 1 ? '' : "\<End>")
endif
let default = get(g:, 'copilot_tab_fallback', pumvisible() ? "\<C-N>" : "\t")
if !a:0
return default
elseif type(a:1) == v:t_string
return a:1
elseif type(a:1) == v:t_func
try
return call(a:1, [])
catch
return default
endtry
else
return default
endif
endfunction
function! copilot#AcceptWord(...) abort
return copilot#Accept(a:0 ? a:1 : '', '\%(\k\@!.\)*\k*')
endfunction
function! copilot#AcceptLine(...) abort
return copilot#Accept(a:0 ? a:1 : "\r", "[^\n]\\+")
endfunction
function! s:BrowserCallback(into, code) abort
let a:into.code = a:code
endfunction
function! copilot#Browser() abort
if type(get(g:, 'copilot_browser')) == v:t_list
let cmd = copy(g:copilot_browser)
elseif type(get(g:, 'open_command')) == v:t_list
let cmd = copy(g:open_command)
elseif has('win32')
let cmd = ['rundll32', 'url.dll,FileProtocolHandler']
elseif has('mac')
let cmd = ['open']
elseif executable('wslview')
return ['wslview']
elseif executable('xdg-open')
return ['xdg-open']
else
return []
endif
if executable(get(cmd, 0, ''))
return cmd
else
return []
endif
endfunction
function! s:OpenURL(params) abort
echo a:params.target
let browser = copilot#Browser()
if empty(browser)
return v:false
endif
let status = {}
call copilot#job#Stream(browser + [a:params.target], v:null, v:null, function('s:BrowserCallback', [status]))
let time = reltime()
while empty(status) && reltimefloat(reltime(time)) < 1
sleep 10m
endwhile
return get(status, 'code') ? v:false : v:true
endfunction
let s:commands = {}
function! s:EnabledStatusMessage() abort
let buf_disabled = s:BufferDisabled()
if !s:has_ghost_text
if has('nvim')
return "Neovim 0.6 required to support ghost text"
else
return "Vim " . s:vim_minimum_version . " required to support ghost text"
endif
elseif !copilot#IsMapped()
return '<Tab> map has been disabled or is claimed by another plugin'
elseif !get(g:, 'copilot_enabled', 1)
return 'Disabled globally by :Copilot disable'
elseif buf_disabled is# 5
return 'Disabled for current buffer by buftype=' . &buftype
elseif buf_disabled is# 4
return 'Disabled for current buffer by b:copilot_enabled'
elseif buf_disabled is# 3
return 'Disabled for current buffer by b:copilot_disabled'
elseif buf_disabled is# 2
return 'Disabled for filetype=' . &filetype . ' by internal default'
elseif buf_disabled
return 'Disabled for filetype=' . &filetype . ' by g:copilot_filetypes'
elseif !copilot#Enabled()
return 'BUG: Something is wrong with enabling/disabling'
else
return ''
endif
endfunction
function! s:VerifySetup() abort
let error = copilot#Agent().StartupError()
if !empty(error)
echo 'Copilot: ' . error
return
endif
let status = copilot#Call('checkStatus', {})
if !has_key(status, 'user')
echo 'Copilot: Not authenticated. Invoke :Copilot setup'
return
endif
if status.status ==# 'NoTelemetryConsent'
echo 'Copilot: Telemetry terms not accepted. Invoke :Copilot setup'
return
endif
return 1
endfunction
function! s:commands.status(opts) abort
if !s:VerifySetup()
return
endif
let status = s:EnabledStatusMessage()
if !empty(status)
echo 'Copilot: ' . status
return
endif
let startup_error = copilot#Agent().StartupError()
if !empty(startup_error)
echo 'Copilot: ' . startup_error
return
endif
if exists('s:agent_error')
echo 'Copilot: ' . s:agent_error
return
endif
let status = copilot#Call('checkStatus', {})
if status.status ==# 'NotAuthorized'
echo 'Copilot: Not authorized'
return
endif
echo 'Copilot: Enabled and online'
call s:NodeVersionWarning()
endfunction
function! s:commands.signout(opts) abort
let status = copilot#Call('checkStatus', {'options': {'localChecksOnly': v:true}})
if has_key(status, 'user')
echo 'Copilot: Signed out as GitHub user ' . status.user
else
echo 'Copilot: Not signed in'
endif
call copilot#Call('signOut', {})
endfunction
function! s:commands.setup(opts) abort
let startup_error = copilot#Agent().StartupError()
if !empty(startup_error)
echo 'Copilot: ' . startup_error
return
endif
let browser = copilot#Browser()
let status = copilot#Call('checkStatus', {})
if has_key(status, 'user')
let data = {}
else
let data = copilot#Call('signInInitiate', {})
endif
if has_key(data, 'verificationUri')
let uri = data.verificationUri
if has('clipboard')
let @+ = data.userCode
let @* = data.userCode
endif
call s:Echo("First copy your one-time code: " . data.userCode)
try
if len(&mouse)
let mouse = &mouse
set mouse=
endif
if get(a:opts, 'bang')
call s:Echo("In your browser, visit " . uri)
elseif len(browser)
call s:Echo("Press ENTER to open GitHub in your browser")
let c = getchar()
while c isnot# 13 && c isnot# 10 && c isnot# 0
let c = getchar()
endwhile
let status = {}
call copilot#job#Stream(browser + [uri], v:null, v:null, function('s:BrowserCallback', [status]))
let time = reltime()
while empty(status) && reltimefloat(reltime(time)) < 5
sleep 10m
endwhile
if get(status, 'code', browser[0] !=# 'xdg-open') != 0
call s:Echo("Failed to open browser. Visit " . uri)
else
call s:Echo("Opened " . uri)
endif
else
call s:Echo("Could not find browser. Visit " . uri)
endif
call s:Echo("Waiting (could take up to 5 seconds)")
let request = copilot#Request('signInConfirm', {'userCode': data.userCode}).Wait()
finally
if exists('mouse')
let &mouse = mouse
endif
endtry
if request.status ==# 'error'
return 'echoerr ' . string('Copilot: Authentication failure: ' . request.error.message)
else
let status = request.result
endif
endif
let user = get(status, 'user', '<unknown>')
echo 'Copilot: Authenticated as GitHub user ' . user
endfunction
let s:commands.auth = s:commands.setup
function! s:commands.help(opts) abort
return a:opts.mods . ' help ' . (len(a:opts.arg) ? ':Copilot_' . a:opts.arg : 'copilot')
endfunction
function! s:commands.version(opts) abort
let info = copilot#agent#EditorInfo()
echo 'copilot.vim ' .info.editorPluginInfo.version
echo info.editorInfo.name . ' ' . info.editorInfo.version
if s:Running()
let versions = s:agent.Call('getVersion', {})
echo 'dist/agent.js ' . versions.version
echo 'Node.js ' . get(s:agent, 'node_version', substitute(get(versions, 'runtimeVersion', '?'), '^node/', '', 'g'))
call s:NodeVersionWarning()
else
echo 'dist/agent.js not running'
endif
endfunction
function! s:UpdateEditorConfiguration() abort
try
if s:Running()
call copilot#Notify('notifyChangeConfiguration', {'settings': s:EditorConfiguration()})
endif
catch
call copilot#logger#Exception()
endtry
endfunction
let s:feedback_url = 'https://github.com/orgs/community/discussions/categories/copilot'
function! s:commands.feedback(opts) abort
echo s:feedback_url
let browser = copilot#Browser()
if len(browser)
call copilot#job#Stream(browser + [s:feedback_url], v:null, v:null, v:null)
endif
endfunction
function! s:commands.restart(opts) abort
call s:Stop()
let err = copilot#Agent().StartupError()
if !empty(err)
return 'echoerr ' . string('Copilot: ' . err)
endif
echo 'Copilot: Restarting agent.'
endfunction
function! s:commands.disable(opts) abort
let g:copilot_enabled = 0
call s:UpdateEditorConfiguration()
endfunction
function! s:commands.enable(opts) abort
let g:copilot_enabled = 1
call s:UpdateEditorConfiguration()
endfunction
function! s:commands.panel(opts) abort
if s:VerifySetup()
return copilot#panel#Open(a:opts)
endif
endfunction
function! copilot#CommandComplete(arg, lead, pos) abort
let args = matchstr(strpart(a:lead, 0, a:pos), 'C\%[opilot][! ] *\zs.*')
if args !~# ' '
return sort(filter(map(keys(s:commands), { k, v -> tr(v, '_', '-') }),
\ { k, v -> strpart(v, 0, len(a:arg)) ==# a:arg }))
else
return []
endif
endfunction
function! copilot#Command(line1, line2, range, bang, mods, arg) abort
let cmd = matchstr(a:arg, '^\%(\\.\|\S\)\+')
let arg = matchstr(a:arg, '\s\zs\S.*')
if cmd ==# 'log'
return a:mods . ' split +$ ' . fnameescape(copilot#logger#File())
endif
if !empty(cmd) && !has_key(s:commands, tr(cmd, '-', '_'))
return 'echoerr ' . string('Copilot: unknown command ' . string(cmd))
endif
try
let err = copilot#Agent().StartupError()
if !empty(err)
return 'echo ' . string('Copilot: ' . err)
endif
try
let opts = copilot#Call('checkStatus', {'options': {'localChecksOnly': v:true}})
catch
call copilot#logger#Exception()
let opts = {'status': 'VimException'}
endtry
if empty(cmd)
if opts.status ==# 'VimException'
return a:mods . ' split +$ ' . fnameescape(copilot#logger#File())
elseif opts.status !=# 'OK' && opts.status !=# 'MaybeOK'
let cmd = 'setup'
else
let cmd = 'panel'
endif
endif
call extend(opts, {'line1': a:line1, 'line2': a:line2, 'range': a:range, 'bang': a:bang, 'mods': a:mods, 'arg': arg})
let retval = s:commands[tr(cmd, '-', '_')](opts)
if type(retval) == v:t_string
return retval
else
return ''
endif
catch /^Copilot:/
return 'echoerr ' . string(v:exception)
endtry
endfunction

Some files were not shown because too many files have changed in this diff Show More