aboutsummaryrefslogtreecommitdiff
path: root/.local/share/bin
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2026-03-26 20:50:48 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2026-03-26 20:50:48 +0100
commitd842d7f125cf055d24cdb2e4b0d94c3885c93d72 (patch)
tree3fc7e2c7f1642a56546816c348cc4ef9c400a56f /.local/share/bin
parent7d782c4af6a369ec5a802eeededf18e5f355088b (diff)
update dotfiles from work (2/2)HEADmaster
Diffstat (limited to '.local/share/bin')
-rwxr-xr-x.local/share/bin/clean3
-rwxr-xr-x.local/share/bin/lf23
-rwxr-xr-x.local/share/bin/venvgen47
3 files changed, 73 insertions, 0 deletions
diff --git a/.local/share/bin/clean b/.local/share/bin/clean
new file mode 100755
index 0000000..8c824f1
--- /dev/null
+++ b/.local/share/bin/clean
@@ -0,0 +1,3 @@
+#!/bin/sh
+[ -n "$UB_SOCKET" ] && ueberzugpp cmd --socket "$UB_SOCKET" --action remove --identifier PREVIEW
+
diff --git a/.local/share/bin/lf b/.local/share/bin/lf
new file mode 100755
index 0000000..430ae0b
--- /dev/null
+++ b/.local/share/bin/lf
@@ -0,0 +1,23 @@
+#!/bin/sh
+lf=/usr/bin/lf
+
+UB_PID=0
+UB_SOCKET=""
+UB_PID_FILE="$(mktemp)"
+
+cleanup() {
+ exec 3>&-
+ ueberzugpp cmd -s "$UB_SOCKET" -a exit
+}
+
+# don't try to use ueberzug over ssh
+[ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] && exec $lf "$@"
+
+ueberzugpp layer --silent --no-stdin --use-escape-codes --pid-file "$UB_PID_FILE" >/dev/null
+UB_PID="$(cat "$UB_PID_FILE")"
+rm -f "$UB_PID_FILE"
+UB_SOCKET="/tmp/ueberzugpp-$UB_PID.socket"
+export UB_PID UB_SOCKET
+trap cleanup HUP INT QUIT TERM EXIT
+$lf "$@" 3>&-
+
diff --git a/.local/share/bin/venvgen b/.local/share/bin/venvgen
new file mode 100755
index 0000000..25f2c78
--- /dev/null
+++ b/.local/share/bin/venvgen
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# check if the input is valid
+for arg in "$@" ; do
+ case "$arg" in
+ *=*) ;;
+ *)
+ echo "error: missing assignment operator in argument ($arg)" >&2
+ exit 1
+ ;;
+ esac
+done
+
+# shebang
+printf '#!/bin/sh\n'
+
+# save old variables
+for arg in "$@" ; do
+ name="${arg%%=*}"
+ eval "hasval=\${$name+x}"
+ [ -n "$hasval" ] && printf '_%s="${%s}"\n' "$name" "$name"
+done
+
+# set new variables
+for arg in "$@" ; do
+ name="${arg%%=*}"
+ value="${arg#*=}"
+ printf 'export %s=%q\n' "$name" "$value"
+done
+
+# deactivate function
+printf 'deactivate() {\n'
+for arg in "$@" ; do
+ name="${arg%%=*}"
+ eval "hasval=\${$name+x}"
+ if [ -n "$hasval" ] ; then
+ printf '\t%s="${_%s}"\n' "$name" "$name"
+ printf '\tunset -v _%s\n' "$name"
+ else
+ printf '\tunset -v %s\n' "$name"
+ fi
+done
+printf '\thash -r 2>/dev/null\n'
+printf '\tunset -f deactivate\n'
+printf '}\n'
+printf 'hash -r 2>/dev/null\n'
+