Giter VIP home page Giter VIP logo

tmux-gitbar's Issues

Git status bar not showing automatically

Hi,

I can't make tmux-gitbar display automatically. I have to invoke it manually.
Running tmux using Konsole Version 18.08.0

I reckon I'm asking for trouble since I installed it using TPM, so I updated my conf as stated in the docs, but the status bar does not show unless I'm calling update-gitbar.

❯ tmux -V                                                                                                                                                                                                                                                                                                        
tmux 2.7-rc
❯ echo $SHELL                                                                                                                                                                                                                                                                                                   
/run/current-system/sw/bin/zsh

Here is my .tmux.conf

❯ cat ~/.tmux.conf                                                                                                                                                                                                                                                                                               
set -g base-index 1

# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on

set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000

setw -g mode-keys vi
setw -g mouse on
setw -g monitor-activity on
set -g status-justify centre

bind-key v split-window -h
bind-key s split-window -v

bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key H resize-pane -L 5
bind-key L resize-pane -R 5

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

# Vim style pane selection
bind h select-pane -L
bind j select-pane -D 
bind k select-pane -U
bind l select-pane -R

# Use Alt-vim keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D 
bind -n M-k select-pane -U
bind -n M-l select-pane -R

# Use Alt-arrow keys without prefix key to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Shift arrow to switch windows
bind -n S-Left  previous-window
bind -n S-Right next-window

# No delay for escape key press
set -sg escape-time 0

# Reload tmux config
bind r source-file ~/.tmux.conf

# THEME
set -g status-bg black
set -g status-fg white
set -g window-status-current-bg white
set -g window-status-current-fg black
set -g window-status-current-attr bold
set -g status-interval 60
set -g status-left-length 30
set -g status-left '#[fg=green](#S) #(whoami) '
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'


# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-sidebar'
#set -g @plugin 'arl/tmux-gitbar'

TMUX_GITBAR_DIR="/home/damien/.tmux/plugins/tmux-gitbar"
set -g status-right-length 100

source-file "/home/damien/.tmux/plugins/tmux-gitbar/tmux-gitbar.tmux"

run -b '/home/damien/.tmux/plugins/tpm/tpm'

My ~/.zshrc

#Zplug
export ZPLUG_HOME=~/.zplug
source $ZPLUG_HOME/init.zsh

zplug clear

zplug "mafredri/zsh-async", from:github, defer:0
zplug "lib/completion", from:oh-my-zsh
zplug "zsh-users/zsh-syntax-highlighting", from:github, defer:3
zplug "sindresorhus/pure", use:pure.zsh, from:github, as:theme

zplug "rupa/z", use:z.sh

zplug load

if ! zplug check --verbose; then
    printf "Install zplug plugins? [y/N]: "
    if read -q; then
        echo; zplug install
    fi
fi

alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'

export LOCAL_IP=172.18.0.1

#VirtualEnv
export WORKON_HOME=/home/damien/Python/Envs/
VIRTUAL_ENV_PATH=`whereis virtualenvwrapper.sh | awk '{print $2}'`


#Path
NPM_PACKAGES=/home/damien/.npm-packages
PATH=$NPM_PACKAGES/bin:$PATH

unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

export EDITOR=vim

# tabtab source for serverless package
# uninstall by removing these lines or running `tabtab uninstall serverless`
[[ -f /home/damien/.npm-packages/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh ]] && . /home/damien/.npm-packages/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh
# tabtab source for sls package
# uninstall by removing these lines or running `tabtab uninstall sls`
[[ -f /home/damien/.npm-packages/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh ]] && . /home/damien/.npm-packages/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh

NB: I had to comment the plugin declaration in ~/.tmux.conf because tpm was returning an error.

Extra spaces in minimal config

Using the following tmux-gitbar.conf:

readonly TMGB_STATUS_LOCATION='left'
readonly TMGB_STYLE=''
readonly TMGB_STATUS_STRING=" #{git_branch}#{git_flags}"

...produces a minimalist tmux-gitbar config. The outputted information contains extra spaces which bloat the width of the tmux-gitbar status line (dashes used in place of spaces for emphasis):
"-⎇-master--✔"

Ideally I'd like "-⎇master-✔", which isn't possible without editing several places in the lib/tmux-gitbar.sh file because of spaces embedded in the strings.

Not sure this is worth fixing ultimately but thought I'd mention it.

Some symbols do not render with the stock font

This is what is shown on Linux with the Fixed font, using tmux Powerline:
image

image

If this is only the branch symbol that doesn't show up, I guess the default would be to not have it displayed.
However, if there are too many symbols that don't show up in a vanilla configuration, the set of symbols should be changed.

Does not work in zsh

Great tmux/git addition!

However, right now it doesn't seem to work in zsh for me. When I enter bash and then a git repo I get the nice status bar, but when I'm just i zsh, it doesn't seem to work.

Problem when on a tag in detached state

To reproduce:

git checkout 2.0.3 

git status sayd:

$ git status
HEAD detached at 2.0.3
nothing to commit, working directory clean

But tmux-gitbar (version tag: v2.1.3)shows:
⎇ 2.0.1-89-g9fc3917 - ^ - . | ✔

Hook on window/pane switch events to keep status synced

Idea comes from this post of an user on tmux-gitbar thread on reddit/r/tmux

Hmm. This looks interesting. But what happens if you have two tmux windows (or panels, I don't know
what they're called) and they've both in different git repositories? Does the bar show the info for the repository for the currently active window / panel?

Answer and a possible solution for implementing it:

Tmux-gitbar is updated via a callback added to your bash $PROMPT_COMMAND. This is triggered every time you send a new bash command (so each time you press ENTER) So basically the gitbar shows the status of last pane or window in which you typed ENTER.
So if you divide your visible screen in 2 panes, and both panes have different working directories, the gitbar is not updated as soon as you switch from one pane to another, but as soon as you type ENTER is a pane.
If guess it should be possible to hook on the tmux switch-pane or switch-window event (or whatever it is called) and update the gitbar at this exact moment. In that way the gitbar would always be in sync.

Error on tmux.conf reload

The if-shell expression, in tmux-gitbar.tmux, installing the PROMPT_COMMAND is failing on tmux.conf reloading. The problem seems due to different variable expansion rules when loading the file, or when reloading it from inside a tmux-session.

Garbage output in freshly created repo with 0 commits

Don't know if this happens only on the currently-in-dev-branch handle-special-states, at commit fba3858, but this happens when entering in a freshly created repository with git init, with 0 commits yets:

Garbage output after each command entered:

[0:8369] 02:56:24 Sun Nov 05 [aurelien@computer8:/dev/pts/5 +3] ~/dev/evolve-webui       
$                                           
/home/aurelien/.tmux-gitbar/lib/tmux-gitbar.sh: line 129: test: on: integer expression expected                                                                                   
/home/aurelien/.tmux-gitbar/lib/tmux-gitbar.sh: line 129: test: master: integer expression expected                                                                               
/home/aurelien/.tmux-gitbar/lib/tmux-gitbar.sh: line 129: test: _NO_REMOTE_TRACKING_: integer expression expected                                                                 
/home/aurelien/.tmux-gitbar/lib/tmux-gitbar.sh: line 129: test: ^: integer expression expected

Garbage string showing on tmux status bar:

websocket⮀ 03:03     1:go 2:js (3:bash) 4:bash        ⎇  No - yet - commits | ```

PROMPT_COMMAND added multiple times if tmux-gitbar.tmux is reloaded

If tmux source-file is called when already inside tmux, the $PROMPT_COMMAND is modified another time. This leads to have multiple calls to update-gitbar in the $PROMPT_COMMAND.

The solution could be to check if $TMUX environment variable is set before modifiying $PROMPT_COMMAND

Gitbar is squashed in to rightmost 14 characters

Hi -- I'm running the latest version of tmux, and the output is squashed over to the last 14 characters of the bottom bar.
This means that I'm not seeing anything but the truncated name of the branch I'm on.
Is there a configuration setting somewhere that I can alter to fix this?
Thanks for any & all help,
Doug.

Git information not showing up after reloading tmux config

I've installed tmux-gitbar by git clone-ing per the documentation, updated my config and run source ~/.tmux.conf.

Something initially suspect was that it seems to have hung on generating the git info (apologies, I don't have the exact message handy). I had a config error unrelated to this that I fixed, and reloaded the config again with no change (it didn't hang this time, but no git information is being displayed in my tmux toolbar).

So, an itemized list of steps I've taken to get here:

  1. install per documentation
  2. update tmux config and reload
  3. correct unrelated config error and reload
  4. reload config several more times to attempt to fix issue

I've also tried running update-gitbar from the tmux command prompt but it tells me Unknown command: update-gitbar. I'm not sure if it's because I'm calling it incorrectly or there's something else afoot.

I'm running under bash on high sierra.

bash version:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.

tmux version: tmux 2.7

.tmux.conf:

# remap prefix to Control + a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

set -g @continuum-restore 'on'

source-file "$HOME/.tmux-gitbar/tmux-gitbar.tmux"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Unnecessarily overwriting status-left or right

Presently tmux-gitbar overwrites the entire status-left or status-right tmux configuration. While the default status line is restored this limitation restricts TMGB's utility.

Consider tmux-gitbar.sh line 176:

tmux set-window-option -a "status-$TMGB_STATUS_LOCATION" "$status_string" > /dev/null

replaced with:

tmux set-window-option "status-$TMGB_STATUS_LOCATION" "$TMGB_OUTREPO_STATUS" > /dev/null
tmux set-window-option -a "status-$TMGB_STATUS_LOCATION" "$status_string" > /dev/null

The new behavior is to restore the default each time, then ADD (-a) the TMGB information to the user's existing tmux status line.

How does tmux-gitbar would take advantage of tmux v2.3

tmux v2.3 has been released, with a nice changelog's .

How could tmux-gitbar take advantage of the new tmux features, especially from:

  • New option 'pane-border-status' to add text in the pane borders.
  • Support for hooks on commands: 'after' and 'before' hooks.

Switching from one pane to another, or from a window to another would immediately update git status. This removes the need to modify bash's PROMPT_COMMAND. This would also make tmux-gitbar shell-independent.

At this point, installation with the tmux-plugins-manager would be super easy.

tmux-gitbar.conf needs to exist outside the repo

Could you allow the option to have the tmux-gitbar.conf exist outside the repo? Apologies if this functionality already exists. Having the file exist in the repo makes it difficult to maintain the file across systems. I have tmux-gitbar as a submodule in my home folder setup which means I cannot manage the tmux-gitbar.conf across my machines. The conf file should really exist in the home folder anyway: ~/.tmux-gitbar.conf

Some errors occur when update-gitbar called in the initial git directory

$ cd /tmp
$ mkdir foobar
$ cd foobar
$ git init
$ ~/.tmux-gitbar/update-gitbar
/Users/foo/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: on: integer expression expected
/Users/foo/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: master: integer expression expected
/Users/foo/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: _NO_REMOTE_TRACKING_: integer expression expected
/Users/foo/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: ^: integer expression expected

env: tmux 2.6, zsh 5.4.2 (x86_64-apple-darwin16.7.0)
out of context: I'm troubled since I cannot update gitbar automatically...

Still having zsh issue

I have the go version of gitstatus and I added the .tmux.conf line you suggested in a previous issue. Though, the tmux status bar isn't updated with git info once I go into a git directory. I still have to manually issue the command. Is there something I am missing with the setup?

Thanks!

Still read Git status when .tmgbignore

Opening this problem reported on #40 by @rbuckley:

@rbuckley:

What does the ignore actually do? I've put it in a large repo because it was causing me issues (taking several seconds to print the prompt because update_gitbar was running).

When I put .tmgbignore in the directory, the status on my tmux bar goes away, but I still see update_gitbar taking several seconds before the prompt is printed.

Thanks.

@arl:

Hi

Thanks for reporting!

.tmgbignore obviously should not do that, it should early exit as soon as
possible, just after clearing tmux git status.

Out of curiosity, how large is your repo?

Could you post the output of:

time git status --porcelain -uall

If possible with and without tmux git bar.
To disable, unexport PROMPT_COMMAND in a shell.

@rbuckley:

Hi, thanks for the quick response.

It is a large Android repo, about 28GB.

time outputs:

With tmux gitbar
real 0m4.564s
user 0m1.396s
sys 0m1.622s

After unexporting PROMPT_COMMAND

real 0m3.629s
user 0m1.190s
sys 0m1.660s

Handle broken Git repositories?

Tmux-gitbar doesn't handle well broken Git working tree... It's not clear exactly how the Git working tree was broken, but it happened with the help of submodules. Probably a git command was unexpectedly failing and producing output that was not filtered by tmux-gitbar, leading to additional lines being printed at every PROMPT_COMMAND and polluting the user terminal.

Make installable with Tmux Plugin Manager

It should be relatively easy to adapt tmux-gitbar nomenclature to let it follow the one of a tmux plugin manager plugin.
However, the fact that the update_gitbar callback needs to be added to $PROMPT_COMMAND from the user .bashrc could be a problem as adding one line to tmux.conf is not enough to make it work, there would still exist the need, as long as #9 is not solved, for an extra manual user action

Possible to remove the need to add a line in .bashrc?

The best way to do this, is to make tmux-gitbar.sh a script called, with absolute path, from PROMPT_COMMAND, instead of, as I'm doing now, defining PROMPT_COMMAND as:

PROMPT_COMMAND="update_gitbar; $PROMPT_COMMAND"

So:

PROMPT_COMMAND="/full/path/to/tmux-gitbar.sh; $PROMPT_COMMAND"

Tmux 2.3 problem

Hi,
I did everthing on README but it cannot display in a project which has git repo. I am using tmux 2.3. How can I fix the problem?

Takes no effect after installation

I followed the step described in readme , but nothing looks different than before.
I used zsh with tmux.
What is the expected location for tmux.conf?
In my device , I only have the config file.tmux.conf, rather than tmux.conf.
Any help?

Issue when cd into a bare repository

This is what happens when entering into a bare repository:

panty@computerino:[~/dotfiles/term/.tmux-gitbar/tmp/repo]: cd bare
/home/panty/.tmux-gitbar/update-gitbar: line 144: test: -eq: unary operator expected
/home/panty/.tmux-gitbar/update-gitbar: line 144: test: -ne: unary operator expected
/home/panty/.tmux-gitbar/update-gitbar: line 144: test: -ne: unary operator expected
/home/panty/.tmux-gitbar/update-gitbar: line 144: test: -ne: unary operator expected
/home/panty/.tmux-gitbar/update-gitbar: line 144: test: -ne: unary operator expected
/home/panty/.tmux-gitbar/update-gitbar: line 144: test: -ne: unary operator expected
/home/panty/.tmux-gitbar/update-gitbar: line 144: test: -eq: unary operator expected

Add length limitation on the branch+remote string, or the whole bar

When the name of current branch is relatively long, the branch+remote substring eats so much space that few tmux windows name, if any, become readable or visible.

Example:
image

This problem would easily be solved by truncating the branch+remote substring. A sensible default in tmgb.conf + possibility to disable the truncating (with xxx_length=-1 or 0?). I guess the truncation could take effect on each component of the substring, replacing truncated parts with ellipsis, so as to still show the beggining of the current branch, and the beggining of the remote.

I guess providing a percentage would give better results than an absolute length.

Doesn’t work with ZSH

My shell is ZSH and when I add tmux-gitbar to my configuration, it does nothing (and I’m in a Git repo, both my ZSH and my Tmux (attach -c)).

I thought I’m doing something wrong, but then I found it relies on the $PROMPT_COMMAND which is a Bash thing.

No bar on tmux 2.1.

Output of tmux -V && echo $SHELL:

tmux 2.1
/bin/bash

My ~/.tmux.conf file can be found at this link (my GitHub repository).

I've tried cd'ing into directories that contain a git repository and I'm seeing no change in my tmux status bar. I don't seem to understand what the problem is.

PS - I'm fairly new to tmux so I may be missing out on something crucial.

Problem to install

Hi,

After installation, I have only this icon on tmux status bar.
image

I tried to change zsh to bash, minimal tmux.conf, new ubuntu user but I have only the same icon.
Did I forget something?

Bug when reading a newly created repo

I noticed that if you enter a folder and hit git init, gitbar seems to have no code handle for having the git folder but no commits. Here follow my log:


/home/willian/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: on: integer expression expected        
/home/willian/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: master: integer expression expected    
/home/willian/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: _NO_REMOTE_TRACKING_: integer expression expected                                                                                            
/home/willian/.tmux-gitbar/lib/tmux-gitbar.sh: line 128: test: ^: integer expression expected

Am I right? I could fix this issue if necessary. Just wanted to confirm with you guys before.

Make Tmux-gitbar styles/colors optional

Copy paste from issue #28, created by @adrianluff:

(Additionally), the current TMGB behavior requires duplicate, manual configuration of colors and styles in TMGB. This makes it unfriendly for use with plugins like vim-tmuxline. Further TMGB enhancement is possible by making TMGB colors and styles optional. I tested this by simply commenting two lines in tmux-gitbar.sh:

#tmux set-window-option "status-$TMGB_STATUS_LOCATION-style" "$TMGB_STYLE" > /dev/null
#tmux set-window-option "status-$TMGB_STATUS_LOCATION-length" 180 > /dev/null

This is only a partial solution but it allows the TMGB information to be combined with the user's existing tmux colorscheme or theme more easily.

An ideal implementation of this issue would have a conf file setting to enable or disable both of these enhancements rather than my hack-y solutions. Here's an example of what these changes allow.

image

tmux-gitbar.conf should be autogenerated on first run

The configuration file should be:

  • auto-generated on update-gitbar first run (why not during interpreting of tmux.conf as this would not add any workload to update-gitbar)
  • out of version control

This would permit to modify the default configuration, and not having it overwritten by tmux-gitbar updates.
Obviously if it already exists it should not be recreated...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.