liquidprompt / liquidprompt

A full-featured & carefully designed adaptive prompt for Bash & Zsh
https://liquidprompt.readthedocs.io/
GNU Affero General Public License v3.0
4.46k stars 423 forks source link

Multiplexer session names #726

Open nojhan opened 1 year ago

nojhan commented 1 year ago

Display terminal multiplexer (screen/tmux) session names.

Description

Display the list of sessions having a name (i.e. not just a number). This may be displayed near the jobs section (within parentheses right after the d counter?) and only for detached ones (the currently attached session surely displays its name in some status bar).

Should probably be disabled by default.

How will this be useful?

Important sessions (long jobs, services, etc.) tend to be named, hence being able to spot them rapidly is important.

Rycieos commented 1 year ago

Good idea, I would find this useful.

I do not know how to gather this information though. The only way we have currently to count detached sessions is to ask the tool to print them all, and we count the lines. Both tmux and screen will show the custom names there, but show no way to actually detect if the name is a custom one or not. We would have to do some hacky regex to figure it out, and that leads to edge cases since we would be guessing.

Open to ideas.

nojhan commented 1 year ago

tmux' default names are just numbers (same as the unique ID), so it should be fairly easy to just not count those sessions, even if the user did set up a number as a custom name.

screen is a bit tricky, as it displays <PID>.pts-<ID>.<host> for defaults, and <PID>.<name> for named sessions. But I think it would also be fair enough to just discard sessions with "pts-" in their ID.

As for the display, I think we should use superscript numbers: ⁰¹²³⁴⁵⁶⁷⁸⁹. This would give something like: « 2d³ » or « 2³d ».