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

Appending to the status bar #21

Closed
zachschultz opened this issue Jan 30, 2019 · 15 comments
Closed

Appending to the status bar #21

zachschultz opened this issue Jan 30, 2019 · 15 comments

Comments

@zachschultz
Copy link

It'd be nice to be able to customize the themes further. I'm trying to add a battery status indicator to my status-right, and right now below the import of the themepack theme I have written:

set -g status-right "#[fg=colour235,bg=colour233]#[fg=colour240,bg=colour235] %H:%M:%S #[fg=colour240, bg=colour235]#[fg=colour233,bg=colour240] %d-%b-%y #[fg=colour245,bg=colour240]#[fg=colour232,bg=colour245,bold] #H #{battery_icon} #{battery_percentage} "

It shows up for the first render, but then it looks like the theme is overwriting my status-right immediately after

@gnumoksha
Copy link

Did you solve this?

@disrupted
Copy link

I'd guess customization is not supported in its current state but wanted to add my +1 to this.

@lucasprag
Copy link

Yeah, I'd like to know about a better way of customizing it, but for now I can add more useful information to my status-right if I place my set-option -g status-right after run '~/.tmux/plugins/tpm/tpm'.

Example:

set -g @themepack 'powerline/default/cyan'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'jimeh/tmux-themepack'

# Initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'


# this is here to overwrite status-right from my tmux theme
set-option -g status-right '#(basename #{pane_current_path})'

@lucasprag
Copy link

In my case I did this:

set -g @themepack 'powerline/default/cyan'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'jimeh/tmux-themepack'

# initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'

# this is here to overwrite my tmux theme
set -g status-left "#[fg=colour232,bg=colour39,bold] #S #[fg=colour39,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(basename #{pane_current_path}) #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #I:#P #[fg=colour235,bg=colour233,nobold]"
set -g status-right ""
set -g status-justify right

@jimeh
Copy link
Owner

jimeh commented Apr 29, 2019

I might have a solution to this soon. I'm thinking something along the lines of the themes define a bunch of fields/areas of information that can be overridden to customize them. It might differ a bit between themes though as the powerline themes have effectively three pieces of information on both the left and right sides, while other themes don't.

I'm currently working on support Tmux 2.9 while still retaining support for 1.8 and earlier. This work should make it rather easy to add in the kind of customizations mentioned in this issue :)

@eh-am
Copy link

eh-am commented May 4, 2019

@lucasprag approach wasn't working for me until I realized I was running run -b '~/.tmux/plugins/tpm/tpm', which I believe was finishing after a certain time t, essentially overwriting the overwrites(!), so in the end just had to remove the b flag

@Teknitix
Copy link

Has there been any update on this? This is a lovely theme to use, but status bar customization and appending is really needed. Even just providing support for the right status indicators for the following plugins would help a lot:
https://github.com/tmux-plugins/tmux-battery
https://github.com/tmux-plugins/tmux-online-status

@oemergenc
Copy link

oemergenc commented Oct 19, 2019

Hi, any progress on this?

Update:
As a current workaround one can use tmux-cpu and tmux-mem for memory and cpu usage.

Here is a snippet of my tmux.conf file:

run '~/.tmux/plugins/tpm/tpm'

set -g status-left-length 100
status_cpu="#[fg=colour24,bg=colour245,nobold]#[fg=colour235,bg=colour245]#(/usr/local/bin/tmux-cpu  --format '#[fg=:color] :percent #[fg=black] :percent5 #[fg=black] :percent15')"
status_memory="#[fg=colour245,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(/usr/local/bin/tmux-mem --format  ":currentBytes/:totalBytes")"
set -g status-left "#[fg=colour232,bg=colour24,bold] #S $status_cpu $status_memory #[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #I:#P #[fg=colour235,bg=colour233,nobold]"

I am using the blue powerline theme, you may need to adjust to your settings. looks like this:
example

@Teknitix
Copy link

Do you mind explaining the code and how to apply it?

@jimeh
Copy link
Owner

jimeh commented Oct 27, 2019

It's taken a lot longer than I thought to find enough time to lay the groundwork for this. But I've finally got PR #30 ready for testing. It makes it possible for end-users to easily customize any part of the themes.

The powerline themes for example have three areas on both the left and the right sides of the status bar, there's a total of six customizable options, they're set like like in the themes:

set -goq @themepack-status-left-area-left-format "#S"
set -goq @themepack-status-left-area-middle-format "#(whoami)"
set -goq @themepack-status-left-area-right-format "#I:#P"
set -goq @themepack-status-right-area-left-format "%H:%M:%S"
set -goq @themepack-status-right-area-middle-format "%d-%b-%y"
set -goq @themepack-status-right-area-right-format "#H"

The -o option means that it only sets the option if it is unset, meaning users can override the value set by the theme, by simply setting it themselves in their .tmux.conf file before loading the theme. When using TPM, the theme is not loaded until TPM itself is loaded. For example:

set -g @plugin 'jimeh/tmux-themepack'

set -g @themepack 'powerline/default/green'
set -g @themepack-status-left-area-left-format "#H : #S"

run "${HOME}/.tmux/plugins/tpm/tpm"

Additional options which you can customize can be found by simply looking at the source for the theme file itself, as pretty much any option in there beginning with a @ are available for customization.

@oemergenc
Copy link

@Teknitix

Actually its pretty straight forward. Simply install the mentioned command line utilities tmux-cpu and tmux-mem. Please note, those tools depend on nodejs (npm). You could also use other tools if you like to. For me those are doing a quite good job.

Something like this will install the tools:

npm install -g tmux-cpu
npm install -g tmux-mem

And then edit your tmux.conf file to include something like the following at the end of the file:

# all your configs ...
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'jimeh/tmux-themepack'
set -g @themepack 'powerline/block/blue'
# maybe other plugins ... 

run '~/.tmux/plugins/tpm/tpm'

# customization of powerline/block/blue theme
set -g status-left-length 100
status_session="#[fg=colour232,bg=colour24,bold] #S"
status_cpu="#[fg=colour24,bg=colour245,nobold]#[fg=colour235,bg=colour245] #(/usr/local/bin/tmux-cpu --format '[#[fg=:color]:spark#[fg=black]] #[fg=:color]:percent #[fg=black]:percent5 #[fg=black]:percent15')"
status_memory="#[fg=colour245,bg=colour240,nobold]#[fg=colour233,bg=colour240] #(/usr/local/bin/tmux-mem --format '[#[fg=:color]:spark#[fg=black]] #[fg=:color]:currentBytes#[fg=black]/:totalBytes')"
status_panes="#[fg=colour240,bg=colour235]#[fg=colour240,bg=colour235] #I:#P #[fg=colour235,bg=colour233,nobold]"
set -g status-left "$status_session $status_cpu $status_memory $status_panes"

Reload tmux (prefix + I) or restart your session and you should be good to go.

@jimeh
Copy link
Owner

jimeh commented Dec 22, 2019

With #30 now merged, I believe this issue is resolved.

This is done like I described in my earlier comment, by setting specific @-prefixed Tmux options before loading the theme. For an example of variables available, check the source for any of the themes, for example:

https://github.com/jimeh/tmux-themepack/blob/1.1.0/powerline/default/green.tmuxtheme

@jimeh jimeh closed this as completed Dec 22, 2019
@ThaDaVos
Copy link

I'm sorry for commenting on an old issue - but I'm doing the exact which is documented here but for me I don't see my status bar changing, this is what I have (one of the lines is cut off as it doesn't fit on the screen):

set -g @themepack-status-left-area-left-prefix "#{prefix_highlight}"
set -g @themepack-status-right-area-right-suffix "#(cat ~/project_revenew_scraper) | Battery: #(cat /sys/class/power_supply/BAT1/status) #[fg=colour155]#(cat /sys/class/power_supply/BAT1/capacity)% | #[fg=colou$
set -g @themepack 'powerline/block/cyan'
# Plugins
set -g @plugin 'jimeh/tmux-themepack'
set -g @plugin 'pschmitt/tmux-ssh-split'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-sidebar'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'                                                                                                                                                     

@ThaDaVos
Copy link

Solution found here: #41

@tataue
Copy link

tataue commented Aug 26, 2020

@lucasprag approach wasn't working for me until I realized I was running run -b '~/.tmux/plugins/tpm/tpm', which I believe was finishing after a certain time t, essentially overwriting the overwrites(!), so in the end just had to remove the b flag

-b flags confused me all the time. I have to quit tmux again and again to look at what has changed.
now just reload the config, everything works as expected.

thanks~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants