From 629a4f85b29b53d167b332e228c10ef1babe1740 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Sun, 17 Jul 2022 22:07:29 +0100 Subject: [PATCH] Handle Flatpak of Vim --- roles/home-cli/files/bashrc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/roles/home-cli/files/bashrc b/roles/home-cli/files/bashrc index bb4d856..98817bb 100644 --- a/roles/home-cli/files/bashrc +++ b/roles/home-cli/files/bashrc @@ -74,9 +74,26 @@ then export GPG_TTY=$(tty) fi -if test -x /usr/bin/vim +# Set EDITOR to vim or vi. +if test -x ${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/app/org.vim.Vim/current/active/export/bin/org.vim.Vim +then + export EDITOR="${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/app/org.vim.Vim/current/active/export/bin/org.vim.Vim -f" +elif test -x /usr/bin/vim then export EDITOR="/usr/bin/vim -f" +else + export EDITOR=vi +fi + +# Alias vi to vim if it is installed. +if test -x ${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/app/org.vim.Vim/current/active/export/bin/org.vim.Vim +then + alias vi=${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/app/org.vim.Vim/current/active/export/bin/org.vim.Vim +elif test -x /usr/bin/vim +then + alias vi=/usr/bin/vim +else + alias vim=vi fi if [ ${XDG_CURRENT_DESKTOP:-unknown} == GNOME ] @@ -122,14 +139,6 @@ alias zlu="zypper list-updates" alias en="LANG=en_GB.UTF-8" alias fr="LANG=fr_FR.UTF-8" -# Alias vi to vim if it is installed. -if [ -x /usr/bin/vim ] -then - alias vi=vim -else - alias vim=vi -fi - # Alias dig to drill if dig is not installed. if [ -x /usr/bin/drill ] && ! [ -x /usr/bin/dig ] then