Skip to content

Commit

Permalink
export OLDPWD variable as the initial directory
Browse files Browse the repository at this point in the history
cc #601
  • Loading branch information
gokcehan committed Apr 13, 2021
1 parent c8f6062 commit 4601e74
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ The following environment variables are exported for shell commands:
fx
id
PWD
OLDPWD
LF_LEVEL
OPENER
EDITOR
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions docstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ The following environment variables are exported for shell commands:
fx
id
PWD
OLDPWD
LF_LEVEL
OPENER
EDITOR
Expand Down Expand Up @@ -868,6 +869,12 @@ Id of the running client.
.PP
Present working directory.
.PP
.EX
OLDPWD
.EE
.PP
Initial working directory.
.PP
.EX
LF_LEVEL
.EE
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4601e74

Please sign in to comment.