feat: support cd - (#2693)

* feat: support `cd -`

* docs: add documentation

* docs: update `CHANGELOG.md`
This commit is contained in:
CatsDeservePets authored and GitHub committed 2026-10-01 02:59:29 +02:00
1 parent 1f31d6634e
commit 20c85c9477
5 files changed
+18 -3

No files matched your search

+4
View File
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## Unreleased
### Added
- The `cd` command now supports `-` to change to the previous directory (#2693).
### Fixed
- Dead client connections no longer prevent the `quit` server command from terminating the server (#2643).
+1
View File
@@ -674,6 +674,7 @@ Print given arguments to the message line at the bottom as `errorfmt` and also t
## cd
Change the working directory to the given argument.
If the argument is `-`, change to the previous directory stored in the special bookmark `'`.
## select
+2 -1
View File
@@ -707,7 +707,8 @@ also to the log file.
cd
Change the working directory to the given argument.
Change the working directory to the given argument. If the argument is
-, change to the previous directory stored in the special bookmark '.
select
+8 -1
View File
@@ -989,13 +989,20 @@ func insert(app *app, arg string) {
}
func cd(app *app, path string) error {
wd := app.nav.currDir().path
if path == "-" {
prev, ok := app.nav.marks["'"]
if !ok {
return errors.New("no previous directory")
}
path = prev
}
path, err := filepath.Abs(replaceTilde(path))
if err != nil {
return fmt.Errorf("getting absolute path: %w", err)
}
wd := app.nav.currDir().path
if path == wd {
return nil
}
+3 -1
View File
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.7.0.2
.\"
.TH "LF" "1" "2026\-08\-11" "r43" "DOCUMENTATION"
.TH "LF" "1" "2026\-10\-01" "r43" "DOCUMENTATION"
.SH NAME
lf \- terminal file manager
.SH SYNOPSIS
@@ -676,6 +676,8 @@ Print given arguments to the message line at the bottom as
\f[CR]errorfmt\f[R] and also to the log file.
.SS cd
Change the working directory to the given argument.
If the argument is \f[CR]\-\f[R], change to the previous directory
stored in the special bookmark \f[CR]\(aq\f[R].
.SS select
Change the current file selection to the given argument.
.SS source