diff --git a/doc.md b/doc.md index f97bddb1..6dab271e 100644 --- a/doc.md +++ b/doc.md @@ -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. diff --git a/doc.txt b/doc.txt index af1d2223..8939a8c3 100644 --- a/doc.txt +++ b/doc.txt @@ -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. diff --git a/lf.1 b/lf.1 index 07cab641..15dd1ee1 100644 --- a/lf.1 +++ b/lf.1 @@ -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 diff --git a/main.go b/main.go index d9cb5016..52b9cc85 100644 --- a/main.go +++ b/main.go @@ -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() }