2

Using nnn (which is a terminal-based file manager), how can you copy the text of a file or folder's name to the clipboard?

For your convenience, this will install and launch nnn in Debian (if you'd like to help me figure it out):

sudo apt install nnn ; nnn
1
  • 1
    One way, that I just discovered, is to press the f key. This displays the path, where I can then copy using my mouse. Is there a quicker way than this? Commented Jul 27, 2022 at 14:13

3 Answers 3

3

The best way would be to use the nnn plugin functionality and pipe the name to xclip, for example:

export NNN_PLUG='s:! echo $nnn|xclip*'

and then hit ;s to pipe the currently selected name to xclip

Note: Debian stable has a rather old version of nnn with which this solution won't work. I suggest to build nnn yourself or backport it from testing

4
  • In Debian 11, I added deb http://deb.debian.org/debian bullseye-backports main to the file /etc/apt/sources.list. Then, at a command prompt, I entered sudo apt update ; sudo apt install nnn/bullseye-backports. I received this error E: Release 'bullseye-backports' for 'nnn' was not found. Commented Jul 28, 2022 at 0:02
  • 1
    Yes, unfortunately there is no package in bullseye-backports for nnn. You have to backport it yourself or just build it yourself or use the packages provided at github.com/jarun/nnn/releases Commented Jul 28, 2022 at 6:55
  • If you want user-confirmation afterwards, omit the final * in the above command. Commented Nov 21, 2022 at 5:09
  • notice this copies only the filename, not the full path Commented Nov 25, 2022 at 12:56
2

To copy the full path, not just the name, in Wayland, use:

NNN_PLUG=s:-!echo $PWD/$nnn|wl-copy*
2

There is a nnn plugin that allows you to copy absolute and relative paths here.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.