help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make GUI applications inherit PATH


From: Fernando Basso
Subject: Re: How to make GUI applications inherit PATH
Date: Tue, 9 Mar 2021 16:31:56 -0300

On Tue, Mar 09, 2021 at 02:07:51PM +0000, Chris Elvidge wrote:
> On 09/03/2021 12:37 pm, Fernando Basso wrote:
> > I am creating a launcher in Xfce4 to run `gvim -f'. When I click the
> > launcher, gvim opens and complains it cannot find nodejs, which I
> > install through nvm (node version manager), which is added to `PATH' in
> > `~/.bashrc'.
> > 
> > I tried creating a wrapper script, something like this:
> > 
> >     #!/usr/bin/env -S bash --login
> >     gvim -f "$@"
> > 
> > It still doesn't pass `PATH' as configured in my `~/.bashrc' to gvim. (I
> > passed `--login' because according to `man bash' it would cause
> > `~/.bashrc' to be read).
> > 
> > If I run that wrapper from the terminal (with bash as the shell), then
> > it works (I can `:echo $PATH' from gvim and see all my configured
> > paths), just like if I had run `gvim -f' directly. If I run that wrapper
> > script from gmrun or xfce4-appfinder then again `PATH' inside gvim
> > contains only some default system directories and not my configured
> > paths.
> > 
> > I have noticed something similar to Zim Wiki, which seems to inherit my
> > shell exported stuff if opened from the terminal, but not if opened from
> > some GUI launcher.
> > 
> > If these applications inherit the `PATH' when I run them directly from
> > the terminal, I guess it should work from wrapper scripts if written
> > correctly.
> > 
> > So my question is how could I create a bash wrapper script that would
> > cause these GUI apps to inherit exported `PATH' from my bash config
> > files?
> > 
> > 
> > 
> > 
> 
> Have you exported the PATH variable in .bashrc?
> 
> -- 
> Chris Elvidge
> England

Yes, I have done so.

    $ sed 's/:/\n/g' <<< $(printf '%s' "$PATH")
    /home/fernandobasso/.nvm/versions/node/v14.16.0/bin
    /home/fernandobasso/bin
    /usr/local/sbin
    /usr/local/bin
    /usr/sbin
    /usr/bin
    /sbin
    /bin
    /usr/games
    /usr/local/games
    /snap/bin
    /home/fernandobasso/bin
    /home/fernandobasso/.local/bin
    /home/fernandobasso/Projects/dotfiles/bin
    /home/fernandobasso/local/bin
    /home/fernandobasso/.deno/bin
    /home/fernandobasso/.rvm/bin

But if from inside GVim, I do:

    <insert mode>^r=substitute($PATH, ':', '\r', 'g')

Then I get this placed on the buffer:

    /home/fernandobasso/bin
    /usr/local/sbin
    /usr/local/bin
    /usr/sbin
    /usr/bin
    /sbin
    /bin
    /usr/games
    /usr/local/games
    /snap/bin

I'm not sure why the first entry is there (`~/bin'). Perhaps my system
adds `$USER/bin' to `PATH' by default.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]