diff --git a/docs/changelog.md b/docs/changelog.md index 31ff371bc..8e4c367c2 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -22,6 +22,7 @@ As features stabilize some brief notes about them will accumulate here. * `Symbols Nerd Font Mono` is now bundled with WezTerm and is included as a default fallback font. This means that you may use any of the glyphs available in the [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts) collection with any font without patching fonts and without explicitly adding that font to your fallback list. Pomicons have an unclear license for distribution and are excluded from this bundled font, however, you may manually install the font with those icons from the Nerd Font site itself and it will take precedence over the bundled font. This font replaces the older `PowerlineExtraSymbols` font. [#1521](https://github.com/wez/wezterm/issues/1521). * [wezterm.nerdfonts](config/lua/wezterm/nerdfonts.md) as a convenient way to resolve Nerd Fonts glyphs by name in your config file * [ShowLauncherArgs](config/lua/keyassignment/ShowLauncherArgs.md) key assignment to show the launcher scoped to certain items, or to launch it directly in fuzzy matching mode +* Workspaces. Follow work in progress on [#1531](https://github.com/wez/wezterm/issues/1531) and [#1322](https://github.com/wez/wezterm/discussions/1322)! [window:active_workspace()](config/lua/window/active_workspace.md) #### Changed diff --git a/docs/config/lua/window/active_workspace.md b/docs/config/lua/window/active_workspace.md new file mode 100644 index 000000000..36faf6bf2 --- /dev/null +++ b/docs/config/lua/window/active_workspace.md @@ -0,0 +1,22 @@ +# window:active_workspace() + +*Since: nightly builds only* + +Returns the name of the active workspace. + +This example demonstrates using the launcher menu to select and create workspaces, +and how the workspace can be shown in the right status area. + +```lua +local wezterm = require 'wezterm' + +wezterm.on("update-right-status", function(window, pane) + window:set_right_status(window:active_workspace()) +end) + +return { + keys = { + {key="9", mods="ALT", action=wezterm.action{ShowLauncherArgs={flags="FUZZY|WORKSPACES"}}}, + }, +} +``` diff --git a/wezterm-gui/src/scripting/guiwin.rs b/wezterm-gui/src/scripting/guiwin.rs index d27a171fa..dddcb2f4f 100644 --- a/wezterm-gui/src/scripting/guiwin.rs +++ b/wezterm-gui/src/scripting/guiwin.rs @@ -7,6 +7,7 @@ use config::keyassignment::KeyAssignment; use luahelper::*; use mlua::{UserData, UserDataMethods}; use mux::window::WindowId as MuxWindowId; +use mux::Mux; use serde::*; use wezterm_toast_notification::ToastNotification; use window::{Connection, ConnectionOps, DeadKeyStatus, WindowOps, WindowState}; @@ -164,5 +165,11 @@ impl UserData for GuiWin { Ok(result) }); + methods.add_method("active_workspace", |_, _, _: ()| { + let mux = Mux::get() + .ok_or_else(|| anyhow::anyhow!("must be called on main thread")) + .map_err(luaerr)?; + Ok(mux.active_workspace().to_string()) + }); } }