diff options
author | Gokcehan <gokcehankara@gmail.com> | 2021-04-13 23:48:49 +0300 |
---|---|---|
committer | Gokcehan <gokcehankara@gmail.com> | 2021-04-13 23:48:49 +0300 |
commit | 4601e74d666ee1f5b41dd120587e131d0e546e9d (patch) | |
tree | 379144fbbfb0deab29ebd12e6e44c519cd332d76 | |
parent | c8f60623f3fd3f59d2469908d206e20dc296db72 (diff) |
export OLDPWD variable as the initial directoryr22
cc #601
-rw-r--r-- | doc.go | 5 | ||||
-rw-r--r-- | docstring.go | 5 | ||||
-rw-r--r-- | lf.1 | 7 | ||||
-rw-r--r-- | main.go | 6 |
4 files changed, 23 insertions, 0 deletions
@@ -144,6 +144,7 @@ The following environment variables are exported for shell commands: fx id PWD + OLDPWD LF_LEVEL OPENER EDITOR @@ -716,6 +717,10 @@ Id of the running client. Present working directory. + OLDPWD + +Initial working directory. + LF_LEVEL The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf. diff --git a/docstring.go b/docstring.go index 0983142..f077fd2 100644 --- a/docstring.go +++ b/docstring.go @@ -148,6 +148,7 @@ The following environment variables are exported for shell commands: fx id PWD + OLDPWD LF_LEVEL OPENER EDITOR @@ -768,6 +769,10 @@ Id of the running client. Present working directory. + OLDPWD + +Initial working directory. + LF_LEVEL The value of this variable is set to the current nesting level when you run @@ -164,6 +164,7 @@ The following environment variables are exported for shell commands: fx id PWD + OLDPWD LF_LEVEL OPENER EDITOR @@ -869,6 +870,12 @@ Id of the running client. Present working directory. .PP .EX + OLDPWD +.EE +.PP +Initial working directory. +.PP +.EX LF_LEVEL .EE .PP @@ -65,6 +65,12 @@ func exportEnvVars() { os.Setenv("PAGER", envPager) os.Setenv("SHELL", envShell) + dir, err := os.Getwd() + if err != nil { + fmt.Fprintf(os.Stderr, "%s\n", err) + } + os.Setenv("OLDPWD", dir) + level, err := strconv.Atoi(envLevel) if err != nil { log.Printf("reading lf level: %s", err) |