Skip to content

Commit

Permalink
add an on-select command
Browse files Browse the repository at this point in the history
This command is executed whenever the selection changes.
  • Loading branch information
laktak committed Oct 10, 2022
1 parent 4968b1d commit 31db914
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 123 deletions.
12 changes: 5 additions & 7 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ func newApp(ui *ui, nav *nav) *app {
}

func (app *app) quit() {
if gOpts.history {
if err := app.writeHistory(); err != nil {
log.Printf("writing history file: %s", err)
}
if err := app.writeHistory(); err != nil {
log.Printf("writing history file: %s", err)
}
if !gSingleMode {
if err := remote(fmt.Sprintf("drop %d", gClientID)); err != nil {
Expand Down Expand Up @@ -407,7 +405,7 @@ func (app *app) loop() {
curr, err := app.nav.currFile()
if err == nil {
if d.path == app.nav.currDir().path {
app.ui.loadFile(app.nav, true)
app.ui.loadFile(app, true)
}
if d.path == curr.path {
app.ui.dirPrev = d
Expand Down Expand Up @@ -456,7 +454,7 @@ func (app *app) loop() {
app.ui.draw(app.nav)
case <-app.ticker.C:
app.nav.renew()
app.ui.loadFile(app.nav, false)
app.ui.loadFile(app, false)
app.ui.draw(app.nav)
}
}
Expand Down Expand Up @@ -528,7 +526,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
anyKey()
}

app.ui.loadFile(app.nav, true)
app.ui.loadFile(app, true)

switch prefix {
case "%":
Expand Down
5 changes: 5 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ The following special shell commands are used to customize the behavior of lf wh
delete
pre-cd
on-cd
on-select
on-quit
The following commands/keybindings are provided by default:
Expand Down Expand Up @@ -886,6 +887,10 @@ This shell command can be defined to be executed before changing a directory.
This shell command can be defined to be executed after changing a directory.
on-select
This shell command can be defined to be executed after the selection changes.
on-quit
This shell command can be defined to be executed before quit.
Expand Down
6 changes: 6 additions & 0 deletions docstring.go

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

Loading

0 comments on commit 31db914

Please sign in to comment.