Improvements related to the config location and spawning the editor

Via https://linuxfr.org/nodes/134968/comments/1952011
This commit is contained in:
Gil Cot 2024-02-26 08:37:15 +01:00 committed by Raphaël Jakse
parent f186757e30
commit d23121e0c3
1 changed files with 7 additions and 8 deletions

15
L
View File

@ -22,7 +22,7 @@
set -e
CONFIG_FILE="${HOME}/.config/Ljournalrc";
CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/Ljournalrc"
if [ ! -f "${CONFIG_FILE}" ]; then
mkdir -p "$(dirname "$CONFIG_FILE")"
@ -58,13 +58,12 @@ fi
if [ "$1" = "e" ]; then
if [ -z "$EDITOR" ]; then
if [ -f "$(which nano)" ]; then
EDITOR=nano
elif [ -f "$(which vim)" ]; then
EDITOR=vim
elif [ -f "$(which emacs)" ]; then
EDITOR=emacs
fi
for prog in 'nano' 'jed' 'jove' 'vim' 'nvim' 'emacs' ; do
if command -v $prog >/dev/null; then
EDITOR=$prog
break
fi
done
fi
exec "$EDITOR" "${JOURNAL_FILE}"
fi