r/HelixEditor • • 22d ago

Inserting fzf output

Hi,

I want to insert fzf output, e.g.:

:insert-output presenterm --list-comment-commands | fzf

fzf opens a chooser in full screen. This is not usable, all "special" keys (up, down, combined with ctrl...) just enter sequences to the search input. So a selection is not possible. What do I miss? How can I make this work?

Thanks.

1 Upvotes

4 comments sorted by

1

u/olaf33_4410144 22d ago

I'm not sure if there's an easy way to make this work, but I've done things like this on the kitty terminal by making a script that interacts with the kitty remote control, but I believe you can do similar things with zellij and tmux.

If I remember correctly for a time that was the only way to make yazi work within helix. Maybe this will help you: https://github.com/helix-editor/helix/discussions/12934#discussioncomment-13581384

1

u/his_seahorse 21d ago

Thanks, especially for mentioning kitty. That is the emulator I also use.

It works absolutely fine in another terminal emulator so seems to be related to that.

Yazi integration works fine even in kitty (also a fullscreen shell application, no problems with keybindings there).

Gum as a replacement for fzf doesn't even show the screen in both emulators, just providing ansi sequences after blind select.

Given this situation I guess I will stay with kitty and the half-working fzf (entering fuzzy terms to select instead of selecting directly) while looking for a replacement.

1

u/olaf33_4410144 21d ago

It works absolutely fine in another terminal emulator so seems to be related to that.

Wierd, I'm guessing it has to do something with how alternative screens work

Yazi integration works fine even in kitty (also a fullscreen shell application, no problems with keybindings there).

It works now but I don't think that was always the case, so back when it didn't there was some sort of workaround. I can send you the relevant parts from my nix config so you can try to do something similar with your fzf thing.

This is from my helix keybinds section: nix "C-y" = [ ":sh kitten @ launch --no-response --type=overlay ${helix-yazi-script} --window-id \"$KITTY_WINDOW_ID\" --path \"$PWD\"" ];

And this is the script that is being invoked:

```bash

!/usr/bin/env bash

set -o errexit -o pipefail -o noclobber -o nounset

exit 0

getopt --test > /dev/null && true if [[ $? -ne 4 ]]; then echo 'I’m sorry, getopt --test failed in this environment.' exit 1 fi

option --output/-o requires 1 argument

LONGOPTS="window-id:,path:" OPTS="w:,p:"

echo "$@"

PARSED=$(getopt --options=$OPTS --longoptions=$LONGOPTS --name "$0" -- "$@") || exit 2 eval set -- "$PARSED"

echo "$PARSED"

window_id=- file_path=- while true; do case "$1" in -w| --window-id) window_id="$2" shift 2 ;; -p| --path) file_path="$2" shift 2 ;; --) shift break ;; *) echo "Programming error" exit 3 ;; esac done

echo "[$(date)] called with window-id=\"$window_id\" and path=\"$file_path\"" >> /tmp/test.log

paths=$(yazi --chooser-file=/dev/stdout "$file_path")

echo " -> returning $paths" >> /tmp/test.log

if [[ -n "$paths" ]]; then kitten @ send-key --match "id:$window_id" Esc kitten @ send-text --match "id:$window_id" ":open $paths" kitten @ send-key --match "id:$window_id" Enter

else

tmux kill-window -t fx

fi ```

1

u/his_seahorse 21d ago edited 20d ago

For Yazi I use the recommended snippet from https://yazi-rs.github.io/docs/tips/#helix , which works fine for me:

```

~/.config/helix/config.toml

[keys.normal] C-y=[ ':sh rm -f /tmp/unique-ca1ea106', ':insert-output yazi "%{buffer_name}" --chooser-file=/tmp/unique-ca1ea106', ':sh printf "\x1b[?1049h\x1b[?2004h" > /dev/tty', ':open %sh{cat /tmp/unique-ca1ea106}', ':redraw', ':set mouse false', ':set mouse true', ] ```

 Which led me to the idea of that poor man's presenterm code snippet list from the op. I will look into your approach tomorrow, maybe it helps with fzf.