dotfiles/.kshrc

663 lines
21 KiB
Plaintext
Raw Normal View History

2022-12-04 22:59:34 +01:00
# ksh environment file
########################################################################
# ENVIRONMENT VARIABLES
########################################################################
### SEARCH PATHS
2023-02-16 10:12:03 +01:00
PATH=~/.bin\
2023-04-06 17:48:14 +02:00
:~/.local/bin\
2022-12-04 22:59:34 +01:00
:/bin\
:/sbin\
:/usr/bin\
:/usr/sbin\
:/usr/local/bin\
:/usr/local/sbin\
:/usr/X11R6/bin\
:/usr/games\
2023-02-16 10:12:03 +01:00
:/usr/ports/infrastructure/bin
2022-12-17 10:27:50 +01:00
JAVA_HOME=/usr/local/jdk-11/bin
PATH=${PATH}:${JAVA_HOME}
PATH=${PATH}:/opt/zodiac/bin
2022-12-27 19:16:20 +01:00
PATH=${PATH}:/opt/stagit/bin
2022-12-04 22:59:34 +01:00
export PATH
#MANPATH=/usr/share/man:/usr/X11R6/man:/usr/local/man
#export MANPATH
2022-12-04 22:59:34 +01:00
### LANGUAGE
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
LC_MESSAGES=C
LC_NUMERIC=C
LC_TIME=en_US.UTF-8
export LANG LC_ALL LC_MESSAGES LC_NUMERIC LC_TIME
########################################################################
# STOP HERE IF NON INTERACTIVE
########################################################################
[[ $- != *i* ]] && return
########################################################################
# INTERACTIVE ENVIRONMENT
########################################################################
case $(hostname -s) in
x13) PKGOPT="-Dsnap"; ;;
openbsd) PKGOPT="-Dsnap"; ;;
2022-12-04 22:59:34 +01:00
esac
### HISTORY
HISTCONTROL=ignoredups:ignorespace:erasedups
HISTFILE=$HOME/.ksh-history
HISTSIZE=2000
export HISTCONTROL HISTFILE HISTSIZE
### SOFTWARE PREFERENCES
2023-04-02 20:25:21 +02:00
EDITOR="vim"
VISUAL="vim"
BROWSER="qutebrowser"
2022-12-04 22:59:34 +01:00
PAGER="less"
2023-01-10 22:18:46 +01:00
export EDITOR VISUAL BROWSER PAGER
### TUIR (reddit)
TUIR_BROWSER="$BROWSER"
export TUIR_BROWSER
2022-12-04 22:59:34 +01:00
### NNN
2022-12-19 09:51:31 +01:00
NNN_OPTS="cErxAJBR"
2022-12-04 22:59:34 +01:00
NNN_OPENER="nnn.sh"
2022-12-08 14:26:14 +01:00
NNN_FIFO=/tmp/nnn.fifo
2022-12-27 19:16:20 +01:00
NNN_PLUG='o:-!mpv "$nnn";x:!imagesort;p:!pdfarranger "$nnn" > /dev/null 2>&1 &'
2022-12-04 22:59:34 +01:00
NNN_ARCHIVE="\\.(7z|bz2|gz|tar|tgz|zip)$"
NNN_COLORS='#0a1b2c3d;1234'
NNN_FCOLORS='c1e2272e006033f7c6d6abc4'
2023-01-10 22:18:46 +01:00
export NNN_OPTS NNN_OPENER NNN_PLUG NNN_ARCHIVE
2022-12-08 14:26:14 +01:00
export NNN_COLORS NNN_FCOLORS NNN_FIFO
2022-12-04 22:59:34 +01:00
# LESS
2023-01-10 22:18:46 +01:00
LESS="-giJmR--tilde"
2022-12-04 22:59:34 +01:00
LESSHISTFILE="$HOME/.less-history"
export LESS LESSHISTFILE
### SLNR
SLRNPULL_ROOT=$HOME/.slrnpull
NNTPSERVER=read.news.tnib.de
export SLRNPULL_ROOT NNTPSERVER
### GOT
GOT_AUTHOR="Stefan Hagen <sh+got@codevoid.de>"
TOG_COLORS=1
2023-01-10 22:18:46 +01:00
export GOT_AUTHOR TOG_COLORS
2022-12-04 22:59:34 +01:00
### BUPSTASH
BUPSTASH_REPOSITORY=ssh://sdk@storage.bupstash.io
2023-02-01 21:22:30 +01:00
BUPSTASH_KEY_COMMAND="pass Internet/bupstash-key"
export BUPSTASH_REPOSITORY BUPSTASH_KEY_COMMAND
2022-12-04 22:59:34 +01:00
### PASSWORD-STORE
PASSWORD_STORE_ENABLE_EXTENSIONS=true
export PASSWORD_STORE_ENABLE_EXTENSIONS
# PORTS
MAKE_JOBS=$(sysctl -n hw.ncpuonline)
FETCH_PACKAGES=No
export MAKE_JOBS FETCH_PACKAGES
2022-12-04 22:59:34 +01:00
########################################################################
# PROMPT (SIMPLE)
########################################################################
2023-01-10 22:18:46 +01:00
PS1="\h|\${?}\w\\$ "
2022-12-04 22:59:34 +01:00
########################################################################
# SHELL SETTINGS
########################################################################
ulimit -c 0
stty -ixon -ixoff
set -o emacs
set bell-style none
########################################################################
# ALIASES
########################################################################
# configuration files
alias kshrc="vim ~/.kshrc"
alias muttrc="vim ~/.mutt/rc-common"
alias vimrc="vim ~/.vim/vimrc"
2023-03-28 18:19:41 +02:00
alias exrc="vim ~/.exrc"
alias web-update='ssh home.codevoid.de "cd web && make update && make"'
alias web-new='ssh home.codevoid.de "cd web && make new"'
alias web-edit='ssh home.codevoid.de "cd web && make edit"'
2023-02-22 08:18:57 +01:00
2023-04-09 09:28:48 +02:00
alias ebay="chrome https://www.ebay-kleinanzeigen.de/m-nachrichten.html &"
alias sbl="chrome https://scottsbasslessons.com &"
alias remake="make clean=all && make"
alias refake="rm -f pkg/*.orig; make clean=fake && make fake"
alias reinstall="remake && make reinstall"
2023-04-09 09:28:48 +02:00
2023-01-10 22:18:46 +01:00
# remind
2023-02-22 08:18:57 +01:00
alias rem="clear; remind -c+cu4 -wt ~/.reminders"
alias remy="clear; remind -cu12 -wt ~/.reminders | less -r"
2023-02-17 08:54:10 +01:00
rems() {
echo "Reminders for $(date +%Y/%m/%d) (today)"
remind ~/.reminders
echo
echo "Next 10 Reminders:"
remind -n .reminders | sort -n | head -10
2023-01-07 15:07:46 +01:00
2023-02-01 21:22:30 +01:00
}
2023-02-17 08:54:10 +01:00
rem-sync() {(
set -xe
scp -q vorstand@vorstand.uugrn.org:private/Kalender/uugrn.rem sdk@home.codevoid.de:.reminders/uugrn.rem
scp -q sdk@home.codevoid.de:.reminders/\*.rem /home/sdk/.reminders/
)}
rem-uugrn() {(
set -xe
vim sftp://vorstand@vorstand.uugrn.org/private/Kalender/uugrn.rem
2023-03-13 08:14:22 +01:00
ssh -q sdk@vorstand.uugrn.org sh ~sdk/.bin/make_calendar.sh
2023-02-17 08:54:10 +01:00
rem-sync
)}
rem-personal() {(
set -xe
vim sftp://sdk@home.codevoid.de/.reminders/personal.rem
rem-sync
)}
rem-birthdays() {(
set -xe
vim sftp://home.codevoid.de/.reminders/birthdays.rem
rem-sync
)}
2023-01-10 22:18:46 +01:00
# mastodon
2023-01-21 16:52:02 +01:00
alias toot-sh="toot-wrapper sh@bsd.network"
alias toot-uug="toot-wrapper uugrn@chaos.social"
2023-02-16 10:12:03 +01:00
tuta() {
tut -u "sh@bsd.network uugrn@chaos.social"
}
2023-01-13 13:46:11 +01:00
2022-12-04 22:59:34 +01:00
# system
alias sudo="doas"
alias su="doas su"
# translation
alias trans-en="trans -l de -s en -t de --no-ansi"
alias trans-de="trans -l en -s de -t en --no-ansi"
# packages
alias pkg_add="doas \pkg_add ${PKGOPT}"
alias pkg_delete="doas \pkg_delete ${PKGOPT}"
alias pkg_info="\pkg_info ${PKGOPT}"
2023-01-10 22:18:46 +01:00
pkg_reset() { pkg_delete -cIX $(</home/sdk/.pkglist); }
2022-12-04 22:59:34 +01:00
2023-01-10 22:18:46 +01:00
# servers
x() { printf '\033]0;$ ssh home.codevoid.de\007' \
&& ssh -t home.codevoid.de 'tmux -u attach || tmux -u'; }
t() { printf '\033]0;$ ssh tweety.home.codevoid.de\007' \
&& ssh -t -J home.codevoid.de \
tweety.home.codevoid.de 'tmux -u attach || tmux -u'; }
o() { printf '\033]0;$ ssh cvs.openbsd.org\007' \
&& ssh -t -J home.codevoid.de \
cvs.openbsd.org 'tmux -u attach || tmux -u'; }
2022-12-04 22:59:34 +01:00
2023-01-10 22:18:46 +01:00
scr() { [ -z "$1" ] && doas wsconsctl -n display.brightness \
|| doas wsconsctl display.brightness="$1"; }
2022-12-04 22:59:34 +01:00
# mount
alias mount_msdos="doas \mount_msdos -o nodev,nosuid,noatime -u 1000 -g 1000"
mount_tank() { awk '$3=="nfs"{print $2}' /etc/fstab | xargs -n1 doas mount; }
umount_tank() { awk '$3=="nfs"{print $2}' /etc/fstab | xargs -n1 doas umount; }
# gopher bookmarks
alias fefe="sacc gopher://codevoid.de/1/fefe"
alias hn="sacc gopher://codevoid.de/1/hn"
alias cv="sacc gopher://codevoid.de"
# pim
2023-01-11 08:25:32 +01:00
alias notes="vim ~/Documents/notes/notes.txt"
alias events="vim ~/Documents/events.txt"
2023-01-10 22:18:46 +01:00
alias caly="ncal -Cy"
alias calm="ncal -3C"
2022-12-04 22:59:34 +01:00
# music
alias music_psychedelik="mpg123 -b 1024 http://62.210.114.63:8000"
alias music_progressive="mpg123 -b 1024 http://62.210.114.63:8010"
alias music_drum-n-bass="mpg123 -b 1024 http://62.210.114.63:8030"
alias music_ambient="mpg123 http://62.210.114.63:8002/listen.mp3"
alias music_tilderadio="ogg123 https://tilderadio.org/listen"
alias music_bitreich="mpv gopher://bitreich.org/9/radio/listen"
alias flac_encode="flac -e --best --delete-input-file"
# security
alias htpasswd-openssl="openssl passwd -apr1"
2023-01-10 22:18:46 +01:00
alias inssh="ssh -o HostKeyAlgorithms=+ssh-rsa \
-o KexAlgorithms=+diffie-hellman-group1-sha1 \
-o Ciphers=+aes256-cbc"
alias my-ssh-pubkey="pass Keystore/ssh-private | head -n1"
alias my-ssh-seckey="pass Keystore/ssh-private | tail -n7"
alias my-gpg-pubkey="gpg --export-options export-minimal --export -a 52BE43BA"
alias my-gpg-seckey="gpg --export-options export-minimal --export-secret-keys -a 52BE43BA"
2023-01-11 09:38:57 +01:00
pw() { pwgen -1 -y --remove-chars=\~\`\"\'{}\(\)\[\]\*.\;\|,\<\> 22; }
2022-12-04 22:59:34 +01:00
# backup
alias tarsnap="doas \tarsnap"
# archives
alias innoextract="\innoextract -g"
2022-12-04 22:59:34 +01:00
2023-03-06 08:14:38 +01:00
alias wget-mirror="wget --mirror --page-requisites --html-extension --convert-links"
2022-12-04 22:59:34 +01:00
# games
alias quake="\vkquake +game id1"
alias quake-mp1-scourge_of_armagon="\vkquake +game hipnotic"
alias quake-mp2-dissolution_of_eternity="\vkquake +game rogue"
alias quake2="\quake2 +game baseq2"
alias quake2-mp1-the_reconning="\quake2 +game xatrix"
alias quake2-mp2-ground_zero="\quake2 +game rogue"
alias quake2-ex1-jaggernaut="\quake2 +game jaggernaut"
alias quake2-ex2-zaero="\quake2 +game zaero"
alias doom3="dhewm3 +set r_fullscreen 1 +set com_fixedtic -1"
alias steam-list="steamctl --user sdk82 apps list"
alias steam-download="steamctl --user sdk82 depot download -os linux64 -a"
# terminal internet stuff
alias terminal_map="telnet mapscii.me"
alias terminal_bofh="telnet towel.blinkenlights.nl 666"
alias terminal_starwars="telnet towel.blinkenlights.nl 23"
alias terminal_cnn="links http://lite.cnn.io/en"
alias terminal_8ball="lynx -width=300 --dump https://codevoid.de/8Ball"
alias terminal_weather="curl wttr.in/Hockenheim"
alias terminal_bbs="telnet gopher.su 1234"
alias terminal_unix50="ssh unix50@unix50.org"
# bookmarks
2023-01-07 15:07:46 +01:00
alias uug-mastodon="firefox https://chaos.social/@uugrn"
2022-12-04 22:59:34 +01:00
alias uug-twitter="firefox https://twitter.com/@uugrn"
alias discord-me="firefox https://discord.com/channels/@me"
alias discord-immortals="firefox https://discord.com/channels/991041843871502366/1000826654974812160"
alias cups-config="firefox http://localhost:631"
alias bbs='ssh -t sdk@home.codevoid.de "LANG=de_DE.UTF-8 syncterm -iC localhost:2323"'
2022-12-04 22:59:34 +01:00
# monitoring
lr() {
2022-12-13 23:16:23 +01:00
[ -z "$1" ] && return 2
[ -z "$2" ] \
&& ssh -t "$1" -- doas tail -n 4000 -f /var/log/{messages,daemon,secure,maillog} \
|| ssh -t "$1" -- doas tail -n 4000 -f /var/log/{messages,daemon,secure,maillog} \
| fgrep -i "$2"
2022-12-04 22:59:34 +01:00
}
l() {
2022-12-13 23:16:23 +01:00
[ -z "$1" ] \
&& doas tail -n 4000 -f /var/log/{messages,daemon,secure,maillog} \
|| doas tail -n 4000 -f /var/log/{messages,daemon,secure,maillog} \
| fgrep -i "$1"
2022-12-04 22:59:34 +01:00
}
2023-01-15 09:30:39 +01:00
# cam
2023-04-10 13:00:38 +02:00
alias camformats="ffplay -f v4l2 -list_formats all -i /dev/video"
2023-03-28 18:19:41 +02:00
alias cam="ffplay -loglevel quiet -f v4l2 -input_format mjpeg -video_size 640x480 -i /dev/video"
setcam() {
_dev=$1
echo ln -sf /dev/video${_dev:=0} /dev/video
doas ln -sf /dev/video${_dev:=0} /dev/video
}
2022-12-04 22:59:34 +01:00
########################################################################
# EMAIL HANDLING
########################################################################
# mailboxes
MUTT_HOST="imaps://mail.codevoid.de"
# account aliases
alias mutt-acc-gmx="\mutt -F $HOME/.mutt/rc-account-gmx"
alias mutt-acc-priv="\mutt -F $HOME/.mutt/rc-account-private"
alias mutt-acc-work="\mutt -F $HOME/.mutt/rc-account-work"
alias mutt-acc-offl="\mutt -F $HOME/.mutt/rc-account-offline"
alias mutt-acc-mborg="\mutt -F $HOME/.mutt/rc-account-mborg"
alias mutt-acc-uugrn="\mutt -F $HOME/.mutt/rc-account-uugrn"
# default
alias mutt="mutt-acc-priv"
alias muttopen="\mutt -F ~/.mutt/rc-common -f"
# select mailbox
mutt-textmail() { mutt-acc-priv -f $MUTT_HOST/Mailboxes/textmail.me/$1; }
mutt-codevoid() { mutt-acc-priv -f $MUTT_HOST/Mailboxes/codevoid.de/sh+$1; }
# shortcuts
alias mutt-all="mutt -f $MUTT_HOST/Virtual/ALL"
alias mutt-amazon="mutt-textmail amazon"
alias mutt-ccc-intern="mutt-textmail ccc-intern"
alias mutt-last-day="mutt -f $MUTT_HOST/Virtual/LAST_DAY"
alias mutt-last-week="mutt -f $MUTT_HOST/Virtual/LAST_WEEK"
alias mutt-last-month="mutt -f $MUTT_HOST/Virtual/LAST_MONTH"
alias mutt-last-year="mutt -f $MUTT_HOST/Virtual/LAST_YEAR"
alias mutt-lieferando="mutt-textmail lieferando"
alias mutt-mutt-users="mutt-codevoid mutt-users"
alias mutt-openbsd-all="mutt -f $MUTT_HOST/Virtual/OpenBSD"
alias mutt-openbsd-bugs="mutt-codevoid openbsd-bugs"
alias mutt-got="mutt-codevoid got"
alias mutt-openbsd-hackers="mutt-codevoid openbsd-hackers"
alias mutt-openbsd-misc="mutt-codevoid openbsd-misc"
alias mutt-openbsd-ports-bugs="mutt-codevoid openbsd-ports-bugs"
alias mutt-openbsd-ports-cvs="mutt-codevoid openbsd-ports-cvs"
alias mutt-openbsd-ports="mutt-codevoid openbsd-ports"
alias mutt-openbsd-x11="mutt-codevoid openbsd-x11"
alias mutt-openbsd-sparc="mutt-codevoid openbsd-sparc"
alias mutt-openbsd-src-cvs="mutt-codevoid openbsd-src-cvs"
alias mutt-openbsd-tech="mutt-codevoid openbsd-tech"
alias mutt-paypal="mutt-textmail paypal"
alias mutt-uugrn="mutt-codevoid uugrn"
alias mutt-vorstand="mutt-codevoid vorstand"
alias otech="mutt -f $MUTT_HOST/Virtual/OpenBSD-tech"
alias oports="mutt -f $MUTT_HOST/Virtual/OpenBSD-ports"
alias omisc="mutt -f $MUTT_HOST/Virtual/OpenBSD-misc"
########################################################################
# OPENBSD PORT TOOLS
########################################################################
2023-01-10 22:18:46 +01:00
# CVS
2023-03-28 18:19:41 +02:00
export CVSROOT=sdk@cvs.openbsd.org:/cvs
2023-02-16 10:12:03 +01:00
alias cvs-diff="doas -u sdk cvs -d $CVSROOT diff -uNp"
alias cvs-commit="doas -u sdk cvs -d $CVSROOT commit"
alias cvs-update="doas -u sdk cvs -z3 -d $CVSROOT -q up -Pd -A"
cvs-update-all() {(
set -x
cd /usr/src && cvs-update
cd /usr/xenocara && cvs-update
cd /usr/ports && cvs-update
cd /usr/www && cvs-update
)}
2023-03-28 18:19:41 +02:00
alias cvs-release="doas -u sdk cvs -d $CVSROOT release"
alias cvs-checkout="doas -u sdk cvs -z 1 -qd $CVSROOT checkout -P"
2022-12-13 23:16:23 +01:00
cvs-import-simulate() {
2023-03-28 18:19:41 +02:00
doas -u sdk cvs -d sdk@cvs.openbsd.org:/cvs \
2023-01-10 22:18:46 +01:00
-n import ports/$(dirname $PWD)/$(basename $PWD) sdk sdk_$(date +"%Y%m%d")
2023-01-08 17:34:37 +01:00
}
2023-02-16 10:12:03 +01:00
cvs-sync-sunny() {
rsync -arv --delete /usr/ports/ root@sunny:/usr/ports/
rsync -arv --delete /usr/src/ root@sunny:/usr/src/
rsync -arv --delete /usr/xenocara/ root@sunny:/usr/xenocara/
}
2023-01-08 17:34:37 +01:00
full-update() {(
set -x
pkg_add -u
cvs-update-all
doas sysupgrade -sn
)}
set_autoconf() {
set -x
export AUTOMAKE_VERSION=1.16
export AUTOCONF_VERSION=2.69
set +x
}
2023-01-10 22:18:46 +01:00
# PORTS
portclean() {(
set -x
2023-01-10 22:18:46 +01:00
cd /usr/ports
2023-02-17 08:54:10 +01:00
doas rm -rf pobj/* plist logs packages bulk update distfiles/*
mkdir -p plist logs packages bulk update
doas make fix-permissions
2023-01-10 22:18:46 +01:00
)}
pmark() { pwd > /var/cache/pmark; }
p() { cd "$(</var/cache/pmark)"; }
2023-01-21 11:09:30 +01:00
pj() { cd "/usr/ports/$(portjump $1)"; }
2022-12-13 23:16:23 +01:00
po() { cd "$(</var/cache/pmark)" && cd "$(make show=WRKSRC)"; }
2022-12-04 22:59:34 +01:00
alias portsweep='doas find . \( -name "*.orig" -or -empty \) -delete'
2022-12-13 23:16:23 +01:00
pdiff() {(
2023-01-10 22:18:46 +01:00
pwd | fgrep -q '/usr/ports/' || return 1
set -A N $(make show="PKGNAME EPOCH REVISION")
PN="${N[0]}${N[1]:+v${N[1]}}${N[2]:+p${N[2]}}"
PD=$(pwd | cut -d"/" -f4,5)
cd /usr/ports
2023-03-28 18:19:41 +02:00
doas -u sdk cvs -d sdk@cvs.openbsd.org:/cvs diff -uNp "${PD}" \
2023-01-10 22:18:46 +01:00
> "/home/sdk/diffs/${PN}.diff"
echo "/home/sdk/diffs/${PN}.diff"
2022-12-13 23:16:23 +01:00
)}
2022-12-04 22:59:34 +01:00
alias port-modgo-update='make MODGO_VERSION=latest modgo-gen-modules > modules.inc'
2023-01-10 22:18:46 +01:00
# DPB
alias proot-rebuild="doas proot -c /etc/proot.conf; doas chroot /home/dpb pkg_add -Dsnap ccache"
2022-12-04 22:59:34 +01:00
alias proot-do="doas chroot /home/dpb/"
alias dmake="doas /usr/ports/infrastructure/bin/dpb -B /home/dpb -c -I "
2023-03-29 07:43:43 +02:00
alias dpb-control="ssh openbsd.codevoid.de \"doas nc -U /usr/ports/logs/amd64/control-openbsd-*\""
dpb-log() {
2023-04-01 21:49:50 +02:00
ssh openbsd.codevoid.de "tail -n 500 /usr/ports/logs/amd64/paths/$1.log"
}
dpb-logf() {
2023-03-29 07:43:43 +02:00
ssh openbsd.codevoid.de "tail -n 500 -f /usr/ports/logs/amd64/paths/$1.log"
}
2022-12-04 22:59:34 +01:00
2023-04-01 21:49:50 +02:00
alias mypkg_add="PKG_PATH=http://openbsd.codevoid.de/pub/OpenBSD/snapshots/packages/amd64 pkg_add -Dsnap -Dunsigned"
alias mypkg_info="PKG_PATH=http://openbsd.codevoid.de/pub/OpenBSD/snapshots/packages/amd64 pkg_info -Dsnap -Dunsigned"
openbsd-gitupdate() {
cd ~/code/OpenBSD/src && git pull
cd ~/code/OpenBSD/ports && git pull
cd ~/code/OpenBSD/xenocara && git pull
cd ~/code/OpenBSD
}
# mygdb <breakpoint> <program> <arguments>
mygdb() {
[ -z $3 ] \
&& echo "mygdb <breakpoint> <program> <arguments>" \
&& return
break="$1"; shift; prog="$1"; shift; args="$@";
egdb -ex "break $break" -ex "run $args" $prog
}
2022-12-13 23:16:23 +01:00
########################################################################
# KERNEL STUFF
########################################################################
2022-12-04 22:59:34 +01:00
2022-12-13 23:16:23 +01:00
alias update-ksh="cd /usr/src/bin/ksh \
&& doas make clean \
&& doas make obj \
&& doas make -j $MAKE_JOBS \
2022-12-13 23:16:23 +01:00
&& doas make install"
2022-12-04 22:59:34 +01:00
########################################################################
# TWITCH FROM CLI
########################################################################
alias twitch-play="mpv https://www.twitch.tv/c0dev0id"
twitch-stream() {
local API_KEY=$(pass Internet/Twitch | head -1)
local RES=$(xrandr | grep "*+" | awk '{print $1}')
local FAUX_OPTS="-d snd/default -m -vmic 5.0 -vmon 0.2 -r $RES -f 20 -b 4000"
2022-12-13 23:16:23 +01:00
fauxstream $FAUX_OPTS rtmp://live-ams.twitch.tv/app/$API_KEY
2022-12-04 22:59:34 +01:00
}
########################################################################
# DOTFILES WITH GIT
########################################################################
2022-12-17 23:03:45 +01:00
alias config='git --git-dir=${HOME}/.cfg/ --work-tree=${HOME}'
2022-12-04 22:59:34 +01:00
dotfiles_autoupdate() {
config add -u && \
config commit -m "Update $(date +"%Y-%m-%d %H:%M") \
2023-04-14 16:46:39 +02:00
$(uname -s)/$(uname -m)-$(hostname -s)" && config push
2022-12-04 22:59:34 +01:00
}
dotfiles_init() {
git --no-replace-objects clone --bare --depth 1 \
2023-01-10 14:18:52 +01:00
_gitea@git.uugrn.org:sdk/dotfiles.git $HOME/.cfg;
2022-12-04 22:59:34 +01:00
config config --local status.showUntrackedFiles no;
config checkout -f
}
########################################################################
# FILE SHARING
########################################################################
2022-12-13 23:16:23 +01:00
doupload-http() {
[ ! -f "$1" ] && return 2
chmod ugo+r "$1"
_name=$(basename "$1");
scp -r "$1" codevoid.de:/tmp
ssh codevoid.de "doas mv /tmp/$_name /home/www/htdocs/http/$_name"
echo "https://codevoid.de/h/$_name";
}
2023-01-10 22:18:46 +01:00
2022-12-13 23:16:23 +01:00
doupload-gopher() {
[ ! -f "$1" ] && return 2
chmod ugo+r "$1"
_name=$(basename "$1");
scp -r "$1" codevoid.de:/tmp
ssh codevoid.de "doas mv /tmp/$_name /home/www/htdocs/gopher/p/$_name"
case "$(file --mime-type -b "$1")" in
image/*) S="I";;
text/*) S="0";;
message/*) S="0";;
*/x-shellscript) S="0";;
*/pgp-keys) S="0";;
application/*) S="9";;
esac
echo "https://codevoid.de/$S/p/$_name";
echo "gopher://codevoid.de/$S/p/$_name";
2022-12-04 22:59:34 +01:00
}
########################################################################
# YOUTUBE-DL
########################################################################
2022-12-13 23:16:23 +01:00
2022-12-04 22:59:34 +01:00
YTDL_AGENT="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4506.0 Safari/537.36"
YTDL_OPTS="-i --no-part --abort-on-unavailable-fragment --buffer-size 16K --fragment-retries 100 --http-chunk-size 10M"
2022-12-04 22:59:34 +01:00
ytdl() {
local FMT="bestvideo[ext=mp4][height<=1080]+bestaudio[ext=m4a]/best[ext=mp4]/best"
yt-dlp $YTDL_OPTS --user-agent "$YTDL_AGENT" -f "$FMT" "$@";
}
ytdl_playlist() {
local FMT="bestvideo[ext=mp4][height<=1080]+bestaudio[ext=m4a]/best[ext=mp4]/best"
yt-dlp $YTDL_OPTS --user-agent "$YTDL_AGENT" -f "$FMT" -o '%(playlist_title)s/%(title)s.%(ext)s' "$@";
}
ytdl_channel() {
local FMT="bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"
yt-dlp $YTDL_OPTS --user-agent "$YTDL_AGENT" --download-archive ytdl_channel.txt -f "$FMT" \
-o '%(upload_date)s - %(title)s.%(ext)s' "$@";
}
ytdl_bandcamp() {
yt-dlp $YTDL_OPTS --user-agent "$YTDL_AGENT" -x --audio-format mp3 -i --embed-thumbnail \
--add-metadata -o '%(artist)s/%(album)s/%(track_number)02d - %(track)s.%(ext)s' "$@";
}
ytdl_audio() {
yt-dlp $YTDL_OPTS --user-agent "$YTDL_AGENT" -f bestaudio --extract-audio --embed-thumbnail \
--add-metadata -o "%(title)s-%(id)s.%(ext)s" "$@";
}
########################################################################
# KSH COMPLETIONS
########################################################################
[ -f $HOME/.ksh-complete ] && . $HOME/.ksh-complete
2022-12-04 22:59:34 +01:00
########################################################################
# SCREEN CONFIGURATION
########################################################################
xr_primary() {
xrandr --listmonitors | awk '/ 0:/{ print $4 }'
}
xr_secondary() {
xrandr | awk '/ connected/ { print $1 }' | fgrep -v $(xr_primary)
}
xr_off() {
xrandr | awk '/disconnected/ { print $1 }'
}
2022-12-13 23:16:23 +01:00
2023-01-24 08:31:39 +01:00
xrandr_list() {
echo "primary: " $(xr_primary)
echo "secondary:" $(xr_secondary)
echo "offline: " $(xr_off)
}
2022-12-04 22:59:34 +01:00
xrandr_set() {
2023-04-01 21:49:50 +02:00
set -x
2022-12-04 22:59:34 +01:00
for scr in $(xr_secondary)
do
2023-04-09 09:28:48 +02:00
xrandr --output $scr --$1 $(xr_primary) --$2 $3
2022-12-04 22:59:34 +01:00
done
for scr in $(xr_off)
do
xrandr --output $scr --off
done
}
2023-01-24 08:31:39 +01:00
xrandr_only_primary() {
pri=$(xr_primary)
sec=$(xr_secondary)
off=$(xr_off)
set -x
xrandr --output $pri --auto
for scr in $sec $off
do
xrandr --output $scr --off
done
}
2022-12-04 22:59:34 +01:00
xrandr_mirror() {
xrandr_set same-as auto
}
xrandr_mirror_hd() {
2023-04-09 09:28:48 +02:00
xrandr_set same-as mode 1920x1080
2022-12-04 22:59:34 +01:00
}
xrandr_extend_above() {
2023-04-09 09:28:48 +02:00
xrandr_set above auto
2022-12-04 22:59:34 +01:00
}
xrandr_extend_right() {
2023-04-09 09:28:48 +02:00
xrandr_set right-of auto
2022-12-04 22:59:34 +01:00
}
xrandr_extend_left() {
2023-04-09 09:28:48 +02:00
xrandr_set left-of auto
2022-12-04 22:59:34 +01:00
}
xrandr_native() {
xrandr --output $(xr_primary) --auto
}
xrandr_720p() {
xrandr --output $(xr_primary) --mode 1280x720
}
xrandr_1080p() {
xrandr --output $(xr_primary) --mode 1920x1080
}
xrandr_4k() {
xrandr --output $(xr_primary) --mode 3840x2160
}
2023-01-10 22:18:46 +01:00
alias xrandr_portrait="xrandr --output DP-1 --rotate left"
2023-04-09 09:28:48 +02:00
alias xrandr_mirror_hdmi="xrandr --output HDMI-A-0 --same-as eDP --mode 1920x1080"
2022-12-13 23:16:23 +01:00
2022-12-04 22:59:34 +01:00
########################################################################
# GNUPG AGENT
########################################################################
2023-01-10 22:18:46 +01:00
if [ -f $HOME/.enable_gpg ]
2022-12-04 22:59:34 +01:00
then
GPG_TTY=$(tty)
SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
SSH_AUTH_SOCK_EXTRA=${SSH_AUTH_SOCK%%.ssh}.extra
export GPG_TTY SSH_AUTH_SOCK SSH_AUTH_SOCK_EXTRA
pgrep -qu sdk gpg-agent || gpg-connect-agent -q /bye
fi