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

Symlink features: go to target, yank target #2437

Open
2 of 3 tasks
maxfl opened this issue Mar 4, 2025 · 6 comments
Open
2 of 3 tasks

Symlink features: go to target, yank target #2437

maxfl opened this issue Mar 4, 2025 · 6 comments
Labels
feature New feature request

Comments

@maxfl
Copy link

maxfl commented Mar 4, 2025

yazi --debug output

Yazi
Version: 25.2.26 (Arch Linux 2025-02-27)
Debug  : false
Triple : x86_64-unknown-linux-gnu (linux-x86_64)
Rustc  : 1.85.0 (4d91de4e 2025-02-17)

Ya
Version: 25.2.26 (Arch Linux 2025-02-27)

Emulator
TERM                : Some("xterm-256color")
TERM_PROGRAM        : None
TERM_PROGRAM_VERSION: None
Brand.from_env      : Some(Konsole)
Emulator.detect     : Emulator { kind: Left(Konsole), light: true, cell_size: Some((8, 17)) }

Adapter
Adapter.matches: KgpOld

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

SSH
shared.in_ssh_connection: false

WSL
WSL: false

Variables
SHELL           : Some("/usr/bin/fish")
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               : false
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    : 2.9.6
ffmpeg/ffprobe: 7.1 / 7.1
pdftoppm      : 25.02.0
magick        : 7.1.1-44
fzf           : 0.60.2
fd/fdfind     : 10.2.0 / No such file or directory (os error 2)
rg            : 14.1.1
chafa         : 1.14.5
zoxide        : 0.9.7
7zz/7z        : No such file or directory (os error 2) / 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         : No such file or directory (os error 2)


See https://yazi-rs.github.io/docs/plugins/overview#debugging on how to enable logging or debug runtime errors.

Please describe the problem you're trying to solve

For symlinks I see where it points to. It is often needed to do something not with the symlink itself, but with the target. The basic features include:

  • follow to target command: opens the folder of the target, sets the cursor on the symlink. May be supplemented with a command (argument) to open the target in the new tab.
  • yank target. The alternative to yank, which, when pasted pastes the target files (or new symlinks to them).

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

Introduce commands:

  • follow to target command: opens the folder of the target, sets the cursor on the symlink. May be supplemented with a command (argument) to open the target in the new tab.
  • yank target. The alternative to yank, which, when pasted pastes the target files (or new symlinks to them).

Additional context

I've searched documentation, list of keys, plugins, issues and merge requests and did not find anything relevant.

Checklist

  • I have searched the existing issues/discussions
  • The latest nightly build doesn't already have this feature
@maxfl maxfl added the feature New feature request label Mar 4, 2025
@sxyazi
Copy link
Owner

sxyazi commented Mar 4, 2025

  • follow to target command: opens the folder of the target, sets the cursor on the symlink. May be supplemented with a command (argument) to open the target in the new tab.

Do you have any suggestions for command names, parameter names, and default key bindings?

  • yank target. The alternative to yank, which, when pasted pastes the target files (or new symlinks to them).

This is already supported via paste --follow.

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Mar 4, 2025
@hakan-demirli
Copy link

follow_symlink: (go to link a.k.a <gl>)

	{ on = [ "g", "l" ], run = '''shell 'ya emit cd "$(readlink -f "$1")"' ''', desc = "Follow hovered symlink" },

@maxfl
Copy link
Author

maxfl commented Mar 5, 2025

@hakan-demirli, thanks a lot. I've done a few modifications:

  • replaced $1 with $0 for hovered file.
  • followed the command with leave as cd kind of enters the file.

I've tried using dirname for cd, but found out that there is no a proper command to set a cursor on particular file afterwards.

[[manager.prepend_keymap]]
on = [ "g", "l" ]
run = '''shell 'ya emit cd "$(readlink -f "$0")" && ya emit leave' '''
desc = "Follow hovered symlink"

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Mar 5, 2025
@maxfl
Copy link
Author

maxfl commented Mar 5, 2025

  • follow to target command: opens the folder of the target, sets the cursor on the symlink. May be supplemented with a command (argument) to open the target in the new tab.
    Do you have any suggestions for command names, parameter names, and default key bindings?

gl as suggested by @hakan-demirli seems to be a good choice.

  • yank target. The alternative to yank, which, when pasted pastes the target files (or new symlinks to them).
    This is already supported via paste --follow.

Thank you for pointing to this. The only difference from the proposal is that when you are able to yank target paths you can use -/_ to make new links to the targets, which I consider to be a useful feature. With paste --follow it is impossible. May be --follow key may be added to link command as well.

@sxyazi
Copy link
Owner

sxyazi commented Mar 5, 2025

there is no a proper command to set a cursor on particular file afterwards

Try:

[[manager.prepend_keymap]]
on = [ "g", "l" ]
run = 'shell -- ya emit reveal "$(readlink -f "$0")"'
desc = "Follow hovered symlink"

@maxfl
Copy link
Author

maxfl commented Mar 5, 2025

@sxyazi, this works, thanks a lot. (do not understand how I've missed the command when searching the docs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

3 participants