Skip to content

Commit

Permalink
Add support for window name
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-francisco committed Jul 26, 2024
1 parent 876715a commit 91cd9c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lua/tmux-status/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
---@field icon_bell string
---@field icon_mute string
---@field icon_activity string
---@field text "dir"|"name"

---@class TmuxStatusComponentSession
---@field icon string
Expand All @@ -33,6 +34,7 @@ M.default_options = {
icon_bell = "",
icon_mute = "",
icon_activity = "",
text = "dir"
},
session = {
icon = ""
Expand Down
8 changes: 7 additions & 1 deletion lua/tmux-status/utils/tmux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

local split = require('tmux-status.utils.str').split

---@type table<"dir"|"name", string>
local text_map = {
dir = "b:pane_current_path",
name = "window_name",
}

local M = {}

---@type string?
Expand Down Expand Up @@ -34,7 +40,7 @@ function M.list_windows(opts)
'tmux',
'list-windows',
'-F',
"#{s|^" .. M._USER .. "|~|:#{b:pane_current_path}}#{s/!/ " .. opts.icon_bell .. "/:#{s/~/ " .. opts.icon_mute .. "/:#{s/M/ " .. opts.icon_mark .. "/:#{s/Z/ " .. opts.icon_zoom .. "/:#{s/#/ " .. opts.icon_activity .. "/:window_flags}}}}}",
"#{s|^" .. M._USER .. "|~|:#{" .. text_map[opts.text] .. "}}#{s/!/ " .. opts.icon_bell .. "/:#{s/~/ " .. opts.icon_mute .. "/:#{s/M/ " .. opts.icon_mark .. "/:#{s/Z/ " .. opts.icon_zoom .. "/:#{s/#/ " .. opts.icon_activity .. "/:window_flags}}}}}",
},
{ text = true },
function (output)
Expand Down

0 comments on commit 91cd9c2

Please sign in to comment.