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

Platform-specific keymap #1561

Closed
2 of 3 tasks
hongyuanjia opened this issue Aug 27, 2024 · 3 comments
Closed
2 of 3 tasks

Platform-specific keymap #1561

hongyuanjia opened this issue Aug 27, 2024 · 3 comments
Labels
feature New feature request

Comments

@hongyuanjia
Copy link

hongyuanjia commented Aug 27, 2024

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
@hongyuanjia hongyuanjia added the feature New feature request label Aug 27, 2024
@sxyazi
Copy link
Owner

sxyazi commented Aug 27, 2024

Sorry, this is one of the features I don't want to add because it goes against Yazi's design philosophy. Yazi is meant to have consistent behavior across all platforms, so assigning different functions to the same key on different platforms would clearly violate that.

The reason we introduced for for [opener] was to hide these differences - even if the opener defines different programs, you can still use them consistently within [open]. The same goes for keybindings: if you really want to have platform-specific differences, please hide them in a plugin, here is an example #51 (comment)

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2024
@hongyuanjia
Copy link
Author

No worry, it totally makes sense. Thanks for the hint.

Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳
This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

2 participants