Skip to content

documentation: add warning+solution for tmux < 2.1 - #{pane_current_path} not supported #19

@mattias-lidman

Description

@mattias-lidman

Expected Behavior

Git information shows up in status bar when in a git repo.

Actual Behavior

It doesn't.

Steps to Reproduce the Problem

  1. On Raspbian jessie, install gitmux and put set -g status-right '#(gitmux "#{pane_current_path}")' in ~/.tmux.conf, and re-source.
  2. Go to a git repo.
  3. Run gitmux manually, which seems to produce sensible output: #[fg=default]#[fg=default]#[fg=white,bold]⎇ #[fg=default]master#[fg=default]..#[fg=cyan]origin/master#[fg=default]#[fg=default] - #[fg=red,bold]✚ 1 #[fg=cyan,bold]⚑ 1 #[fg=magenta,bold]…1
  4. Observe lack of git info in status bar.

Specifications

  • OS: Raspbian GNU/Linux 8 (jessie)
  • gitmux version: 0.4.1
  • tmux version: 1.9

Same setup works for me on a x86 box with tmux 2.1. Any ideas?

Activity

arl

arl commented on Mar 4, 2020

@arl
Owner

Uhm it seems that tmux 1.9 does not support #{pane_current_path} in tmux.conf.

The problem is not gitmux per se, but how to have it automatically called by tmux on user actions (switch paned ,change for, etc.). Without a recent tmux version, you'll have to implement a solution based on your shell, such as one based on $PROMPT_COMMAND for bash, in order to have gitmux be automatically called.

Tmux is very easy to compile, IMO the simplest solution is to build a recent ARM version.

arl

arl commented on Mar 4, 2020

@arl
Owner

Just saw this, have a look at the unique answer: https://unix.stackexchange.com/questions/233929/tmux-2-0-pane-current-path-not-working-on-centos/234222#234222

If that works, or if you find another shell-independent solution I'll update the README accordingly

mattias-lidman

mattias-lidman commented on Mar 4, 2020

@mattias-lidman
Author

I tried set -g status-right '#(gitmux "$PWD")': It gets the output of wherever you launch tmux from, but then never updates. I can just build a >2.0 version -- maybe add a warning about <2.0 to the README? Or is there something else you'd like me to try so you can keep the "Works with all tmux versions" claim?

Thank you for your work -- I'm finding this a very useful addition to my setup.

arl

arl commented on Mar 4, 2020

@arl
Owner

Ok It seems that tmux < 2.0 generates it's status statically.
The only way I see to make it work, only on bash btw, is to to call tmux set -g status-right "#(gitmux $PWD)" from within a PROMPT_COMMAND, which is a bit more involved since you have to do it in .bashrc in order to have it work then on any tmux session.

export PROMPT_COMMAND="tmux set -g status-right \"$(gitmux $PWD)\""
I may have forgotten or added too much escaping but I know that works since I was doing like that in https://github.com/arl/tmux-gitbar

Thank you for your patience, tell me your results and I'll update the README.

mattias-lidman

mattias-lidman commented on Mar 4, 2020

@mattias-lidman
Author

This seems to work reasonably well: export PROMPT_COMMAND='tmux set -g status-right "$(gitmux $PWD)" &> /dev/null'

Redirecting both STDERR and STDOUT seems necessary, or tmux will spam output on every command. For me I think building a recent tmux is a better way to go but hopefully this will be useful to someone.

Cheers.

arl

arl commented on Mar 4, 2020

@arl
Owner

Great! Thanks for reporting

added
documentationImprovements or additions to documentation
on Mar 6, 2020
changed the title [-]Not working on Raspbian (ARM) / tmux 1.9[/-] [+]documentation: add warning & possible solution for tmux < 2.1 (since #{pane_current_path} was not supported)[/+] on Mar 6, 2020
changed the title [-]documentation: add warning & possible solution for tmux < 2.1 (since #{pane_current_path} was not supported)[/-] [+]documentation: add warning+solution for tmux < 2.1 - #{pane_current_path} not supported[/+] on Mar 6, 2020
casr

casr commented on May 5, 2020

@casr

The OpenBSD version of tmux hasn't had pane_current_path for a few versions now so I worked around it by abusing the dynamic titles feature.

With your shell prompt you set the title to the current path:

# ksh
PS1="\e]2;\${PWD}\a\$"

# zsh
PS1=$'\e]2;%d\a\$'

Then use this in .tmux.conf (in my case it was so that a pane split takes the current pane's path):

bind-key '"' split-window -v -c "#{pane_title}"
bind-key % split-window -h -c "#{pane_title}"

This comes with the caveat that other programmes also set the title such as Vim. You then have to work around those cases individually. In the case of Vim, put this in your .vimrc:

set titlestring=%{getcwd()}

@arl you may want to change future instructions to use pane_path instead of pane_current_path which is a dedicated way for the pane to self-report the path through OSC 7:

# ksh
PS1="\e]7;\${PWD}\a"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @arl@casr@mattias-lidman

        Issue actions

          documentation: add warning+solution for tmux < 2.1 - #{pane_current_path} not supported · Issue #19 · arl/gitmux