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

if file has no extension use output of file command #49

Closed
pcause opened this issue Jan 11, 2025 · 5 comments
Closed

if file has no extension use output of file command #49

pcause opened this issue Jan 11, 2025 · 5 comments
Labels
invalid This doesn't seem right

Comments

@pcause
Copy link

pcause commented Jan 11, 2025

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

ptyxis or wezterm

yazi --debug output

Yazi
    Version: 0.4.3 (b495f78 2025-01-10)
    Debug  : false
    Triple : x86_64-unknown-linux-gnu (linux-x86_64)
    Rustc  : 1.84.0 (9fc6b431 2025-01-07)

Ya
    Version: 0.4.3 (b495f78 2025-01-10)

Emulator
    Brand.from_env      : Some(WezTerm)
    Emulator.detect     : Emulator { kind: Left(WezTerm), light: false, cell_size: Some((16, 32)) }
    Emulator.detect_full: Ok(Emulator { kind: Right(Unknown { kgp: false, sixel: false }), light: false, cell_size: Some((16, 32)) })

Adapter
    Adapter.matches: Iip

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-0")
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

NVIM
    NVIM          : false
    Neovim version: 0.10.3

Variables
    SHELL           : Some("/usr/bin/zsh")
    EDITOR          : Some("/usr/bin/nvim")
    VISUAL          : Some("/usr/bin/nvim")
    YAZI_FILE_ONE   : None
    YAZI_CONFIG_HOME: None
    YAZI_ZOXIDE_OPTS: None
    FZF_DEFAULT_OPTS: None

Text Opener
    default     : Some(Opener { run: "${EDITOR:-nvim} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-create: Some(Opener { run: "${EDITOR:-nvim} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-rename: Some(Opener { run: "${EDITOR:-nvim} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : 2
    tmux version       : tmux 3.5a
    tmux build flags   : enable-sixel=Unknown
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file          : 5.45
    ueberzugpp    : No such file or directory (os error 2)
    ffmpeg/ffprobe: 7.0.2 / 7.0.2
    pdftoppm      : 24.08.0
    magick        : 7.1.1-41
    fzf           : 0.57.0
    fd/fdfind     : 10.1.0 / No such file or directory (os error 2)
    rg            : 14.1.1
    chafa         : 1.14.5
    zoxide        : No such file or directory (os error 2)
    7z/7zz        : 16.02 / 24.09
    jq            : 1.7.1

Clipboard
    wl-copy/paste: 2.2.1 / 2.2.1
    xclip        : No such file or directory (os error 2)
    xsel         : 1.2.1

Describe the bug

I have a shell script in a file with no extension. When I this plugin I don't get a preview but merely :

A header line that says file type classification and then a line that says
POSIX shell script, Unicode text, UTF-8 text, executable

If I disable the extension I get a preview of the file. I think the code here should look for a match and then if not use the file command, as yazi does, to determine the mime type. When I disable the extension yazi does display a preview.

Minimal reproducer

create a bash shell script in a file without an extension.

Anything else?

No response

@pcause pcause added the bug Something isn't working label Jan 11, 2025
@sxyazi
Copy link
Member

sxyazi commented Jan 11, 2025

I think the code here should look for a match and then if not use the file command

fallback_file1 = true is exactly this, see https://github.com/yazi-rs/plugins/tree/main/mime-ext.yazi#advanced

Next time, please search through the documentation/issues before creating a new post - you can do better 👍

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2025
@sxyazi sxyazi added invalid This doesn't seem right and removed bug Something isn't working labels Jan 11, 2025
@pcause
Copy link
Author

pcause commented Jan 11, 2025

sorry. missed the last part of the init.lua since I wasn't interested in custom filenames/folder, so missed the last bit.

curious why this defaults to false and not true. seems to me the difference in speed when needing to do the file lookup after no match would be negligible.

@sxyazi
Copy link
Member

sxyazi commented Jan 13, 2025

curious why this defaults to false and not true

Its name mime-ext suggests that it works based on file extensions, so assuming it always relies on extensions and doesn't involve file content is a safer bet.

When users use it on network devices, it won't accidentally download files with unrecognized extensions, since those unrecognized files aren't necessarily small files.

@pcause
Copy link
Author

pcause commented Jan 13, 2025

Understand but not clear/obvious. Might make a small change to the README saying that by default, this changes yazi behavior to ONLY rely on extensions. If the user wishes to have this plugin use the yazi file method if the extension doesn't match soemthing that plugin supports, see the Advanced example below

@sxyazi
Copy link
Member

sxyazi commented Jan 13, 2025

I'd appreciate a PR for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants