diff options
Diffstat (limited to '')
-rwxr-xr-x | home/.local/bin/aes | 7 | ||||
-rwxr-xr-x | home/.local/bin/clock | 17 | ||||
-rwxr-xr-x | home/.local/bin/def | 47 | ||||
-rwxr-xr-x | home/.local/bin/deg | 6 | ||||
-rwxr-xr-x | home/.local/bin/git-password | 7 | ||||
-rwxr-xr-x | home/.local/bin/mdate | 2 | ||||
-rwxr-xr-x | home/.local/bin/mins | 4 | ||||
-rwxr-xr-x | home/.local/bin/nasd | 14 | ||||
-rwxr-xr-x | home/.local/bin/notify-send | 9 | ||||
-rwxr-xr-x | home/.local/bin/np | 7 | ||||
-rwxr-xr-x | home/.local/bin/open | 19 | ||||
-rwxr-xr-x | home/.local/bin/pbcopy | 11 | ||||
-rwxr-xr-x | home/.local/bin/pbpaste | 11 | ||||
-rwxr-xr-x | home/.local/bin/versions | 9 | ||||
-rwxr-xr-x | home/.local/bin/whinclude | 11 |
15 files changed, 181 insertions, 0 deletions
diff --git a/home/.local/bin/aes b/home/.local/bin/aes new file mode 100755 index 00000000..32b52637 --- /dev/null +++ b/home/.local/bin/aes @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +enwiden() { + exec tr ' -~' ' !-~' +} +[ $# -gt 0 ] && echo "$*" | enwiden || enwiden diff --git a/home/.local/bin/clock b/home/.local/bin/clock new file mode 100755 index 00000000..ef8cd6d8 --- /dev/null +++ b/home/.local/bin/clock @@ -0,0 +1,17 @@ +#!/bin/sh +set -eu + +tput civis +sleep=$(( 60 - $(date +'%S' | sed 's/^0//') )) +while :; do + if [ $(apm -a) -eq 1 ]; then + printf '%3s%%' "$(apm -l)" + else + test $(apm -b) -eq 2 && tput setaf 1 bold + printf '%3.3sm' "$(apm -m)" + tput sgr0 + fi + printf ' %s\r' "$(date +'%a %H:%M')" + sleep $sleep + sleep=60 +done diff --git a/home/.local/bin/def b/home/.local/bin/def new file mode 100755 index 00000000..6a1681d3 --- /dev/null +++ b/home/.local/bin/def @@ -0,0 +1,47 @@ +#!/bin/sh +set -eu + +macro=$1 +headers=' +assert.h +complex.h +ctype.h +errno.h +fenv.h +float.h +inttypes.h +iso646.h +limits.h +locale.h +math.h +setjmp.h +signal.h +stdalign.h +stdarg.h +stdatomic.h +stdbool.h +stddef.h +stdint.h +stdio.h +stdlib.h +stdnoreturn.h +string.h +tgmath.h +threads.h +time.h +uchar.h +wchar.h +wctype.h +' + +for header in $headers; do + defined=$( + echo "$macro" \ + | cc -E -x c -include "$header" - \ + 2> /dev/null \ + | tail -n 1 + ) + [ $? -ne 0 -o "$defined" = "$macro" ] && continue + echo "#include <${header}>" + echo "$defined" +done diff --git a/home/.local/bin/deg b/home/.local/bin/deg new file mode 100755 index 00000000..216029ed --- /dev/null +++ b/home/.local/bin/deg @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu +cat <<EOF +${1}°F = $(dc -e "1k $(echo "$1" | sed 's/^-/_/') 32-1.8/p")°C +${1}°C = $(dc -e "1k $(echo "$1" | sed 's/^-/_/') 1.8*32+p")°F +EOF diff --git a/home/.local/bin/git-password b/home/.local/bin/git-password new file mode 100755 index 00000000..41351e38 --- /dev/null +++ b/home/.local/bin/git-password @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +url=$1 +echo "url=${url}" \ + | git credential fill \ + | sed -En 's/^password=(.*)/\1/p' diff --git a/home/.local/bin/mdate b/home/.local/bin/mdate new file mode 100755 index 00000000..daff50dc --- /dev/null +++ b/home/.local/bin/mdate @@ -0,0 +1,2 @@ +#!/bin/sh +exec date +'.Dd %B %e, %Y' diff --git a/home/.local/bin/mins b/home/.local/bin/mins new file mode 100755 index 00000000..9cbd5fa8 --- /dev/null +++ b/home/.local/bin/mins @@ -0,0 +1,4 @@ +#!/bin/sh +exec dc <<EOF +$1 60~rn[h]nn[m]p +EOF diff --git a/home/.local/bin/nasd b/home/.local/bin/nasd new file mode 100755 index 00000000..60241395 --- /dev/null +++ b/home/.local/bin/nasd @@ -0,0 +1,14 @@ +#!/bin/sh +set -eu + +dir=$(mktemp -d) +trap 'rm -r "$dir"' EXIT + +echo 'bits 64' >"${dir}/input" +for ins; do + printf '%s\n' "$ins" >>"${dir}/input" +done +[ $# -eq 0 ] && cat >>"${dir}/input" + +nasm -o "${dir}/output" "${dir}/input" +ndisasm -b 64 "${dir}/output" diff --git a/home/.local/bin/notify-send b/home/.local/bin/notify-send new file mode 100755 index 00000000..5630440d --- /dev/null +++ b/home/.local/bin/notify-send @@ -0,0 +1,9 @@ +#!/usr/bin/osascript + +on run argv + if count of argv is 2 then + display notification (item 2 of argv) with title (item 1 of argv) + else + display notification (item 1 of argv) + end if +end run diff --git a/home/.local/bin/np b/home/.local/bin/np new file mode 100755 index 00000000..b0eb2326 --- /dev/null +++ b/home/.local/bin/np @@ -0,0 +1,7 @@ +#!/usr/bin/osascript + +tell application "Music" + tell current track + get "/me is listening to " & artist & " — " & name + end tell +end tell diff --git a/home/.local/bin/open b/home/.local/bin/open new file mode 100755 index 00000000..9439f07d --- /dev/null +++ b/home/.local/bin/open @@ -0,0 +1,19 @@ +#!/bin/sh +set -eu + +if [ -n "${SSH_CLIENT:-}" ]; then + exec pbd -o "$@" +fi + +case "$1" in + (*.gif|*.jpeg|*.jpg|*.png) + curl -LSs "$1" | imv - + ;; + (https://youtu.be/*|https://www.youtube.com/watch*|https://twitch.tv/*) + ulimit -c 0 # mpv segfaults on exit every time on OpenBSD... + exec mpv "$1" >/dev/null 2>&1 + ;; + (*) + exec firefox -new-tab "$1" >/dev/null 2>&1 + ;; +esac diff --git a/home/.local/bin/pbcopy b/home/.local/bin/pbcopy new file mode 100755 index 00000000..a804f836 --- /dev/null +++ b/home/.local/bin/pbcopy @@ -0,0 +1,11 @@ +#!/bin/sh +set -eu + +if [ -n "${SSH_CLIENT:-}" ]; then + exec pbd -c +elif [ -n "${DISPLAY:-}" ]; then + exec xsel -bi +else + echo "${0}: don't know what to do" >&2 + exit 1 +fi diff --git a/home/.local/bin/pbpaste b/home/.local/bin/pbpaste new file mode 100755 index 00000000..2924f01e --- /dev/null +++ b/home/.local/bin/pbpaste @@ -0,0 +1,11 @@ +#!/bin/sh +set -eu + +if [ -n "${SSH_CLIENT:-}" ]; then + exec pbd -p +elif [ -n "${DISPLAY:-}" ]; then + exec xsel -bo +else + echo "${0}: don't know what to do" >&2 + exit 1 +fi diff --git a/home/.local/bin/versions b/home/.local/bin/versions new file mode 100755 index 00000000..25e5ff72 --- /dev/null +++ b/home/.local/bin/versions @@ -0,0 +1,9 @@ +#!/bin/sh +set -u + +for repo in ~/src/git/*; do + version=$(git -C "${repo}" describe --dirty 2>/dev/null) + if [ $? -eq 0 ]; then + echo "${repo##*/}-${version#v}" + fi +done | sort -nr -t '-' -k 3 | column -t -s '-' diff --git a/home/.local/bin/whinclude b/home/.local/bin/whinclude new file mode 100755 index 00000000..26445cdc --- /dev/null +++ b/home/.local/bin/whinclude @@ -0,0 +1,11 @@ +#!/bin/sh +set -eu + +echo "#include <${1}>" | +cc ${CFLAGS:-} -E -x c - | +sed -En ' + /^# [0-9]+ "[^<]/{ + s/.*"([^"]+)".*/\1/p + q + } +' |