diff --git a/.config/codebook/codebook.toml b/.config/codebook/codebook.toml index 8c1dfa3d..792b00a1 100644 --- a/.config/codebook/codebook.toml +++ b/.config/codebook/codebook.toml @@ -1,6 +1,7 @@ words = [ "diceware", "hmac", + "linewise", "pathlib", "ttp", "typst", diff --git a/.config/helix/scripts/paste-util.fish b/.config/helix/scripts/paste-util.fish index bc67f1db..57718f3d 100755 --- a/.config/helix/scripts/paste-util.fish +++ b/.config/helix/scripts/paste-util.fish @@ -9,15 +9,17 @@ set -l cmd $argv[1] # get clip contents, and preserve newlines -set -l contents (wl-paste -n | string collect -N) +set -l contents (wl-paste -n | string collect -N --allow-empty) count "$contents" if test "$cmd" = inline # if there's more than 1 newline, it # has to be linewise set -l lines (string split -n \n "$contents") set -S lines + set -S contents - printf "%s" "$(string join \n "$lines")" + # string join \n $lines + printf "%s" (string join \n $lines | string collect -N) # if test "$newlines" -eq 1 # printf "%s" (string trim --chars \n "$contents") # else diff --git a/.config/helix/scripts/paste.py b/.config/helix/scripts/paste.py new file mode 100755 index 00000000..60d5971e --- /dev/null +++ b/.config/helix/scripts/paste.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +import subprocess +import sys + +# tiny script to force inline vs. linewise paste in Helix + +cmd = sys.argv[1] +contents = subprocess.check_output(["wl-paste", "-n"], text=True) +if cmd == "inline": + print(contents.rstrip("\n"), end="") +elif cmd == "linewise": + if contents[-1] != "\n": + contents += "\n" + print(contents, end="")