You are not logged in.

#1 2022-10-26 15:47:29

hugsie
Member
Registered: 2018-01-26
Posts: 46

[solved] i3, terminator, zsh, nnn

I would like to bind a key in my i3 config that starts a terminator window running nnn.

Since nnn does not have a config file and relies on environment variables to activate plugins i am looking for a solution to load those variables when using my defined hotkey.
I figured i can just export those variables within my .zshrc.local and have terminator run nnn within a zsh command.

This is what i came up with for the i3 config.

bindsym $mod+F3 exec terminator -x "zsh -c 'nnn -R -e'"

It is working but neither the options "-R -e" are applied nor the environment variables from my .zshrc.local.

What am i missing?

Last edited by hugsie (2022-10-26 17:13:49)

Offline

#2 2022-10-26 16:02:24

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,690

Re: [solved] i3, terminator, zsh, nnn

Not sure I  understand what your command is supposed to do.  How about setting environmental variables like this:

bindsym $mod+F3 exec ENV1=foo ENV2=bar terminator -x nnn

?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2022-10-26 16:05:54

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

Re: [solved] i3, terminator, zsh, nnn

Or just use a wrapper script for nnn that sets / exports the variables then execs nnn (or optionally execs the terminal to run nnn).


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

Offline

#4 2022-10-26 16:17:05

hugsie
Member
Registered: 2018-01-26
Posts: 46

Re: [solved] i3, terminator, zsh, nnn

ewaller wrote:

Not sure I  understand what your command is supposed to do.  How about setting environmental variables like this:

bindsym $mod+F3 exec ENV1=foo ENV2=bar terminator -x nnn

?

Thanks, tried that doesnt work.


Trilby wrote:

Or just use a wrapper script for nnn that sets / exports the variables then execs nnn (or optionally execs the terminal to run nnn).

Thanks.

bindsym $mod+F3 exec terminator -e "~/start_nnn.sh"

This is the wrapper start_nnn.sh

#!/bin/bash
export NNN_FCOLORS='0000E6310000000000000000'

nnn -R -e

Directory colors are correctly applied but still the params "-R -e" are not working.

Just running ./start_nnn.sh is actually working as intended.

Last edited by hugsie (2022-10-26 16:19:23)

Offline

#5 2022-10-26 16:21:39

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

Re: [solved] i3, terminator, zsh, nnn

According to the man page, -R is to disable the "rollover" when scrolling to one end or the other.  And -e is to use the value of $VISUAL for editing text files.  Are these your intended results from those flags?  I know nothing of the former, but for the latter, what is the actual result?  Is VISUAL even set in that environment?  You could test this in the wrapper script:

#!/bin/sh

export NNN_FCOLORS=...
echo $VISUAL > /tmp/visual.value
export VISUAL
exec nnn -R -e

Then (after running it) check /tmp/visual.value.  Does it have the name of the editor you expected, or is it empty?

Last edited by Trilby (2022-10-26 16:22:35)


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

Offline

#6 2022-10-26 16:29:50

hugsie
Member
Registered: 2018-01-26
Posts: 46

Re: [solved] i3, terminator, zsh, nnn

/tmp/visual.value is empty.

I mistyped the options.
Its "-r -E" not the other way around.

But still does not work when being launched via i3 hotkey. I suspect terminator. But no clue where to debug

Last edited by hugsie (2022-10-26 16:36:44)

Offline

#7 2022-10-26 16:52:36

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,300

Re: [solved] i3, terminator, zsh, nnn

if /tmp/visual is empty then that means you are not exporting VISUAL or EDITOR for that matter in your i3 session.

What you probably want is either fix that or adjust your exec to

terminator -x zsh -ic "nnn -r -E" 

because what you are actually looking for is that your zshrc is being parsed before running nnn. the -i flag is what you've been missing which should enforce zsh to be interactive and thus parse the zshrc

If you pass a command to terminator directly it does not invoke your shell in the first place

Last edited by V1del (2022-10-26 16:56:32)

Offline

#8 2022-10-26 17:00:48

hugsie
Member
Registered: 2018-01-26
Posts: 46

Re: [solved] i3, terminator, zsh, nnn

terminator -x zsh -ic "nnn -r -E" 

Edit: Well, too early .... it only works from within the wrapper now when i have a terminal already opened. Without a running terminal my i3 hotkey does nothing .....

i3 config
bindsym $mod+F3 exec terminator -x "~/start_nnn.sh"

start_nnn.sh

#!/bin/bash
export NNN_FCOLORS='0000E6310000000000000000'

zsh -ic 'nnn -r -E'

Edit2:

ok, now its seems to be working.
i have to use -e with terminator to start the wrapper. Also i am exporting EDITOR=vim as well within the wrapper.

So the working combination is this:

bindsym $mod+F3 exec terminator -e "~/start_nnn.sh"

#!/bin/bash
export EDITOR=vim
export NNN_FCOLORS='0000E6310000000000000000'

nnn -r -E


Thanks for your help.

Last edited by hugsie (2022-10-26 17:13:02)

Offline

Board footer

Powered by FluxBB