Skip to content

Commit

Permalink
update readme with new events
Browse files Browse the repository at this point in the history
  • Loading branch information
MLFlexer committed Jul 23, 2024
1 parent 289dc5d commit d1fe2a8
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,34 @@ If you want your project switcher only to select projects from this list, but st
Adding the path as a part of the right-status can be done with the `smart_workspace_switcher.workspace_chosen` event which is emitted when choosing the workspace.

```lua
wezterm.on("smart_workspace_switcher.workspace_chosen", function(window, path)
wezterm.on("smart_workspace_switcher.workspace_switcher.chosen", function(window, path)
local base_path = string.gsub(path, "(.*[/\\])(.*)", "%2")
window:set_right_status(wezterm.format({
{ Foreground = { Color = colors.colors.ansi[5] } },
{ Text = base_path .. " " },
}))
end)

wezterm.on("smart_workspace_switcher.workspace_switcher.created", function(window, path)
local base_path = string.gsub(path, "(.*[/\\])(.*)", "%2")
window:set_right_status(wezterm.format({
{ Foreground = { Color = colors.colors.ansi[5] } },
{ Text = base_path .. " " },
}))
end)

```

#### Callbacks when switching workspace
Use the `smart_workspace_switcher.workspace_chosen` event which is emitted when choosing the workspace to add a callback function.
#### Events
Use the events which are emitted when choosing the workspace to add a callback function. The following events are available:
* `smart_workspace_switcher.workspace_switcher.start` - when the fuzzy finder starts
* `smart_workspace_switcher.workspace_switcher.selected` - when a element is selected
* `smart_workspace_switcher.workspace_switcher.created` - after a new workspace is created and switched to upon selecting
* `smart_workspace_switcher.workspace_switcher.chosen` - after switching to a new workspace upon selecting

See example for use below:
```lua
wezterm.on("smart_workspace_switcher.workspace_chosen", function(window, path)
wezterm.on("smart_workspace_switcher.workspace_switcher.chosen", function(window, path)
wezterm.log_info("THIS IS EMITTED FROM THE CALLBACK")
end)
```
Expand Down

0 comments on commit d1fe2a8

Please sign in to comment.