excalibur1234 / pacui

Bash script providing advanced Pacman and Yay/Pikaur/Aurman/Pakku/Trizen/Pacaur/Pamac-cli functionality in a simple UI
GNU General Public License v3.0
169 stars 13 forks source link

fix no editor for pacaur in tmux #8

Closed excalibur1234 closed 7 years ago

excalibur1234 commented 7 years ago

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
Chrysostomus commented 7 years ago

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.

excalibur1234 commented 7 years ago

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
Chrysostomus commented 7 years ago

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.

excalibur1234 commented 7 years ago

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 https://github.com/excalibur1234/pacui/issues/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!

excalibur1234 commented 7 years ago

this was fixed here: a099f412346a8a915b5335ef227170c85b913547