summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGokcehan <gokcehankara@gmail.com>2021-04-13 23:48:49 +0300
committerGokcehan <gokcehankara@gmail.com>2021-04-13 23:48:49 +0300
commit4601e74d666ee1f5b41dd120587e131d0e546e9d (patch)
tree379144fbbfb0deab29ebd12e6e44c519cd332d76
parentc8f60623f3fd3f59d2469908d206e20dc296db72 (diff)
export OLDPWD variable as the initial directoryr22
cc #601
-rw-r--r--doc.go5
-rw-r--r--docstring.go5
-rw-r--r--lf.17
-rw-r--r--main.go6
4 files changed, 23 insertions, 0 deletions
diff --git a/doc.go b/doc.go
index 806600e..43e7b99 100644
--- a/doc.go
+++ b/doc.go
@@ -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
diff --git a/lf.1 b/lf.1
index d215363..74715ae 100644
--- a/lf.1
+++ b/lf.1
@@ -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
diff --git a/main.go b/main.go
index 48dcd2d..25aae79 100644
--- a/main.go
+++ b/main.go
@@ -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)