excalibur1234/pacui

fix no editor for pacaur in tmux

Closed this issue · 5 comments

here a suggested solution from @Chrysostomus:
https://forum.manjaro.org/t/pacui-a-simple-bash-frontend-for-pacman-and-yaourt-pacaur/677/269

# check, whether pacaur is installed, but its config files does not exist and $EDITOR variable does not exist
if [[ -e /usr/bin/pacaur ]] && ! [[ -e $XDG_CONFIG_HOME/pacaur/config ]] && ! [[ -z $EDITOR ]]
then
    # create directory and export "editor='${EDITOR:-nano}'" to config file (this is needed for tmux to work, if the conditions above are met)
    mkdir -p $XDG_CONFIG_HOME/pacaur/
    echo "editor='${EDITOR:-nano}'" >> $XDG_CONFIG_HOME/pacaur/config
fi

Alternatively one could try to make the tmux window source the profile. But I'm not sure how to go about it. This solution is rather simple.

yes your fix is simple.

i see that "config" file is part of the "pacaur" package and always gets installed. this means that your fix will never be applied.
this should work, though:

# check, whether pacaur and vi is installed and $EDITOR variable does not exist. in this case - when used with tmux - pacaur sometimes does not find an editor to use. then the --preview window in fzf does not show any package information.
if [[ -e /usr/bin/pacaur ]] && ! [[ -e /usr/bin/vi ]] && ! [[ -z $EDITOR ]]
then
    # export "editor='${EDITOR:-nano}'" to config file. '${EDITOR:-nano}'" outputs "nano", if there is no $EDITOR variable set.
    echo "editor='${EDITOR:-nano}'" >> $XDG_CONFIG_HOME/pacaur/config
fi

No it is not, $XDG_CONFIG_HOME is ~/.config/ and pacaur does not install anything there. Also, your version fails if there is no $XDG_CONFIG_HOME/pacaur.

But checking for vi is a good idea. How about checking editor with

$(grep -q 'editor=' $XDG_CONFIG_HOME/pacaur/config)

? This would account for the case where file exists and the editor is not set.

you are right.
i mixed up $XDG_CONFIG_DIRS and $XDG_CONFIG_HOME.
my mistake.

so, your original fix should work (with some addition code comments and maybe a check for vi).

i will wait for #5 before i integrate your fix, because i do not want to confuse @thefallenrat with new code (and him needing to do a "git pull --rebase").

thanks so far!

this was fixed here: a099f41