Skip to content

Platform-specific keymap #1561

Description

@hongyuanjia

yazi --debug output

❯ yazi --debug

Yazi
    Version: 0.3.0 (7a380c2 2024-08-01)
    Debug  : false
    OS     : windows-x86_64 (windows)

Ya
    Version: 0.3.0

Emulator
    Emulator.via_env: ("xterm-256color", "WezTerm")
    Emulator.via_csi: Ok(Unknown([]))
    Emulator.detect : WezTerm

Adapter
    Adapter.matches: Iterm2

Desktop
    XDG_SESSION_TYPE: None
    WAYLAND_DISPLAY : None
    DISPLAY         : None

SSH
    shared.in_ssh_connection: false

WSL
    /proc/sys/fs/binfmt_misc/WSLInterop: false

Variables
    SHELL              : None
    EDITOR             : None
    YAZI_FILE_ONE      : Some("C:\\Users\\hongyuanjia\\scoop\\apps\\git\\current\\usr\\bin\\file.exe")
    YAZI_CONFIG_HOME   : None
    ZELLIJ_SESSION_NAME: None

Text Opener
    default: Some(Opener { run: "nvim \"%@\"", block: true, orphan: false, desc: "neovim", for_: None, spread: false })
    block  : Some(Opener { run: "nvim \"%@\"", block: true, orphan: false, desc: "neovim", for_: None, spread: false })

tmux
    TMUX   : false
    Version: program not found

Dependencies
    file             : 5.45
    ueberzugpp       : program not found
    ffmpegthumbnailer: program not found
    magick           : program not found
    fzf              : 0.53.0
    fd               : 10.1.0
    rg               : 14.1.0
    chafa            : program not found
    zoxide           : program not found
    7z               : 24.06
    7zz              : program not found
    jq               : 1.7.1


--------------------------------------------------
When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time.
You can find it in the "C:\\Users\\hongyuanjia\\AppData\\Roaming\\yazi\\state" directory.

Please describe the problem you're trying to solve

In yazi.toml we can have a for field to specify the settings for specific platforms, e.g.:

[opener]
edit = [
    { run = '${EDITOR:=vi} "$@"', block = true, desc = "$EDITOR", for = "unix" },
    { run = 'nvim "%@"', block = true, desc = "neovim", for = "windows" }
]

I wonder if it is possible to do the same in keymap.toml? E.g.:

[[manager]]
prepend_keymap = [
    { on = [ "<C-s>" ], run = 'shell "$SHELL" --block --confirm', desc = "Open shell here", for = "unix" },
    { on = [ "<C-s>" ], run = 'shell "pwsh" --block --confirm', desc = "Open shell here",for = "windows" }
]

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

[[manager]]
prepend_keymap = [
    { on = [ "<C-s>" ], run = 'shell "$SHELL" --block --confirm', desc = "Open shell here", for = "unix" },
    { on = [ "<C-s>" ], run = 'shell "pwsh" --block --confirm', desc = "Open shell here",for = "windows" }
]

Additional context

No response

Validations

  • I have searched the existing issues
  • The latest nightly build of Yazi doesn't already have this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions