diff --git a/doc.go b/doc.go index 155908f6..03599ce7 100644 --- a/doc.go +++ b/doc.go @@ -927,19 +927,23 @@ For example, with POSIX shells, you can use '[ -n "$LF_LEVEL" ] && PS1="$PS1""(l OPENER -If this variable is set in the environment, use the same value, otherwise set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. EDITOR -If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on Unix, 'notepad' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'vi' on Unix, 'notepad' in Windows. PAGER -If this variable is set in the environment, use the same value, otherwise set the value to 'less' on Unix, 'more' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'less' on Unix, 'more' in Windows. SHELL -If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on Unix, 'cmd' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'sh' on Unix, 'cmd' in Windows. + + lf + +Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string 'lf'. lf_{option} diff --git a/docstring.go b/docstring.go index 979f85d6..0104fd31 100644 --- a/docstring.go +++ b/docstring.go @@ -990,23 +990,28 @@ $LF_LEVEL) "' in your shell configuration file (e.g. '~/.bashrc'). OPENER -If this variable is set in the environment, use the same value, otherwise set -the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. +If this variable is set in the environment, use the same value. Otherwise, +this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. EDITOR -If this variable is set in the environment, use the same value, otherwise set -the value to 'vi' on Unix, 'notepad' in Windows. +If this variable is set in the environment, use the same value. Otherwise, +this is set to 'vi' on Unix, 'notepad' in Windows. PAGER -If this variable is set in the environment, use the same value, otherwise set -the value to 'less' on Unix, 'more' in Windows. +If this variable is set in the environment, use the same value. Otherwise, +this is set to 'less' on Unix, 'more' in Windows. SHELL -If this variable is set in the environment, use the same value, otherwise set -the value to 'sh' on Unix, 'cmd' in Windows. +If this variable is set in the environment, use the same value. Otherwise, +this is set to 'sh' on Unix, 'cmd' in Windows. + + lf + +Absolute path to the currently running lf binary, if it can be found. Otherwise, +this is set to the string 'lf'. lf_{option} diff --git a/lf.1 b/lf.1 index 30414c4f..9506166a 100644 --- a/lf.1 +++ b/lf.1 @@ -1122,25 +1122,31 @@ The value of this variable is set to the current nesting level when you run lf f OPENER .EE .PP -If this variable is set in the environment, use the same value, otherwise set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. .PP .EX EDITOR .EE .PP -If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on Unix, 'notepad' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'vi' on Unix, 'notepad' in Windows. .PP .EX PAGER .EE .PP -If this variable is set in the environment, use the same value, otherwise set the value to 'less' on Unix, 'more' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'less' on Unix, 'more' in Windows. .PP .EX SHELL .EE .PP -If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on Unix, 'cmd' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to 'sh' on Unix, 'cmd' in Windows. +.PP +.EX + lf +.EE +.PP +Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string 'lf'. .PP .EX lf_{option} diff --git a/main.go b/main.go index 301e8b4f..24f37b11 100644 --- a/main.go +++ b/main.go @@ -79,6 +79,13 @@ func exportEnvVars() { level++ os.Setenv("LF_LEVEL", strconv.Itoa(level)) + + lfPath, err := os.Executable() + if err != nil { + log.Printf("getting path to lf binary: %s", err) + lfPath = "lf" + } + os.Setenv("lf", lfPath) } // used by exportOpts below diff --git a/os.go b/os.go index 222c0bf1..75f6ea9f 100644 --- a/os.go +++ b/os.go @@ -159,7 +159,7 @@ func setDefaults() { gOpts.keys["i"] = &execExpr{"$", `$PAGER "$f"`} gOpts.keys["w"] = &execExpr{"$", "$SHELL"} - gOpts.cmds["doc"] = &execExpr{"$", "lf -doc | $PAGER"} + gOpts.cmds["doc"] = &execExpr{"$", `"$lf" -doc | $PAGER`} gOpts.keys[""] = &callExpr{"doc", nil, 1} } diff --git a/os_windows.go b/os_windows.go index 1852c869..4c635fa5 100644 --- a/os_windows.go +++ b/os_windows.go @@ -115,7 +115,7 @@ func setDefaults() { gOpts.keys["i"] = &execExpr{"!", "%PAGER% %f%"} gOpts.keys["w"] = &execExpr{"$", "%SHELL%"} - gOpts.cmds["doc"] = &execExpr{"!", "lf -doc | %PAGER%"} + gOpts.cmds["doc"] = &execExpr{"!", "%lf% -doc | %PAGER%"} gOpts.keys[""] = &callExpr{"doc", nil, 1} }