Export command line flags as environment variables (#2079)

This commit is contained in:
Joe Lim authored and GitHub committed 2025-08-07 15:59:13 +10:00
1 parent 42b36fd52c
commit 02156a3806
4 files changed
+25 -1

No files matched your search

+5
View File
@@ -236,6 +236,7 @@ The following environment variables are exported for shell commands:
lf
lf_{option}
lf_user_{option}
lf_flag_{flag}
lf_width
lf_height
lf_count
@@ -1167,6 +1168,10 @@ Value of the {option}.
Value of the user_{option}.
## lf_flag_{flag}
Value of the command line {flag}.
## lf_width, lf_height
Width/Height of the terminal.
+5
View File
@@ -226,6 +226,7 @@ The following environment variables are exported for shell commands:
lf
lf_{option}
lf_user_{option}
lf_flag_{flag}
lf_width
lf_height
lf_count
@@ -1283,6 +1284,10 @@ lf_user_{option}
Value of the user_{option}.
lf_flag_{flag}
Value of the command line {flag}.
lf_width, lf_height
Width/Height of the terminal.
+4 -1
View File
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.7.0.2
.\"
.TH "LF" "1" "2025\-08\-04" "r37" "DOCUMENTATION"
.TH "LF" "1" "2025\-08\-07" "r37" "DOCUMENTATION"
.SH NAME
lf \- terminal file manager
.SH SYNOPSIS
@@ -243,6 +243,7 @@ SHELL
lf
lf_{option}
lf_user_{option}
lf_flag_{flag}
lf_width
lf_height
lf_count
@@ -1108,6 +1109,8 @@ Otherwise, this is set to the string \f[CR]lf\f[R].
Value of the {option}.
.SS lf_user_{option}
Value of the user_{option}.
.SS lf_flag_{flag}
Value of the command line {flag}.
.SS lf_width, lf_height
Width/Height of the terminal.
.SS lf_count
+11
View File
@@ -89,6 +89,16 @@ func exportEnvVars() {
os.Setenv("LF_LEVEL", strconv.Itoa(level))
}
func exportFlags() {
os.Setenv("lf_flag_config", gConfigPath)
os.Setenv("lf_flag_last_dir_path", gLastDirPath)
os.Setenv("lf_flag_log", gLogPath)
os.Setenv("lf_flag_print_last_dir", strconv.FormatBool(gPrintLastDir))
os.Setenv("lf_flag_print_selection", strconv.FormatBool(gPrintSelection))
os.Setenv("lf_flag_selection_path", gSelectionPath)
os.Setenv("lf_flag_single", strconv.FormatBool(gSingleMode))
}
// used by exportOpts below
func fieldToString(field reflect.Value) string {
kind := field.Kind()
@@ -355,6 +365,7 @@ func main() {
}
exportEnvVars()
exportFlags()
run()
}