From 3ae67fc3612e629121746844f86f42ed15b3fff3 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Sun, 2 Apr 2023 02:40:28 +1000 Subject: [PATCH] Export count as a variable when running commands (#1187) --- doc.go | 5 +++++ docstring.go | 5 +++++ eval.go | 2 ++ lf.1 | 7 +++++++ 4 files changed, 19 insertions(+) diff --git a/doc.go b/doc.go index f5f80563..d33bb323 100644 --- a/doc.go +++ b/doc.go @@ -186,6 +186,7 @@ The following environment variables are exported for shell commands: lf_user_{option} lf_width lf_height + lf_count The following special shell commands are used to customize the behavior of lf when defined: @@ -959,6 +960,10 @@ Value of the user_{option}. Width/Height of the terminal. + lf_count + +Value of the count associated with the current command. + # Special Commands This section shows information about special shell commands. diff --git a/docstring.go b/docstring.go index fde45403..8d7428c8 100644 --- a/docstring.go +++ b/docstring.go @@ -189,6 +189,7 @@ The following environment variables are exported for shell commands: lf_user_{option} lf_width lf_height + lf_count The following special shell commands are used to customize the behavior of lf when defined: @@ -1026,6 +1027,10 @@ Value of the user_{option}. Width/Height of the terminal. + lf_count + +Value of the count associated with the current command. + # Special Commands This section shows information about special shell commands. diff --git a/eval.go b/eval.go index e628218a..4e9ddc6a 100644 --- a/eval.go +++ b/eval.go @@ -1263,6 +1263,8 @@ func insert(app *app, arg string) { } func (e *callExpr) eval(app *app, args []string) { + os.Setenv("lf_count", strconv.Itoa(e.count)) + switch e.name { case "up": if !app.nav.init { diff --git a/lf.1 b/lf.1 index 3f5e5cbd..d454bdf5 100644 --- a/lf.1 +++ b/lf.1 @@ -207,6 +207,7 @@ The following environment variables are exported for shell commands: lf_user_{option} lf_width lf_height + lf_count .EE .PP The following special shell commands are used to customize the behavior of lf when defined: @@ -1167,6 +1168,12 @@ Value of the user_{option}. .EE .PP Width/Height of the terminal. +.PP +.EX + lf_count +.EE +.PP +Value of the count associated with the current command. .SH SPECIAL COMMANDS This section shows information about special shell commands. .PP