diff --git a/home/.local/bin/select-and-copy b/home/.local/bin/select-and-copy new file mode 100755 index 0000000..0864bbe --- /dev/null +++ b/home/.local/bin/select-and-copy @@ -0,0 +1,5 @@ +#!/bin/sh + +path=$(lf -selection-path=/dev/stdout | tail -n 1) +copyq copy "$(xdg-mime query filetype "$path")" - < "$path" +niri msg action focus-window-previous && sleep .1s && copyq paste diff --git a/home/.local/bin/xrescat b/home/.local/bin/xrescat new file mode 100755 index 0000000..07c9491 --- /dev/null +++ b/home/.local/bin/xrescat @@ -0,0 +1,21 @@ +#!/bin/sh + +awk -v query="$1" ' +/^!/ || length($0) == 0 { next } +{ + delI=index($0, ":") + path=substr($0, 0, delI - 1) + gsub(/[\\.^$(){}\[\]|+]/, "\\\\&", path) + gsub(/*/, ".*?", path) + gsub(/\\\.?\\./, "\\.[^.]*\\.", path) + gsub(/^\?$/, "^[^.]*$", path) + gsub(/^\?\\./, "^[^.]*\\.", path) + gsub(/\\.\?$/, "\\.[^.]*$", path) +} +query ~ path { + res=substr($0, delI + 1) + gsub(/^[\t ]+/, "", res) + printf "%s", res + exit +} +' "$HOME/.Xdefaults" diff --git a/paths b/paths index 773e3fb..eed6c86 100644 --- a/paths +++ b/paths @@ -17,3 +17,5 @@ /home/olive/.basilisk /home/olive/.zshrc /home/olive/.Xdefaults +/home/olive/.local/bin/xrescat +/home/olive/.local/bin/select-and-copy