joshmedeski / tmux-nerd-font-window-name

Nerd Font icons for your tmux windows
144 stars 29 forks source link

Can I show pane_current_path as window name? #41

Open worldsayshi opened 3 months ago

worldsayshi commented 3 months ago

Thanks for a great plugin! It's is almost perfect for me but I'd like the window names to be set to #{b:pane_current_path}.

This could be a duplicate of https://github.com/joshmedeski/tmux-nerd-font-window-name/issues/14 but I'm not sure if the plugin is working as expected for me.

What I see: image

What I'd like to see: <Icon> <pane_current_path>

I am running this in Windows Terminal and WSL Ubuntu.

Is there some way to configure the plugin to set the title using tmux variables like pane_current_path (as seems to be the default in tmux) while still getting the icons?

Here's my current tmux.conf (very much WIP because I'm currently learning tmux):

## https://github.com/mischavandenburg/dotfiles/blob/main/.tmux.conf

set-option -g history-limit 25000
set -g mouse on

# for neovim
set -sg escape-time 10
set-option -g focus-events on

# vi for copy mode
setw -g mode-keys vi

# status bar
set -g status-right "#(pomo)"
set -g status-style "fg=#665c54"
set -g status-left-style "fg=#928374"

set -g status-bg default
set -g status-position top
set -g status-interval 1
set -g status-left ""

# rename panes to current working directory
#set-option -g automatic-rename on
#set-option -g automatic-rename-format '#{b:pane_current_path}'

# disable status
# set -g status off
# set -g status on

# count the panes from 1
set -g base-index 1
setw -g pane-base-index 1

# reload configuration
bind-key -r r source-file ~/.config/tmux/tmux.conf

# term colors, these are the correct ones according to neovim checkhealth
set -g default-terminal "tmux-256color"
set-option -sa terminal-overrides ',xterm-256color:RGB'

## https://unix.stackexchange.com/a/118381/122597
# create windows in current directory
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

## https://github.com/cpow/cpow-dotfiles/blob/master/.tmux.conf

# Set leader prefix key
#set -g prefix C-s

bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R

# https://stackoverflow.com/a/45010147/439034
#set-option -g status-interval 5
#set-option -g automatic-rename on
#set-option -g automatic-rename-format '#{b:pane_current_path}/[#{b:pane_current_command}]'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
#set -g @plugin 'ofirgall/tmux-window-name' # https://github.com/ofirgall/tmux-window-name?tab=readme-ov-file#installation
set -g @plugin 'joshmedeski/tmux-nerd-font-window-name'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'dracula/tmux'

set -g @dracula-show-powerline true
set -g @dracula-fixed-location "Gothenburg, Sweden"
set -g @dracula-plugins "weather"
set -g @dracula-show-flags true
set -g @dracula-show-left-icon session
set -g status-position top

#set -g @dracula-kubernetes-context-label "Some Label"

# Keybindings for moving tmux windows

bind-key S-Left swap-window -t -1
bind-key S-Right swap-window -t +1

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
worldsayshi commented 3 months ago

I managed to find a workaround!

Instead of installing the plugin as a plugin I call it from my conf.

  1. Clone this repo to some nice location (here I'm putting it in ~/git_apps):
mkdir ~/git_apps && cd ~/git_apps && git clone https://github.com/joshmedeski/tmux-nerd-font-window-name.git
  1. Make bin/tmux-nerd-font-window-name executable
  2. Include a call to it when setting the automatic-rename-format option:
    set-option -g automatic-rename on
    set-option -g automatic-rename-format '#(~/git_apps/tmux-nerd-font-window-name/bin/tmux-nerd-font-window-name #{pane_current_command} #{window_panes}) #{b:pane_current_path}'
  3. Set show-name to false in ~/.config/tmux/tmux-nerd-font-window-name.yml:
    config:
    show-name: false

Quite happy with the result: 💯

image

joshmedeski commented 3 months ago

Interesting, this is a good idea!

I'll experiment with it later this week, thanks for looking into it.

joshmedeski commented 3 months ago

I didn't find this to be significantly faster, perhaps I'm missing something.

I wonder if bash is the culprit.

worldsayshi commented 3 months ago

No it's not supposed to be faster. It's just a way to display <icon> <working dir> as the tab title. As far as I understood it the plugin doesn't support doing that? But maybe I'm misunderstanding something.

joshmedeski commented 3 months ago

I see! At this point the plugin is very simple: replace the process name with an icon. I think we could support passing other values in the window name. I'd have to look over the available values and determine the best way to make this plugin more flexible.

chris4prez commented 4 weeks ago

I came here looking for same exact thing and/or similar option. (FYI This plugin is awesome, excellent work.)

Currently I define the following in my tmux.conf for window naming: set -gq @catppuccin_window_current_text "#{?#{==:#{b:pane_current_command},zsh},#{b:pane_current_path},#{window_name}}"

What I would like to do is have an option to define a folder icon whenever #{b:pane_current_path} is defined as my window name.

joshmedeski commented 3 weeks ago

I think it could work to add a variable that can disable automatic window renaming and allow the user to call their own overwrite options in some way.

@worldsayshi would you be interested in opening a PR?