Improvements related to the config location and spawning the editor
Via https://linuxfr.org/nodes/134968/comments/1952011
This commit is contained in:
parent
f186757e30
commit
d23121e0c3
15
L
15
L
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue