diff options
author | Joe Lim <50560759+joelim-work@users.noreply.github.com> | 2024-11-06 12:12:12 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 12:12:12 +1100 |
commit | 670343a23f77c43ddeda6dd9b9419b4bdba61c78 (patch) | |
tree | 9b43035f60976dd29c6bdbaa3b4172a98c1243c0 | |
parent | 0b519870441671bda90be725ff64748d836c0684 (diff) |
Add `on-init` hook command (#1838)
-rw-r--r-- | client.go | 3 | ||||
-rw-r--r-- | doc.md | 5 | ||||
-rw-r--r-- | doc.txt | 6 | ||||
-rw-r--r-- | eval.go | 8 | ||||
-rw-r--r-- | lf.1 | 7 |
5 files changed, 27 insertions, 2 deletions
@@ -117,7 +117,7 @@ func readExpr() <-chan expr { ch := make(chan expr) go func() { - duration := 1 * time.Second + duration := 100 * time.Millisecond c, err := net.Dial(gSocketProt, gSocketPath) for err != nil { @@ -130,6 +130,7 @@ func readExpr() <-chan expr { fmt.Fprintf(c, "conn %d\n", gClientID) ch <- &callExpr{"sync", nil, 1} + ch <- &callExpr{"on-init", nil, 1} s := bufio.NewScanner(c) for s.Scan() { @@ -239,6 +239,7 @@ The following special shell commands are used to customize the behavior of lf wh on-cd on-focus-gained on-focus-lost + on-init on-select on-redraw on-quit @@ -1143,6 +1144,10 @@ This shell command can be defined to be executed when the terminal gains focus. This shell command can be defined to be executed when the terminal loses focus. +## on-init + +This shell command can be defined to be executed after initializing and connecting to the server. + ## on-select This shell command can be defined to be executed after the selection changes. @@ -230,6 +230,7 @@ of lf when defined: on-cd on-focus-gained on-focus-lost + on-init on-select on-redraw on-quit @@ -1262,6 +1263,11 @@ on-focus-lost This shell command can be defined to be executed when the terminal loses focus. +on-init + +This shell command can be defined to be executed after initializing and +connecting to the server. + on-select This shell command can be defined to be executed after the selection @@ -600,6 +600,12 @@ func onFocusLost(app *app) { } } +func onInit(app *app) { + if cmd, ok := gOpts.cmds["on-init"]; ok { + cmd.eval(app, nil) + } +} + func onRedraw(app *app) { if cmd, ok := gOpts.cmds["on-redraw"]; ok { cmd.eval(app, nil) @@ -1801,6 +1807,8 @@ func (e *callExpr) eval(app *app, args []string) { onFocusGained(app) case "on-focus-lost": onFocusLost(app) + case "on-init": + onInit(app) case "cmd-insert": if len(e.args) == 0 { return @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 2.11.4 .\" -.TH "LF" "1" "2024-11-01" "" "DOCUMENTATION" +.TH "LF" "1" "2024-11-06" "" "DOCUMENTATION" .hy .SH NAME .PP @@ -256,6 +256,7 @@ pre-cd on-cd on-focus-gained on-focus-lost +on-init on-select on-redraw on-quit @@ -1262,6 +1263,10 @@ focus. .PP This shell command can be defined to be executed when the terminal loses focus. +.SS on-init +.PP +This shell command can be defined to be executed after initializing and +connecting to the server. .SS on-select .PP This shell command can be defined to be executed after the selection |