Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weird output with fish-apple-touchbar & iterm2 #184

Closed
1 task done
fredericrous opened this issue Jul 3, 2021 · 9 comments
Closed
1 task done

weird output with fish-apple-touchbar & iterm2 #184

fredericrous opened this issue Jul 3, 2021 · 9 comments

Comments

@fredericrous
Copy link

Describe the bug

When I use fzf.fish in conjunction with fish-apple-touchbar, I am getting extra lines containing "1337;SetKeyLabel=" shown on the attached screenshot

Steps to Reproduce

Steps to reproduce the behavior:

  1. fisher install rodrigobdz/fish-apple-touchbar
  2. fisher install PatrickF1/fzf.fish
  3. Ctrl+R

Screenshots

image

Environment

Versions installed:

  • Fish: 3.3.0
  • fzf.fish: 7.1
  • plugin manager: 4.3.0
  • iTerm2: 3.4.6
  • macOS Big Sur 11.4

Additional context

I configured fish-apple-touchbar 1.0.0 like so:

cat  ~/.config/fish/conf.d/touchbar.fish
__fish_apple_touchbar_bind_key_custom 1 '👈' 'prevd' '-s'
__fish_apple_touchbar_bind_key_custom 2 '🗄 jump' 'cdh' '-s'

https://github.com/fredericrous/dotfiles/blob/main/private_dot_config/private_fish/conf.d/touchbar.fish
https://github.com/fredericrous/dotfiles/blob/main/private_dot_config/private_fish/functions/__fish_apple_touchbar_bind_key_custom.fish

fzf_configure_bindings --directory=\cf --git_log=\cg --git_status=\cs

https://github.com/fredericrous/dotfiles/blob/master/private_dot_config/private_fish/config.fish#L38

This issue might be related to #183, but the extra lines appear at a different spot.

My exact config for fish is there https://github.com/fredericrous/dotfiles/tree/main/private_dot_config/private_fish
The extra characters 1337 are apparently issued by iterm2
The issue does not seem to come from fish-apple-touchbar plugin rodrigobdz/fish-apple-touchbar#13

@PatrickF1
Copy link
Owner

Sorry about the bug! Can you add 2>/dev/null to fzf_configure_bindings and see if anything changes?

@fredericrous
Copy link
Author

fredericrous commented Jul 3, 2021

No change. I also tried to remove the function as suggested in issue #183 . No effect. Maybe we could just deactivate the preview by setting an environment variable for example? I find the preview a bit slow anyway.
Actually I'm also getting that on file preview
image

@PatrickF1
Copy link
Owner

PatrickF1 commented Jul 3, 2021

Maybe we could just deactivate the preview by setting an environment variable for example?

Sure check this out https://github.com/PatrickF1/fzf.fish/wiki/Cookbook#how-can-i-disable-the-fzf-preview-pane-for-a-particular-command.

Thanks for giving me such detailed screenshots and description of your set up. It really helps with debugging! 💯
Anyway, I suspect that https://github.com/rodrigobdz/fish-apple-touchbar/blob/main/functions/__fish_apple_touchbar_print_key.fish#L6 is causing the output. In which case your touchbar config might have a bug in it. I'm not too familiar with the touchbar code so can't say right now...

@fredericrous
Copy link
Author

fredericrous commented Jul 4, 2021

I suspected the same, tried disabling the print_key function, but it appears that this function is essential for the custom buttons to appear in the touchbar.
Thanks for directing me to this part of the doc, I hadn't noticed fzf_history_opts. It feels better than overriding the function _fzf_search_history 😅

UPDATE:
If I remove the \e]1337; in https://github.com/rodrigobdz/fish-apple-touchbar/blob/main/functions/__fish_apple_touchbar_print_key.fish#L2
the extra line appears at the top of my terminal as well

If I try to change the escape codes suggested on page https://iterm2.com/documentation-escape-codes.html
adding \e\\ instead of \a doesn't solve the issue. I think the solution would be to make some code specific to iTerm2 and strip everything that contains the string OSC 1337 ; SomeCommandsHere ST with maybe something like "s/\e]1337 ; .*[(\e\\|\a)]/" before passing it to preview..

Actually when I do fzf --preview "echo hello", I get the issue.. It seems related to fzf then :/ I see people are having similar issues there => junegunn/fzf#881
I tried the solution suggested overthere, I tried to remove fish_vi_key_bindings from my config but the issue persists

I think we can close this issue. I found a weird workaround actually, I put my config for apple touch bar in config.fish instead of conf.d/touchbar.fish..I don't know why it works but it does..

@PatrickF1
Copy link
Owner

I am so confused....thanks for reporting back though! Are you saying this is more of an fzf bug?

@fredericrous
Copy link
Author

I don't know for sure if it's a bug with fzf but this characters should in theory be "removed" by iTerm2.. I written an issue report and was ready to send it to iTerm2 bug tracker, when I found the workaround. Because I don't understand why this workaround is working and I already spend too much time on that, I kinda gave up and didn't send the issue

@kidonng
Copy link
Contributor

kidonng commented Jul 5, 2021

This is not a bug with either fzf.fish or fish-apple-touchbar. It's because you are calling __fish_apple_touchbar_bind_key_custom in conf.d/touchbar.fish, which in turn calls __fish_apple_touchbar_print_key and output those escape codes. conf.d scripts will be sourced even in non-interactive sessions, and that's where fzf's preview window runs.

It is very likely that you have guard your config with status -i || exit or something similar when you put it in config.fish, therefore resolving the issue.

@PatrickF1
Copy link
Owner

Thank you for debugging this @kidonng !

@fredericrous
Copy link
Author

That explains why I had no issue when I put that in my config.fish. You're totally right @kidonng, I indeed ended up putting the lines __fish_apple_touchbar_bind_key_custom at the bottom, behind a status is-interactive || exit... I'll use this check in touchbar.fish instead, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants