nix-dotfiles/custom/clipedit/default.nix
2023-01-19 20:01:19 +01:00

13 lines
551 B
Nix

{ writeShellScriptBin, lib, xclip, coreutils, terminal-command ? "kitty sh -c"
, editor-command ? "hx" }:
# 64 │ function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; }
# 65 │ function clippaste() { xclip -out -selection clipboard; } clip
writeShellScriptBin "clipedit" ''
PATH=$PATH:"${lib.makeBinPath [ coreutils xclip ]}"
tmp_file=$(mktemp)
xclip -out -selection -clipboard > $tmp_file
${terminal-command} "${editor-command} $tmp_file"
xclip -in -selection clipboard < $tmp_file
rm $tmp_file
''