yazi icon indicating copy to clipboard operation
yazi copied to clipboard

Add option to set cursor position based on file type, when renaming files

Open dxrcy opened this issue 1 month ago • 0 comments

yazi --debug output

Yazi
    Version: 0.4.2 (Arch Linux 2024-12-28)
    Debug  : false
    Triple : x86_64-unknown-linux-gnu (linux-x86_64)
    Rustc  : 1.83.0 (90b35a62 2024-11-26)

Ya
    Version: 0.4.2 (Arch Linux 2024-12-28)

Emulator
    Brand.from_env      : Some(Kitty)
    Emulator.detect     : Emulator { kind: Left(Kitty), light: false, cell_size: Some((14, 29)) }
    Emulator.detect_full: Ok(Emulator { kind: Left(Kitty), light: false, cell_size: Some((14, 29)) })

Adapter
    Adapter.matches: Kgp

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-1")
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: Some("0bd541f2fd902dbfa04c3ea2ccf679395e316887_1735515382_248783120")
    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("nvim")
    VISUAL          : None
    YAZI_FILE_ONE   : None
    YAZI_CONFIG_HOME: None
    YAZI_ZOXIDE_OPTS: None
    FZF_DEFAULT_OPTS: None

Text Opener
    default     : Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-create: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-rename: Some(Opener { run: "${EDITOR:-vi} \"$@\"", 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.46
    ueberzugpp    : No such file or directory (os error 2)
    ffmpeg/ffprobe: 7.1 / 7.1
    pdftoppm      : 24.12.0
    magick        : 7.1.1-43
    fzf           : 0.57.0
    fd/fdfind     : 10.2.0 / No such file or directory (os error 2)
    rg            : 14.1.1
    chafa         : No such file or directory (os error 2)
    zoxide        : 0.9.6
    7z/7zz        : 24.09 / No such file or directory (os error 2)
    jq            : 1.7.1

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

Please describe the problem you're trying to solve

The --cursor option for the rename command will use the same behavior for both regular files and directories. Eg. rename --cursor=before_ext will always put the cursor before the file extension.

This is annoying when renaming directories containing period characters as word separators, as the periods do not usually indicate an extension.

Would you be willing to contribute this feature?

  • [X] Yes, I'll give it a shot

Describe the solution you'd like

Introduce before_file_ext value for --cursor. This will behave as end for directories, and before_ext for a non-directory file. This might not be ideal, as a user cannot chose between end and start for directory renaming.

Perhaps a new --cursor-directory option can be added, but this seems over-involved.

If this can be resolved with a simple configuration tweak, such as overloading keybinds or creating a simple plugin, then that might be preferable.

Additional context

This might be a problem which is too niche to introduce new behavior for. If so, I am happy to abandon this issue in favor of a creating a custom plugin.

Checklist

  • [X] I have searched the existing issues/discussions
  • [X] The latest nightly build doesn't already have this feature

dxrcy avatar Dec 30 '24 01:12 dxrcy