arl / tmux-gitbar Goto Github PK
View Code? Open in Web Editor NEWGit in your tmux status bar
License: GNU General Public License v3.0
Git in your tmux status bar
License: GNU General Public License v3.0
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.
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.
This is what is shown on Linux with the Fixed font, using tmux Powerline:
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.
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.
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 - ^ - . | ✔
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.
With the default settings, and I see the declarations in the tmux-gitbar.conf, this gets written to my terminal.
bad colour: fg=white,bg=black
Ubuntu Wily
gnome-terminal
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.
Got following message with tmux 1.8 and gitbar is not updating.
unknown option: status-right-style
As it was also the case in bash-git-prompt, the ✔ symbol, indicating a clean working tree, should not be a separate keyword.
Instead #{git_flags}
should expand to ✔ when the working tree is clean, and to the succession of dirty flags otherwise. They are mutually exclusive and they both represent related information.
This would also make simpler the status definition.
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 | ```
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
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.
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:
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'
bad colour:
bad colour:
is displayed when:
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.
tmux v2.3 has been released, with a nice changelog's .
How could tmux-gitbar take advantage of the new tmux features, especially from:
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.
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
$ 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...
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!
Opening this problem reported on #40 by @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.
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
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.
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
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"
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?
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?
Detect those special working tree status and show it in the bar?
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
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.
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.
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.
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.
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.
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.
The configuration file should be:
update-gitbar
first run (why not during interpreting of tmux.conf
as this would not add any workload to update-gitbar
)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...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.