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

Ability to cd directly to one-off directories #1758

Closed
fryit5150 opened this issue Nov 11, 2023 · 8 comments
Closed

Ability to cd directly to one-off directories #1758

fryit5150 opened this issue Nov 11, 2023 · 8 comments

Comments

@fryit5150
Copy link

Can you add a way to go directly to a one-off directory? Say if I need to a directory in /usr/share it's quite clumsy to have to type `, ^N, usr, share, ... rather than e.g. :cd <ctrl+shift+v> in other file managers.

@fryit5150 fryit5150 added the bug label Nov 11, 2023
@N-R-K
Copy link
Collaborator

N-R-K commented Nov 11, 2023

It should be possible to do this quite easily with a plugin. There's already a couple cd related plugin you can take a look at for reference.

@N-R-K N-R-K added enhancement and removed bug labels Nov 11, 2023
@fryit5150
Copy link
Author

It's quite basic functionality, so it would be great not needing to install and setup a plugin for it on all my computers/new installs in VMs.

@0xACE
Copy link
Collaborator

0xACE commented Nov 13, 2023

It's quite basic functionality, so it would be great not needing to install and setup a plugin for it on all my computers/new installs in VMs.

It serves no purpose, you can literally hit these keys:

!mkdir -p foo/bar/baz<ENTER><CTRL-D>

for a better and more robust functionality...

update: i didnt read the topic and assumed the request was to create sub folders... my bad...

@fryit5150
Copy link
Author

It's quite basic functionality, so it would be great not needing to install and setup a plugin for it on all my computers/new installs in VMs.

It serves no purpose, you can literally hit these keys:

!mkdir -p foo/bar/baz<ENTER><CTRL-D>

for a better and more robust functionality...

You are right. Running mkdir to browse a directory makes no sense at all.

@N-R-K
Copy link
Collaborator

N-R-K commented Nov 14, 2023

Here's a plugin to do what you want:

#!/bin/sh

printf "enter path to cd: "
read -r to
[ -n "$to" ] && printf "0c%s" "${to}" > "$NNN_PIPE"

it would be great not needing to install and setup a plugin for it on all my computers/new installs in VMs

Whether to include this feature in nnn natively or not is @jarun's call. I don't really have any preference here one way or other.

@0xACE
Copy link
Collaborator

0xACE commented Nov 14, 2023

Sorry i didn't fully read the topic.

This is the way it was implemented on my branch: when in filter mode: / will cd into a directory if the highlighted line is a directory otherwise it will clear the filter + show all files and highlight the matched item, essentially allowing you to paste a path to go to the desired location.

I just gave it a try, it still works after 3 years, but I guess it doesnt work while nnn is running within tmux...

@jarun
Copy link
Owner

jarun commented Nov 17, 2023

We can't add a new keybind for changing directories.
Plugins are one of the best features of nnn and very simple to migrate and use.

However, in this case, did you try to add the following in your ~/.bashrc:

NNN_PLUG='c:!read -r to && [ -n "$to" ] && printf "0c%s" "${to}" > "$NNN_PIPE"*'

and press Alt-C and paste the destination path?

@jarun
Copy link
Owner

jarun commented Nov 19, 2023

Fixed at 9259170.

@jarun jarun closed this as completed Nov 19, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants