|
| 1 | +# `pane:get_metadata()` |
| 2 | + |
| 3 | +*Since: nightly builds only* |
| 4 | + |
| 5 | +Returns metadata about a pane. The return value depends on the instance of the |
| 6 | +underlying pane. If the pane doesn't support this method, `nil` will be returned. |
| 7 | +Otherwise, the value is a lua table with the metadata contained in table fields. |
| 8 | + |
| 9 | +To consume this value, it is recommend to use logic like this to obtain a table |
| 10 | +value even if the pane doesn't support this method: |
| 11 | + |
| 12 | +```lua |
| 13 | +local meta = pane:get_metadata() or {} |
| 14 | +``` |
| 15 | + |
| 16 | +The following metadata keys may be present: |
| 17 | + |
| 18 | +## password_input |
| 19 | + |
| 20 | +A boolean value that is populated only for local panes. |
| 21 | +It is set to true if it appears as though the local PTY is |
| 22 | +configured for password entry (local echo disabled, canonical |
| 23 | +input mode enabled). |
| 24 | + |
| 25 | +This example demonstrates how to change the color scheme |
| 26 | +to exaggerate when a password is being input: |
| 27 | + |
| 28 | +```lua |
| 29 | +local wezterm = require 'wezterm' |
| 30 | + |
| 31 | +wezterm.on('update-status', function(window, pane) |
| 32 | + local meta = pane:get_metadata() or {} |
| 33 | + local overrides = window:get_config_overrides() or {} |
| 34 | + if meta.password_input then |
| 35 | + overrides.color_scheme = 'Red Alert' |
| 36 | + else |
| 37 | + overrides.color_scheme = nil |
| 38 | + end |
| 39 | + window:set_config_overrides(overrides) |
| 40 | +end) |
| 41 | + |
| 42 | +return {} |
| 43 | +``` |
| 44 | + |
| 45 | +## is_tardy |
| 46 | + |
| 47 | +A boolean value that is populated only for multiplexer client panes. |
| 48 | +It is set to true if wezterm is waiting for a response from the multiplexer |
| 49 | +server. |
| 50 | + |
| 51 | +This can be used in conjunction with `since_last_response_ms` below. |
| 52 | + |
| 53 | +## since_last_response_ms |
| 54 | + |
| 55 | +An integer value that is populated only for multiplexer client panes. |
| 56 | +It is set to the number of elapsed milliseconds since the most recent |
| 57 | +response from the multiplexer server. |
| 58 | + |
| 59 | +This example shows how to put mux latency information into the status area: |
| 60 | + |
| 61 | +```lua |
| 62 | +local wezterm = require 'wezterm' |
| 63 | + |
| 64 | +wezterm.on('update-status', function(window, pane) |
| 65 | + local meta = pane:get_metadata() or {} |
| 66 | + if meta.is_tardy then |
| 67 | + local secs = meta.since_last_response_ms / 1000.0 |
| 68 | + window:set_right_status(string.format('tardy: %5.1fs⏳', secs)) |
| 69 | + end |
| 70 | +end) |
| 71 | + |
| 72 | +return {} |
| 73 | +``` |
| 74 | + |
0 commit comments