You are not logged in.

#1 2022-06-06 10:44:01

RounakDutta
Member
From: West Bengal, India
Registered: 2022-02-11
Posts: 192
Website

[SOLVED] Problems with nnn file manager

I have installed the nnn file manager and I am having some problems with it -

  • I Cannot edit files. Pressing "e" on the keyboard doesn't open the file in my default text editor which is "mousepad"

  • I Cannot edit empty files/text files. When I press e on my keyboard nothing happens

Here is my .bashrc

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
neofetch

export NNN_BMS='d:~/Desktop;p:~/Pictures;D:~/Downloads/'
export NNN_SSHFS="sshfs -o follow_symlinks"        # make sshfs follow symlinks on the remote
export NNN_COLORS="2136"                           # use a different color for each context
export NNN_TRASH=1                                 # trash (needs trash-cli) instead of delete
 

Any help would be appreciated.

Last edited by RounakDutta (2022-06-06 14:42:30)

Offline

#2 2022-06-06 11:52:09

dogknowsnx
Guest

Re: [SOLVED] Problems with nnn file manager

Judging from this topic text files should open in 'vim'.
https://github.com/jarun/nnn/wiki/Usage#program-options

EDIT: If you want text files to be opened with 'mousepad' by default, you have to set your mimetypes accordingly (try and press 'Right' or 'o' in nnn...)

Last edited by dogknowsnx (2022-06-06 12:08:03)

#3 2022-06-06 14:05:28

RounakDutta
Member
From: West Bengal, India
Registered: 2022-02-11
Posts: 192
Website

Re: [SOLVED] Problems with nnn file manager

dogknowsnx wrote:

Judging from this topic text files should open in 'vim'.
https://github.com/jarun/nnn/wiki/Usage#program-options

EDIT: If you want text files to be opened with 'mousepad' by default, you have to set your mimetypes accordingly (try and press 'Right' or 'o' in nnn...)

I set mousepad as my default editor.
I also tried setting vim as my default editor

When I set vim as my default text editor and I try to open the text file by pressing enter it opens it in a browser and when I set mousepad as my default text editor and I try to open the text file by pressing enter it opens it in firefox again.
When I try to edit  a file by pressing "e" nothing happens.

Last edited by RounakDutta (2022-06-06 14:16:06)

Offline

#4 2022-06-06 14:10:02

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Problems with nnn file manager

RounakDutta wrote:

I set mousepad as my default editor.

how / where did you do this, there is no EDITOR setting in the shellrc file you posted.  If EDITOR is not set, nnn defaults to 'vi', and if 'vi' is not installed, pressing 'e' will indeed do nothing.

Last edited by Trilby (2022-06-06 14:19:26)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2022-06-06 14:19:15

RounakDutta
Member
From: West Bengal, India
Registered: 2022-02-11
Posts: 192
Website

Re: [SOLVED] Problems with nnn file manager

Trilby wrote:
RounakDutta wrote:

I set mousepad as my default editor.

how / where did you do this, there is no EDITOR setting in the shellrc file you posted.

I changed it now -

 
#
# ~/.bash_profile
#
if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
	  exec startx
fi

export EDITOR=vim

and ran the

 source .bash_profile

command.
And for mousepad I remove the EDITOR=vim line from .bash_profile and source the file. Then I ran -

 xdg-mime default vim.desktop text/plain

Last edited by RounakDutta (2022-06-06 14:21:38)

Offline

#6 2022-06-06 14:21:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Problems with nnn file manager

Why set it to vim?  Do you want to use vim or mousepad?  Does nnn now open the file in vim when you press 'e'?

Note that putting it after the exec startx in your bash_profile is almost completely useless - it will not be applied in most situations that you would want it applied.  (It will in your currently running shell after your source'd .bash_profile, but it will not be anywhere else other than other ttys).

xdg-mime is irrelevant.  Set EDITOR to the editor you want to use.  That's it.  (edit: though if it was relevant, setting the default mime handler for text files to vim.desktop would certainly not result in mousepad being used!)

Last edited by Trilby (2022-06-06 14:23:26)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2022-06-06 14:29:41

RounakDutta
Member
From: West Bengal, India
Registered: 2022-02-11
Posts: 192
Website

Re: [SOLVED] Problems with nnn file manager

Trilby wrote:

Why set it to vim?  Do you want to use vim or mousepad?  Does nnn now open the file in vim when you press 'e'?

Nope pressing "e" does nothing. I cannot open any files when I press "e"
When I press enter the file open inside a browser instead of vim.

Trilby wrote:

Note that putting it after the exec startx in your bash_profile is almost completely useless - it will not be applied in most situations that you would want it applied.  (It will in your currently running shell after your source'd .bash_profile, but it will not be anywhere else other than other ttys).

Oh! From now on I will put my environment variables in bashrc then.

EDIT: I just restarted my pc and now nnn works!! It opens it vim. Thanks a lot @Trilby and @dogknowsnx for helping me on this. Marking the post as [SOLVED]

@dogknowsnx Thanks for giving me the mimetype link. I didn't knew that mimetype only sets default apps for GUI applications and for CLI apps like vim we have to use environment variables.

Last edited by RounakDutta (2022-06-06 14:46:12)

Offline

#8 2022-06-06 14:39:31

dogknowsnx
Guest

Re: [SOLVED] Problems with nnn file manager

@RounakDutta I wouldn't recommend exporting a GUI editor... Please do some more reading: man nnn.
There are different ways/keybindings for opening files, e.g. 'e' for 'edit', 'l' and 'Right' for opening files with default applications...

EDIT: I just read your last post and saw that you exported 'vim'...
EDIT#2: Thank @Trilby, @Slithery didn't participate...

Last edited by dogknowsnx (2022-06-06 14:42:58)

#9 2022-06-06 14:45:06

RounakDutta
Member
From: West Bengal, India
Registered: 2022-02-11
Posts: 192
Website

Re: [SOLVED] Problems with nnn file manager

dogknowsnx wrote:

EDIT#2: Thank @Trilby, @Slithery didn't participate...

Lol sorry. I made a mistake.

Offline

#10 2022-06-06 14:49:47

dogknowsnx
Guest

Re: [SOLVED] Problems with nnn file manager

RounakDutta wrote:

I didn't knew that mimetype only sets default apps for GUI applications and for CLI apps like vim we have to use environment variables.

Technically you can export every app, GUI apps just won't work outside a graphical environment, obviously...

#11 2022-06-06 15:19:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Problems with nnn file manager

I agree, setting EDITOR to a gui editor like 'mousepad' is not generally ideal*.  However, the potential downsides are minimized if you are pretty much exclusively using your system from within an X11 session and you are not shelling into remote systems or using the tty much.  But setting EDITOR is the only bit relevant to changing the 'e' key binding.  Using other keys (like return) will most likely use mime-types, and for those options xdg-mime settings would likely be relevant.

*note: if I'm being completely honest, I'd not find using a gui editor like mousepad in any contenxt to be ideal!  Learn vim!  I'm (mostly) joking; of all the gui text-editors I've found mousepad to be one of the most tolerable - but once I learned vim, I never wanted to ever use any gui editor again.

Last edited by Trilby (2022-06-06 15:21:46)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#12 2022-06-06 17:19:38

RounakDutta
Member
From: West Bengal, India
Registered: 2022-02-11
Posts: 192
Website

Re: [SOLVED] Problems with nnn file manager

Trilby wrote:

I agree, setting EDITOR to a gui editor like 'mousepad' is not generally ideal*.  However, the potential downsides are minimized if you are pretty much exclusively using your system from within an X11 session and you are not shelling into remote systems or using the tty much.  But setting EDITOR is the only bit relevant to changing the 'e' key binding.  Using other keys (like return) will most likely use mime-types, and for those options xdg-mime settings would likely be relevant.

*note: if I'm being completely honest, I'd not find using a gui editor like mousepad in any contenxt to be ideal!  Learn vim!  I'm (mostly) joking; of all the gui text-editors I've found mousepad to be one of the most tolerable - but once I learned vim, I never wanted to ever use any gui editor again.

Umm... I already use vim and emacs. I also learned how to use vim and emacs. The vim tutorials made by distrotube is the best if you want to learn about vim.

Btw as a gui text editor I use Mousepad and geany. I like both. Geany has more features. Sometimes I need graphical IDE/text editor for programming because customizing vim (adding themes and stuff) is so hard and there is no guide on how to customize your vimrc sad . Geany is easier to use thats why I use geany smile cool

Last edited by RounakDutta (2022-06-06 17:20:52)

Offline

#13 2022-06-06 18:09:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Problems with nnn file manager

RounakDutta wrote:

The vim tutorials made by distrotube is the best ... customizing vim (adding themes and stuff) is so hard and there is no guide on how to customize your vimrc

You don't see a contradiction here?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB