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

--preview: nerd font glyph support from external previewers: eza --icons #280

Open
freeo opened this issue Jan 17, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@freeo
Copy link

freeo commented Jan 17, 2025

Problem
I'm using tv as fuzzy folder finder within ranger-cli. This works surprisingly well with the current features. But since running tv dirs --preview "..." requires a pipe from stdin, the nerd-font icons from eza aren't displayed correctly. I don't know which component exactly introduces this. eza displays nerd-fonts icons correctly, but when piping this to tv with this command, then I get this char in every instance instead of the icon:

fd --type d | tv dirs --preview "eza -a --icons=always --color=always --color-scale --oneline {}"
# same goes for this minimal command
fd --type d | tv dirs --preview "eza --icons=always {}"

Maybe it's because of the pipe?

tv nerd fonts are active btw and work fine when running tv without piping from stdin.
use_nerd_font_icons = true

television 0.9.2
build: 1.83.0 (2025-01-10)

Tested in kitty and ghostty, both with the same result.

Feature

  • Support for --preview without piping from STDIN
  • Support for nerd font glyphs from preview applications lika eza.

Examples

tv dirs --preview "eza -a --icons=always --color=always --color-scale=all --color-scale-mode=gradient --oneline {}"

Additional context

SIDE NOTE: This is where I use this function:
ranger-cli commands.py

class tv_dirs_select(Command):
    def execute(self):
        import subprocess
        from ranger.ext.get_executables import get_executables

        if "tv" not in get_executables():
            self.fm.notify("Could not find tv(television)", bad=True)
            return

        tv = self.fm.execute_command(
            'fd --type d | tv dirs --preview "eza -a --icons=always --color=always --color-scale --oneline {}"',
            universal_newlines=True,
            stdout=subprocess.PIPE,
        )
        stdout, _ = tv.communicate()
        if tv.returncode == 0:
            selected = os.path.abspath(stdout.strip())
            if os.path.isdir(selected):
                self.fm.cd(selected)
            else:
                self.fm.select_file(selected)

Image

BTW, thank you for television!

@freeo freeo added the enhancement New feature or request label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant