Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I show pane_current_path as window name? #41

Open
worldsayshi opened this issue Aug 4, 2024 · 7 comments
Open

Can I show pane_current_path as window name? #41

worldsayshi opened this issue Aug 4, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@worldsayshi
Copy link

worldsayshi commented Aug 4, 2024

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 #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
Copy link
Author

worldsayshi commented Aug 4, 2024

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}'
  1. 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
Copy link
Owner

Interesting, this is a good idea!

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

@joshmedeski
Copy link
Owner

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

I wonder if bash is the culprit.

@worldsayshi
Copy link
Author

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
Copy link
Owner

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.

@joshmedeski joshmedeski moved this to Next in OSS Development Aug 20, 2024
@joshmedeski joshmedeski self-assigned this Aug 20, 2024
@joshmedeski joshmedeski added the enhancement New feature or request label Aug 20, 2024
@chris4prez
Copy link

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
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

3 participants