diff --git a/.config/helix/config.toml b/.config/helix/config.toml index 0cf6382d..b5e5d305 100644 --- a/.config/helix/config.toml +++ b/.config/helix/config.toml @@ -105,6 +105,29 @@ n = "scroll_down" j = "search_next" J = "search_prev" +[keys.normal.space.p] +# force inline paste +p = ':append-output ~/.config/helix/scripts/paste.py' +P = ':insert-output ~/.config/helix/scripts/paste.py' +# force linewise paste +"]" = [ + "ensure_selections_forward", + "add_newline_below", + "move_line_down", + ":insert-output ~/.config/helix/scripts/paste.py", +] +"[" = [ + "ensure_selections_forward", + "flip_selections", + "add_newline_above", + "move_line_up", + ":insert-output ~/.config/helix/scripts/paste.py", +] +c = ''' +:append-output sh -c clipcat-menu --finder custom --custom-finder-program-path fuzzel --custom-finder-arguments=--dmenu,--placeholder=Clipboard --config <(printf "[log]\nemit_stdout = true\n") | grep -q 'Nothing is selected' && exit 1 || wl-paste''' +C = ''' +:insert-output sh -c clipcat-menu --finder custom --custom-finder-program-path fuzzel --custom-finder-arguments=--dmenu,--placeholder=Clipboard --config <(printf "[log]\nemit_stdout = true\n") | grep -q 'Nothing is selected' && exit 1 || wl-paste''' + [keys.normal] tab = "trim_selections" # swap select_mode and regex keys @@ -242,10 +265,6 @@ space = [ # insert markdown toc :) -p = ''' -:append-output clipcat-menu --finder custom --custom-finder-program-path fuzzel --custom-finder-arguments=--dmenu,--placeholder=Clipboard --config <(printf "[log]\nemit_stdout = true\n") | grep -q 'Nothing is selected' && exit 1 || wl-paste''' -P = ''' -:insert-output clipcat-menu --finder custom --custom-finder-program-path fuzzel --custom-finder-arguments=--dmenu,--placeholder=Clipboard --config <(printf "[log]\nemit_stdout = true\n") | grep -q 'Nothing is selected' && exit 1 || wl-paste''' x = ":bc" X = ':sh %{buffer_name}' diff --git a/.config/helix/scripts/paste.py b/.config/helix/scripts/paste.py index 60d5971e..4d30a319 100755 --- a/.config/helix/scripts/paste.py +++ b/.config/helix/scripts/paste.py @@ -1,14 +1,7 @@ #!/usr/bin/env python import subprocess -import sys -# tiny script to force inline vs. linewise paste in Helix +# tiny script to strip only trailing newlines from clipboard -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="") +print(contents.rstrip("\n"), end="")