summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Pervaz Boocha <mboocha@sudomsg.com>2026-06-06 13:31:45 +0530
committerMarc Pervaz Boocha <mboocha@sudomsg.com>2026-06-06 13:31:45 +0530
commitebbcc63d7ece9920cd09d0e556635f873d5123bb (patch)
treeb09fe182c31b593f8f65e088232cf6dd7b80795c
parentUpdated misc (diff)
downloaddotfiles-ebbcc63d7ece9920cd09d0e556635f873d5123bb.tar
dotfiles-ebbcc63d7ece9920cd09d0e556635f873d5123bb.tar.gz
dotfiles-ebbcc63d7ece9920cd09d0e556635f873d5123bb.tar.bz2
dotfiles-ebbcc63d7ece9920cd09d0e556635f873d5123bb.tar.lz
dotfiles-ebbcc63d7ece9920cd09d0e556635f873d5123bb.tar.xz
dotfiles-ebbcc63d7ece9920cd09d0e556635f873d5123bb.tar.zst
dotfiles-ebbcc63d7ece9920cd09d0e556635f873d5123bb.zip
Added OSC 52. http.server is also good enoughHEADmain
-rwxr-xr-x.local/bin/http-static42
-rwxr-xr-x.local/bin/osc-copy3
-rwxr-xr-x.local/bin/osc-paste74
-rw-r--r--.profile2
-rw-r--r--.zfunc/bell3
-rw-r--r--.zfunc/e3
-rw-r--r--.zfunc/p3
-rw-r--r--.zfunc/v4
m---------.zfunc/zsh-completions0
-rw-r--r--.zshrc3
10 files changed, 79 insertions, 58 deletions
diff --git a/.local/bin/http-static b/.local/bin/http-static
deleted file mode 100755
index cd5ed09..0000000
--- a/.local/bin/http-static
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env python3
-
-from argparse import ArgumentParser
-from collections.abc import Sequence
-from pathlib import Path
-from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
-from functools import partial
-
-
-def serve(bind: str, port: int, directory: Path):
- handler = partial(SimpleHTTPRequestHandler, directory=directory)
-
- with ThreadingHTTPServer((bind, port), handler) as httpd:
- print(*httpd.socket.getsockname())
- try:
- httpd.serve_forever()
- except KeyboardInterrupt:
- return
-
-
-def main(argv: Sequence[str] | None = None) -> None:
- parser = ArgumentParser()
- _ = parser.add_argument(
- "-b", "--bind", metavar="ADDRESS", default="", help="bind to this address"
- )
- _ = parser.add_argument(
- "-p", "--port", default=8080, type=int, help="bind to this port"
- )
- _ = parser.add_argument(
- "directory",
- type=Path,
- default=Path.cwd(),
- nargs="?",
- help="serve this directory",
- )
- args = parser.parse_args(argv)
-
- serve(**vars(args))
-
-
-if __name__ == "__main__":
- main()
diff --git a/.local/bin/osc-copy b/.local/bin/osc-copy
new file mode 100755
index 0000000..5ffbb94
--- /dev/null
+++ b/.local/bin/osc-copy
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+printf "\033]52;c;%s\007" "$(base64 | tr -d '\r\n ')" > /dev/tty
diff --git a/.local/bin/osc-paste b/.local/bin/osc-paste
new file mode 100755
index 0000000..1580627
--- /dev/null
+++ b/.local/bin/osc-paste
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+
+import sys
+import tty
+import termios
+import base64
+import os
+
+
+def osc52_paste() -> str | None:
+ fd = os.open("/dev/tty", os.O_RDWR)
+
+ old = termios.tcgetattr(fd)
+ _ = tty.setraw(fd)
+
+ try:
+ _ = os.write(fd, b"\x1b]52;c;?\x1b\\")
+
+ buf = bytearray()
+
+ while True:
+ b = os.read(fd, 1)
+ if not b:
+ continue
+
+ buf += b
+
+ if buf.endswith(b"\x07") or buf.endswith(b"\x1b\\"):
+ break
+
+ if not buf.startswith(b"\x1b]"):
+ return None
+
+ if buf.endswith(b"\x07"):
+ inner = buf[2:-1]
+ elif buf.endswith(b"\x1b\\"):
+ inner = buf[2:-2]
+ else:
+ return None
+
+ parts = inner.split(b";", 2)
+ if len(parts) != 3:
+ return None
+
+ op, _, b64 = parts
+ if bytes(op) != b"52":
+ return None
+
+ try:
+ data = base64.b64decode(b64, validate=False)
+ return data.decode(errors="replace")
+ except Exception:
+ return None
+
+ finally:
+ termios.tcsetattr(fd, termios.TCSADRAIN, old)
+ os.close(fd)
+
+
+def main() -> None | int:
+ try:
+ clipboard_text = osc52_paste()
+ if clipboard_text is not None:
+ _ = sys.stdout.write(clipboard_text)
+ _ = sys.stdout.flush()
+ else:
+ print("Error: Could not read clipboard via OSC 52.", file=sys.stderr)
+ return 1
+ except KeyboardInterrupt:
+ return 1
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/.profile b/.profile
index e64b4ef..fb8138f 100644
--- a/.profile
+++ b/.profile
@@ -5,7 +5,7 @@ prepend_path () {
*:"$1":*)
;;
*)
- PATH="${PATH:+:$PATH}$1"
+ PATH="$1${PATH:+:$PATH}"
esac
}
diff --git a/.zfunc/bell b/.zfunc/bell
deleted file mode 100644
index cc01adc..0000000
--- a/.zfunc/bell
+++ /dev/null
@@ -1,3 +0,0 @@
-#!zsh
-
-echoti bel
diff --git a/.zfunc/e b/.zfunc/e
deleted file mode 100644
index c714d76..0000000
--- a/.zfunc/e
+++ /dev/null
@@ -1,3 +0,0 @@
-#!zsh
-
-"${EDITOR:-ed}" "$@"
diff --git a/.zfunc/p b/.zfunc/p
deleted file mode 100644
index 59115b7..0000000
--- a/.zfunc/p
+++ /dev/null
@@ -1,3 +0,0 @@
-#!zsh
-
-${PAGER:-less} "$@"
diff --git a/.zfunc/v b/.zfunc/v
deleted file mode 100644
index a223795..0000000
--- a/.zfunc/v
+++ /dev/null
@@ -1,4 +0,0 @@
-#!zsh
-
-"${VISUAL:-${EDITOR:-vi}}" "$@"
-
diff --git a/.zfunc/zsh-completions b/.zfunc/zsh-completions
-Subproject e461417f4e20b20f84b9d48a7acd58214572392
+Subproject dd83145816fe2d90b1ab4154ed528050e94ac5e
diff --git a/.zshrc b/.zshrc
index 2db030e..598a1b5 100644
--- a/.zshrc
+++ b/.zshrc
@@ -54,8 +54,6 @@ autoload -Uz run-help
(( ${+aliases[run-help]} )) && unalias run-help
alias help=run-help
-autoload -Uz e v p bell
-
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' formats "(%s)-[%b]%m%u%c"
@@ -95,3 +93,4 @@ if command -v uvx > /dev/null
then
eval "$(uvx --generate-shell-completion zsh)"
fi
+