diff --git a/src/cli/init.go b/src/cli/init.go index 9e3ef80..4c0e01e 100644 --- a/src/cli/init.go +++ b/src/cli/init.go @@ -17,7 +17,7 @@ func TempInitCli() { } // textEditor - textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"vi\"):") + textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"" + offline.FallbackEditor + "\"):") offline.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID}) } diff --git a/src/offline/init.go b/src/offline/init.go index 51f4180..08f3036 100644 --- a/src/offline/init.go +++ b/src/offline/init.go @@ -16,9 +16,9 @@ func TempInit(configFileMap map[string]string) { // ensure textEditor is set if configFileMap["textEditor"] == "" { - textEditor := os.Getenv("EDITOR") - if textEditor == "" { - textEditor = fallbackEditor + textEditor, editorEnvPresent := os.LookupEnv("EDITOR") + if !editorEnvPresent { + textEditor = FallbackEditor } configFileMap["textEditor"] = textEditor } diff --git a/src/offline/initUNIX.go b/src/offline/initUNIX.go index 1986bd2..d97c1b1 100644 --- a/src/offline/initUNIX.go +++ b/src/offline/initUNIX.go @@ -7,7 +7,7 @@ import ( "os" ) -const fallbackEditor = "vi" // vi is pre-installed on most UNIX systems +const FallbackEditor = "vi" // vi is pre-installed on most UNIX systems // dirInit creates the libmutton directories func dirInit() { diff --git a/src/offline/initWIN.go b/src/offline/initWIN.go index 3f4ab9c..287e15e 100644 --- a/src/offline/initWIN.go +++ b/src/offline/initWIN.go @@ -7,7 +7,7 @@ import ( "os" ) -const fallbackEditor = "nvim" // since there is no pre-installed CLI editor on Windows, default to the most popular one +const FallbackEditor = "nvim" // since there is no pre-installed CLI editor on Windows, default to the most popular one // dirInit creates the libmutton directories func dirInit() {