Nnn: Cannot copy file path on macOS

Created on 24 May 2020  路  13Comments  路  Source: jarun/nnn

I'm sorry if I'm mising something obvious but I can't seem to find an easy way to copy a full file path in nnn.

I'm on macOS Catalina 10.15.4. nnn v3.1 installed via brew. i'm using zsh in iterm2.

First I tried invoking nnn using nnn -x. The docs say if I do that, I should be able to copy a file path just by selecting it (e.g. using the space bar?) EG:

Use the program option -x to copy selection to the system clipboard. You must have plugins installed.

this does not work for me i.e. selecting a file puts nothing on the clipboard. Am I doing something wrong? Also, what does 'you must have plugins installed' mean? which plugins? Installed how?

Since that did not work I also tried setting the NNN_COPIER environment variable with a copier.sh script:

#!/bin/sh

echo -n $1 | pbcopy

I saved it as ~/.config/nnn/copier.sh, made it executable, and put ~/.config/nnn in my PATH (as per previous issues) but I'm unsure about how to invoke it. ^k is suggested on various sites but has no effect. it is already bound to Mark range/clear. what am i missing?

I'm at a dead end, any help would be appreciated. Thanks!

question

Most helpful comment

Thanks @jarun! I have indeed got it working

Believe it or not, I did look at the list of plugins but did not find anything relevant in the list at https://github.com/jarun/nnn/tree/master/plugins#list-of-plugins.

For anyone else who may experience similar problems, the .cbcp plugin is the one you want. The name is not descriptive and it is not listed in the list of plugins.

It was on display. In the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying 鈥楤eware of the Leopard'

thank you for helping me solve my problem! 馃榿

All 13 comments

Your issue is looks similar to https://github.com/jarun/nnn/issues/184.

NNN_COPIER is retired for a while now - https://github.com/jarun/nnn/wiki/Usage#configuration. So you have to install the plugins and invoke nnn with the -x option.

which plugins? Installed how?

The plugins and documentation are here: https://github.com/jarun/nnn/tree/master/plugins

I believe you should be able to fix the problem now. All the best!

Thanks @jarun! I have indeed got it working

Believe it or not, I did look at the list of plugins but did not find anything relevant in the list at https://github.com/jarun/nnn/tree/master/plugins#list-of-plugins.

For anyone else who may experience similar problems, the .cbcp plugin is the one you want. The name is not descriptive and it is not listed in the list of plugins.

It was on display. In the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying 鈥楤eware of the Leopard'

thank you for helping me solve my problem! 馃榿

No problem!

You didn't find it because it is nnn internal. Installing the plugins install the hidden ones as well.

And of course, feel free to award a star to the project if you like it and/or if you think it's worth appreciating the time and effort of the devs.

I'm having the same issue as @getmoheb on a similar spec (macOS 10.13.6 iterm2) ... selection copies to clipboard on the first loading of nnn, but does not update anytime for any subsequent selections made afterwards.

Any subsequent selections are not being transferred to clipboard, and I can't seem to figure out why. I am invoking -x manually in addition to it being set in NNN_OPTS in sourced ~/.bashrc. I seem to have all the necessary dependencies and plugins installed.

I'm having the same issue as @getmoheb

Not sure if it's the same issue. For @getmoheb nothing was getting selected. In your case the first one is selected.

@getmoheb can you please help @protrolium resolve this? I think it's a local problem.

I am noticing that each time I make a selection and then q to leave nnn Xquartz its opening in the background. This was not happening earlier, and I'm trying to figure out if this has something to do with my problem.

If it helps, in your case pbcopy should be invoked.

This is the script: https://github.com/jarun/nnn/blob/master/plugins/.cbcp

Location of the script: ${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins

@jarun thank you for clarifying. i'm looking for assistance in trying to resolve this.

I have identified that for some reason Xquartz GUI opens in the background once I make a selection within nnn. I have to manually quit Xquartz, and then space bar to make a new selection passes it to clipboard successfully, as intended. If I don't close XQuartz, the selection is not passed successfully.

What is happening here with XQuartz? How to prevent this behavior of it interfering with the selection?

@protrolium I don't know macOS, but maybe you have xclip or xsel installed, relying on Xquartz: in that case edit ~/.config/nnn/plugins/.cbcp to prefer pbcopy over xsel/xclip (it should work better on mac I guess).

@protrolium i'm not experiencing the same issue but then I don't have xquartz installed - perhaps it is related to that, as @leovilok suggested?

thanks very much @jarun @leovilok. it was indeed the .cbcp plugin that was using Xquartz. I have pbcopyworking now.

I think my earlier frustration with the path not being copied might be my misreading what I was trying to use nnn to do. It seems that the selection's path made within nnn is not retrievable after q and returning to shell, but is updated and remains current while navigating within nnn.

I was trying to use selections from within nnn to yank a filepath to system clipboard (-x) and then use after exiy in the shell prompt. This is still not working for me. It seems to work the first time on shell boot up and first entering nnn but is not updated on subsequent ins/outs of nnn.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ralphee picture ralphee  路  6Comments

harriott picture harriott  路  6Comments

akimdi picture akimdi  路  5Comments

kuntau picture kuntau  路  3Comments

weatherbell picture weatherbell  路  8Comments