jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
19.3k stars 761 forks source link

Launch nnn with a keyboard shortcut #224

Closed juacq97 closed 5 years ago

juacq97 commented 5 years ago

When I run nnn from a keyboard shortcut, in my case, super + f executes termite -e nnn, then weird things happens. The files doesn't open with the xdg-open default and the export options seems doesn't load. If I run nnn normally from a terminal, all works normally. Any idea of how ,solve this? Thanks.

jarun commented 5 years ago

Please share the steps how you run nnn using a keyboard shortcut.

juacq97 commented 5 years ago

I'm ussing bspwm, so, in the sxhkdrc I have this:

#File Manager
super + f
       termite -e nnn

Then I press super + f and a terminal window with nnn running appears. If I press q the window closes.

I tried with rofi, in the run mode running termite -e nnn and I have the same issue. I tried with urxvt too, and nothing changes, the export variables doesn't load.

jarun commented 5 years ago

You need an executable wrapper script which your terminal has to execute instead of calling nnn directly.

$ cat nwrap
#!/usr/bin/env fish

export NNN_USE_EDITOR=1
export NNN_BMS="D:~/Downloads;n:~/GitHub/nnn;v:~/Videos;"
export NNN_CONTEXT_COLORS="1234"
export NNN_IDLE_TIMEOUT=900
export NNN_SCRIPT=/home/vaio/Downloads/packages/user-scripts
export NNN_PLAIN_FILTER=1
export NNN_NOTE='/home/vaio/.note'
export NNN_OPS_PROG=1
alias ncp="cat ~/.nnncp | tr '\0' '\n'"

export NNN_TMPFILE=/tmp/nnn
function n
        nnn -isl $argv

        if test -e "$NNN_TMPFILE"
                source "$NNN_TMPFILE"
                rm "$NNN_TMPFILE"
        end
end

n

Here's my command to start:

xfce4-terminal -e ./nwrap
jarun commented 5 years ago

Please feel free to award a star to the project and make a small donation if your budget permits. ;)

jarun commented 5 years ago

I have added a wiki page to setup nnn as the default file manager - https://github.com/jarun/nnn/wiki/nnn-as-default-file-manager

Can you please test this and confirm if it works? If you think something is missing OR something else works feel free to update the wiki page. It's editable for all now.

juacq97 commented 5 years ago

It works very well, I added a small section destined to be used in Tiling Window Manager and added a line to restore pywal if you use it, because when you start a TUI application outside the terminal, the color schemes are not loaded.

jarun commented 5 years ago

Sure! Thanks!