how to display filename edited with vim in status bar

35 views
Skip to first unread message

Ray Gllisse

unread,
Dec 23, 2023, 2:19:18 PM12/23/23
to tmux-users
Hi,
I am new user of tmux using mainly tmux 3.2a on ubuntu 22.04 with WSL2.
Once a file is edited with vim, there's no hint of the filename being edited and it gets difficult to identify quickly files when several files are opened at the same time in different vim windows.

Tried to ask Chat GPT without luck, and not very easy to dwelve into tmux documentation.
Nevertheless, I tried a few things editing ~/.tmux.conf and reloading it without success:
  the status bar staying the same: an integer followed by colon and the command name followed by an asterisk

Here are my attempts :

set-window-option -g pane-border-format '#(/home/cedric/tmux-pane-title.sh #T) #T '

or

set -g pane-border-format "#(/home/cedric/tmux-pane-title.sh)"

or

set -g set-titles on
set -g set-titles-string '#(/home/cedric/tmux-pane-title.sh)'

with tmux-pane-pane-title.sh :

#!/bin/bash
# Get the command with arguments
TMUX_PANE_PID=$(tmux display -a| grep pane_pid| cut -d'=' -f2)
cmd_with_args=$(ps -o cmd= -p $TMUX_PANE_PID)
# Print the formatted pane title
echo "#{pane_index}:$cmd_with_args"


Thanks for your help !

Cédric

Christian Ebert

unread,
Dec 23, 2023, 4:59:58 PM12/23/23
to tmux-...@googlegroups.com
* Ray Gllisse on Saturday, December 23, 2023 at 11:02:13 -0800:
> I am new user of tmux using mainly tmux 3.2a on ubuntu 22.04 with WSL2.
> Once a file is edited with vim, there's no hint of the filename being
> edited and it gets difficult to identify quickly files when several files
> are opened at the same time in different vim windows.

[...]

> Here are my attempts :
>
> set-window-option -g pane-border-format '#(/home/cedric/tmux-pane-title.sh
> #T) #T '
>
> or
>
> set -g pane-border-format "#(/home/cedric/tmux-pane-title.sh)"
>
> or
>
> set -g set-titles on

Not 100% sure what you want, but I have the above. However, the
brunt of the work is done in vimrc:

if &term =~ '^\(screen\|tmux\)'
set title
" VimTip #1126
set t_ts=^[k
set t_fs=^[\
set ttyfast " tmux FAQ
let &titleold = fnamemodify(&shell, ":t")
endif

Hope this helps.

--
LAST SHIP HOME
The circumnavigation of the world of the Peter von Danzig
Winner of the German Ocean Film Award 2019
Watch the movie in full online: https://lastshiphome.de/en/movie

Ray Gllisse

unread,
Dec 24, 2023, 11:21:36 AM12/24/23
to tmux-...@googlegroups.com
Hi,
Thanks for your answer
actually I would like to see vim README.txt in status bar when README.txt is edited with vim in the active pane and not just vim *

After posting this message, I have found some .tmux.conf setting that does it:
here it is:

set-option -g status-interval 1
set-option -g automatic-rename on
set-option -g automatic-rename-format "#(ps -f --no-headers --ppid $(tmux display-message -p #{pane_pid}) | awk '{ print substr($0, index($0,$8)) }') "

A few problems though, I have to move cursor within vim window to have status bar updated.
There's no automatic update when there is a change of active pane

When focus switches to a bash pane , I just get "*" and not at least "bash" or "bash * "

And second problem is that I don't understand the syntax following set-option -g automatic-rename-format   in

set-option -g automatic-rename-format "#(ps -f --no-headers --ppid $(tmux display-message -p #{pane_pid}) | awk '{ print substr($0, index($0,$8)) }') " 

the $(tmux display-message -p #{pane_pid}) make me think command subsitution with $( cmd ) expression is possible but
why put #(ps -f --no-headers --ppid ....  and not #($( ps -f --no-headers --ppid.... ) ?

Is there a link somewhere to a tutorial explaining how to use shell commands with tmux own scripting language ?
Thanks !


--
You received this message because you are subscribed to a topic in the Google Groups "tmux-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tmux-users/XA3w6iiJIl8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/ZYdI5WJUnYqbXu9P%40krille.phloxic.productions.
Reply all
Reply to author
Forward
0 new messages