Unhelpful window title with console file manager ranger
Closed this issue · 3 comments
Hello ofirgall!
First, thank you for creating such a useful program. Really happy that I no longer need to manually rename windows.
However, I have a problem with it integrating with ranger. Please see the video below:
simplescreenrecorder-2022-04-11_20.50.08.mp4
To reproduce:
- type
r
(my alias for ranger) to open ranger in terminal - current tmux window is not updated (as expected)
- move to next window by pressing
alt+2
- previous tmux window is updated (as expected) but it's renamed as
/usr/bin/python -O /
Below is my settings in ranger (if it's relevant):
# Set a title for the window? Updates both `WM_NAME` and `WM_ICON_NAME`
set update_title true
# Set the tmux/screen window-name to "ranger"?
set update_tmux_title true
I've tried disabling tmux-window-name
as follows:
# set -g @plugin 'ofirgall/tmux-window-name'
set -g status-interval 1
set -g automatic-rename on
set -g automatic-rename-format '#{b:pane_current_path}'
set -g allow-rename on
This is what happens:
simplescreenrecorder-2022-04-11_20.56.44.mp4
It's simply displayed as python
(better than /usr/bin/python -O /
imo)
However, I simply lose the benefits of using tmux-window-name
:
Recommendation
Maybe provide a manual intervention to rename certain programs? Currently I encounter this problem only with ranger. But I'm quite sure there are other programs with similar issues. Is it possible to provide a way to "override manually"? Like a mapping below:
set -g @tmux_window_override '{"/usr/bin/python -O /", "ranger", "undesired window name", "desired window name"}'
Thank you again!
Thanks for the detailed issue.
I would add @tmux_window_substitute
which allows to add regex replace with list of tuples.
By the way I would suggest to turn off update_tmux_title
in ranger, it modifies your tmux rename options, it collides with tmux-window-name
Thank you so much for such a quick fix enhancement. Really appreciate it. It works like a charm! Btw this is what I get after running --print_programs
for ranger:
❯ ~/.tmux/plugins/tmux-window-name/scripts/rename_session_windows.py --print_programs
/usr/bin/python -O /usr/bin/ranger -> ranger
Thanks again!
Not sure if this is relevant but I think it might be helpful to some people.
I use ranger along with tmux
a lot. When I open ranger
, and then open a file in vim
, the tmux pane is stuck with the name ranger
, which is not helpful. I have the following vim snippet to rename the tmux
pane whenever I open a file in vim.
augroup _tmux_rename
autocmd!
if exists('$TMUX')
autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window " . expand("%:t"))
endif
augroup end
We don't need the following
autocmd VimLeave,FocusLost * call system("tmux rename-window \"\"") " to enable auto-rename again
because tmux-window-name
takes care for us when we're back to ranger
. Cheers!