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

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

Closed
3 tasks done
dxrcy opened this issue Dec 30, 2024 · 3 comments · Fixed by #2132
Closed
3 tasks done

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

dxrcy opened this issue Dec 30, 2024 · 3 comments · Fixed by #2132
Labels
bug Something isn't working

Comments

@dxrcy
Copy link
Contributor

dxrcy commented Dec 30, 2024

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?

  • 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

  • I have searched the existing issues/discussions
  • The latest nightly build doesn't already have this feature
@dxrcy dxrcy added the feature New feature request label Dec 30, 2024
@sxyazi sxyazi added bug Something isn't working and removed feature New feature request labels Dec 31, 2024
@sxyazi
Copy link
Owner

sxyazi commented Dec 31, 2024

Please try #2132

@dxrcy
Copy link
Contributor Author

dxrcy commented Jan 1, 2025

Please try #2132

Yep works 🙏 thanks

Copy link

github-actions bot commented Feb 1, 2025

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 file 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 Feb 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants