Gitmux not loading at all
hqkhan opened this issue · 9 comments
Describe the bug
Gitmux is not showing in the statusbar.
To Reproduce
Tmux conf:
# True color support
# set-option -g default-terminal "tmux-256color"
set -g default-terminal "${TERM}"
set-option -ga terminal-overrides ",*256col*:Tc"
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm' # undercurl support
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m' # underscore colours - needs tmux-3.0
set -g mouse on
set-option -g default-shell "/bin/bash"
set -g default-command "/bin/bash"
# set -s escape-time 10
set -g base-index 1
setw -g pane-base-index 1
setw -g mode-keys vi
# scrollback buffer n lines
set -g history-limit 100000
setw -g automatic-rename on # rename window to reflect current program
set -g renumber-windows on # renumber windows when a window is closed
set -g set-clipboard on
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
bind-key -T prefix e select-pane -t :.+
bind-key -T copy-mode-vi Escape send-keys -X cancel
bind-key -T copy-mode-vi J send-keys NPage
bind-key -T copy-mode-vi K send-keys PPage
bind W command-prompt -I "swap-window -t "
# open a new window in the current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind '%' split-window -h -c "#{pane_current_path}"
set-option -sg escape-time 10
bind r source-file $HOME/.config/tmux/tmux.conf \; display-message "Config reloaded..."
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -T copy-mode-vi C-j send-keys -X scroll-down
bind-key -T copy-mode-vi C-k send-keys -X scroll-up
set -g status-interval 2 # update status every 2 seconds
set -g status-left-length 200 # increase status line length
set -g status-position top # macOS / darwin style
set -g status-right '' # empty
set -g status-left '#[fg=blue,bold]#S'
set -ga status-left '#[fg=white,nobold]#(gitmux -timeout 200ms -cfg $HOME/.config/tmux/gitmux.conf) '
set -g pane-active-border-style 'fg=magenta,bg=default'
set -g pane-border-style 'fg=brightblack,bg=default'
set -g status-style 'bg=default' # transparent
set -g window-status-current-format '#[fg=magenta]#W'
set -g window-status-format '#[fg=gray]#W'
# Fuzzback config
set -g @fuzzback-bind /
set -g @fuzzback-popup 1
set -g @fuzzback-popup-size '95%'
set -g @fuzzback-fzf-bind ''
set -g @fuzzback-fzf-colors 'bg+:#656A7c,gutter:#323F4E,pointer:#F48FB1,info:#ffe6b3,hl:#F48FB1,hl+:#F48FB1,border:#FFFFFF'
# Plugins
# set -g @plugin 'tmux-plugins/tmux-resurrect'
# set -g @plugin 'tmux-plugins/tmux-continuum'
# set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# set -g @plugin 'hqkhan/tmux-onedark-theme'
# set -g @plugin 'joshmedeski/tmux-nerd-font-window-name'
# set -g @plugin 'roosta/tmux-fuzzback'
set -g @tpm-clean 'u'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
I commented and removed all tmux plugins to see if it'd fix but still nothing.
Expected behavior
Expecting gitmux to show branch and other git items on the statusbar.
The above image shows nothing from gitmux.
Here's the output in the terminal when I call gitmux manually in my yadm repo. The issue is there in any other git repo.
~/dots/yadm-repo took 2m14s
gitmux --cfg $HOME/.config/tmux/gitmux.conf
#[fg=default]#[fg=default]#[fg=white,nobold] שׂ #[fg=default]#[fg=white,nobold]main#[fg=default] #[fg=default]#[fg=green,nobold]都1 #[fg=yellow,nobold] 2#[fg=default] #[fg=default]#[fg=green] 7 #[fg=red] 7
Environment:
- gitmux version:
0.9.1
- tmux version:
tmux next-3.4
- OS:
AL2_x86
- shell:
bash
Gitmux Config: $HOME/.config/tmux/gitmux.conf
:
tmux:
symbols:
branch: ' שׂ '
hashprefix: ':'
ahead: ' '
behind: ' '
staged: '都'
conflict: '繁'
untracked: ' '
modified: ' '
stashed: ' '
clean: ''
insertions: ' '
deletions: ' '
styles:
state: '#[fg=red,nobold]'
branch: '#[fg=white,nobold]'
staged: '#[fg=green,nobold]'
conflict: '#[fg=red,nobold]'
modified: '#[fg=yellow,nobold]'
untracked: '#[fg=gray,nobold]'
stashed: '#[fg=gray,nobold]'
clean: '#[fg=green,nobold]'
divergence: '#[fg=cyan,nobold]'
layout: [branch, divergence, ' ', flags, ' ', stats]
options:
branch_max_len: 0
~/dots/yadm-repo took 2m14s
gitmux --cfg $HOME/.config/tmux/gitmux.conf
#[fg=default]#[fg=default]#[fg=white,nobold] שׂ #[fg=default]#[fg=white,nobold]main#[fg=default] #[fg=default]#[fg=green,nobold]都1 #[fg=yellow,nobold] 2#[fg=default] #[fg=default]#[fg=green] 7 #[fg=red] 7
Ok so the output above shows that gitmux is working well.
The problem seems to lie in how gitmux is called from tmux.conf
Note that gitmux readme shows:
set -g status-right '#(gitmux -cfg $HOME/.gitmux.conf "#{pane_current_path}")'
From what I see you're not using pane_current_path
.
So, I tried that as well. Same result. Nothing shows up on the status bar. For a bit more context, I was borrowing the config from here. I searched for pane_current_path
in that particular repo and could not find it being used in a "gitmux context".
Hey @arl. Apologies for leaving this issue up for a bit. So, gitmux wasn't working before due to a wonky setup that I have where my default shell is zsh but I tell tmux to open bash shell in new windows. After adding gitmux to zsh $PATH, gitmux will work with defaults but it refuses to work with my config file.
I confirmed the path multiple times and can even issue gf
in nvim
to get to the file. I thought maybe I have some invalid config so I commented out the entire file but the status bar won't show when I ask it to use my config file.
I wanted to ask how I can debug using gitmux
since there's not much output on stdout to work with. I realize there's --dbg
option but wasn't sure on how to use it. Could you give an example of how to use this option?
Hey @hqkhan
The --dbg
is made to be used by calling gitmux --dbg
manually on your terminal. What it does is that it prints whatever error message in case gitmux failed to get a git status on the current directory, or failed to load the config file for example. And then, instead of printing tmux format strings, it prints git status as JSON.
This allows one to know why would gitmux would failed to print anything, which is your case.
You can even try to run:
tmux set -ga status-left '#(gitmux -cfg $HOME/.config/tmux/gitmux.conf)'
Or whatever command you're using in tmux.conf
, preceded with tmux
this should set the status string immediately, unless there's a problem.
I'm still running into issues. I uploaded a video below to showcase commands tried and what gitmux shows. When I reload my config, you can see gitmux showing up for a split second before disappearing. If I manually set it with the same command, it shows up. I tried it with zsh as well because of my "wonky" setup mentioned previously but the issue is still there. The spacing is off as well
cropped_gitmux.mov
Here's my gitmux config:
tmux:
symbols:
branch: 'שׂ '
hashprefix: ':'
ahead: ' '
behind: ' '
staged: '都'
conflict: '繁'
untracked: ' '
modified: ' '
stashed: ' '
clean: 'c'
insertions: ' '
deletions: ' '
styles:
state: '#[fg=red,nobold]'
branch: '#[fg=white,nobold]'
staged: '#[fg=green,nobold]'
conflict: '#[fg=red,nobold]'
modified: '#[fg=yellow,nobold]'
untracked: '#[fg=gray,nobold]'
stashed: '#[fg=gray,nobold]'
clean: '#[fg=green,nobold]'
divergence: '#[fg=cyan,nobold]'
layout: [branch, divergence, flags, stats]
options:
branch_max_len: 0
hide_clean: true
@arl I apologize for "@-ing" you. I wanted to ping you to see if you got a chance to look at the video and if it provides and meaningful error. For some reason, it disappears right away upon config reload. Setting it again works...
When I reload my config, you can see gitmux showing up for a split second before disappearing. If I manually set it with the same command, it shows up.
Both the video and what you're saying are going in the same direction, which is that gitmux is working correctly but that some other option in your tmux.conf are conflicting with what you want to show on the left side of tmux status bar.
For example if you replaced the whole gitmux command with the foobar
string, you would see it shown for a brief moment.
You should try to comment one by one all the other tmux status commands, reload config each time, to get to the conflicting commands
Hey @arl. Thank you so much. I went through my config and found the issue. Specifically, tmux-continuum
was the culprit. It does mess with the status line, specifically status-right
:
From tmux-continuum
:
Note it requires the status line to be on to run (since it uses a hook in status-right to run).
I think it basically flushes the entire statusline to put its thing on there which was deleting my statusline. It does so continuously so nothing else that modifies the statusline can really work besides modifying window names.
I had trouble getting it working with tmux-prefix-highlight
as well but realized that I don't actually use that plugin. Ended up removing that and continuum
as I wasn't utilizing it either.
Thank you for your help!
Cool, glad you worked it out Hassaan 👍🏽