Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dynamic Window Title

Daniel Fichtinger edited this pageMay 20, 2025 ·1 revision

For those of us that don't use Xorg, or can't use lemonbar, the advice inBar won't work. However, we can achieve a similar effect by dynamically changing the title of our window.

The window title is prime real estate for helpful information. By default, it mirrors exactly the modeline. However, this is redundant, and we could use the space to display a buffer list instead. Depending on your environment, the terminal's title may be displayed in a prominent and readable position, making it an excellent candidate for displaying a buffer list.

This solution requires commit7e05dc8, which at the time of writing is not included in the latest release,2024.05.18. The reason is that we need theterminal_title key of theui_options map. Before this, it was not possible to change the title of the ncurses window.

Here's an example that formats a buffer list and sets it to the window title. It excludes the*debug* buffer because that's not a buffer you can switch to by cycling. It surrounds the currently active buffer in brackets, like so:[1 *scratch* ] 2 kakrc 3 autoload/foobar.kak

define-command -hidden bar-buflist %{evaluate-commands%sh{        list=''whileread buf;doif ["$buf"='*debug*' ];thencontinuefi            index=$(($index+1))if ["$buf"="$kak_bufname" ];then                cur=$(printf'[%s %s]'"$index""$buf")else                cur=$(printf'%s %s'"$index""$buf")fi            list="$list$cur"done<<<$(printf'%s\n'"$kak_buflist"| tr'''\n')        title="$list -$kak_client@[$kak_session]"printf"set-option -add global ui_options %%{terminal_title=%s}""$title"    }}

This is just an example; you can (and should) decide exactly what information you want to display for yourself. You could set this command to execute on theWinDisplay event, ensuring that your buffer list is always updated:

hookglobalWinDisplay .* bar-buflist

The result is a buffer list that integrates quite nicely with your environment, without taking up unnecessary space, and doesn't explicitly rely on external tools, which keeps it portable. The following example shows how it looks in the Niri window manager with the window title displayed on Waybar:

image

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp