1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 11:19:47 +01:00

home-manager: Check VISUAL before EDITOR for editor

Check VISUAL for a visual editor before EDITOR, as per Unix convention
and as followed by Git, crontab, mutt, and other tools.
This commit is contained in:
Scott Stevenson 2024-02-05 22:22:43 +00:00 committed by Mikilio
parent 546ace0756
commit e910311c46
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
2 changed files with 10 additions and 6 deletions

View file

@ -97,7 +97,7 @@ Instantiate the configuration and print the resulting derivation\&.
.It Cm edit
.RS 16
Open the home configuration using the editor indicated by \fBEDITOR\fR\&.
Open the home configuration using the editor indicated by \fBVISUAL\fR or \fBEDITOR\fR\&.
.RE
.Pp

View file

@ -565,11 +565,15 @@ function presentNews() {
}
function doEdit() {
if [[ ! -v VISUAL || -z $VISUAL ]]; then
if [[ ! -v EDITOR || -z $EDITOR ]]; then
# shellcheck disable=2016
_i 'Please set the $EDITOR environment variable' >&2
_i 'Please set the $EDITOR or $VISUAL environment variable' >&2
return 1
fi
else
EDITOR=$VISUAL
fi
setConfigFile
@ -881,7 +885,7 @@ function doHelp() {
echo
echo " help Print this help"
echo
echo " edit Open the home configuration in \$EDITOR"
echo " edit Open the home configuration in \$VISUAL or \$EDITOR"
echo
echo " option OPTION.NAME"
echo " Inspect configuration option named OPTION.NAME."