0

When I run an executable inside of tmux in msys2 on Windows, the window name give the full executable name and they can sometimes get very long. For example my current tab name is:

C:\\Users\\me\\Anaconda3\\python.exe

(yes, those are double slashes \\)

While I like the feature of updating to whatever I'm running, it'd be great if this was just python. My guess is that tmux is trying to parse directories of the form /c/Users/me/Anaconda3/python (since cat just shows up as cat and not /usr/bin/cat) and the weird mix of sometimes that format and sometimes the window format isn't working well for tmux.

Any idea how I can get tmux to display just python as a tab name when python is running?

2
  • Can you provide a screenshot of that window? Does executable within msys2/mingw environment show that same effect? – Biswapriyo Nov 19 '20 at 5:22
  • @Biswapriyo Screenshot: imgur.com/a/kyfOD2E Tab 1 is the external python and Tab 2 is the internal one and displays fine. – Jarvin Nov 20 '20 at 1:24
0

Tmux supports substitution for variable names in options. The two options you'll want to manipulate are window-status-format and window-status-current-format.

So, for example, to have the window number followed by the current command you would normally do something like this in your .tmux.conf:

setw -g window-status-format "#I > #pane_current_command "
setw -g window-status-current-format "#I > #pane_current_command "

But we can do regular expressions substitution on the pane_current_command by doing #{s_string1_string2_:pane_current_command} and it'll replace occurrences of string1 with string2. He're we're going to use a greedy wildcard to replace everything before the backslashes .*\\\\ and replace it with nothing. We'll also replace .exe by using an regex or which is |. So our final results are:

setw -g window-status-format "#I > #{s_.*\\\\|\.exe__:pane_current_command} "
setw -g window-status-current-format "#I > #{s_.*\\\\|\.exe__:pane_current_command} "

Now the tab will read python instead of C:\\Users\\me\\Anaconda3\\python.exe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.