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

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

Closed
mattias-lidman opened this issue Mar 4, 2020 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@mattias-lidman
Copy link

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?

@arl
Copy link
Owner

arl commented Mar 4, 2020

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

arl commented Mar 4, 2020

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

arl commented Mar 4, 2020

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

arl commented Mar 4, 2020

Great! Thanks for reporting

@arl arl added the documentation Improvements or additions to documentation label Mar 6, 2020
@arl arl 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) Mar 6, 2020
@arl arl 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 Mar 6, 2020
@casr
Copy link

casr commented May 5, 2020

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"

@arl arl closed this as completed in 8703c0d Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants