Skip to content

Commit

Permalink
Finish with appearence and status bar. Integrate various plugins incl…
Browse files Browse the repository at this point in the history
…uding tmux-plugin-sysstat
  • Loading branch information
samoshkin committed Nov 21, 2017
1 parent 943be96 commit 8570ef7
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.LSOverride

# Icon must end with two \r
Icon
Icon

# Thumbnails
._*
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "plugins/sysstat"]
path = plugins/sysstat
url = [email protected]:samoshkin/tmux-plugin-sysstat.git
40 changes: 26 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,40 @@ is_app_installed() {
REPODIR="$(cd "$(dirname "$0")"; pwd -P)"
cd "$REPODIR";

git submodule update --recursive --init --quiet;

if ! is_app_installed tmux; then
printf "$(tput setaf 1)WARNING:$(tput sgr0) \"tmux\" command is not found. \
Install \"tmux\" yourself\n"
Install it first\n"
exit 1
fi

# .tmux may already exist (created by tmux plugin manager)
rsync -aq --backup ./tmux/ "$HOME"/.tmux
if [ ! -e "$HOME/.tmux/plugins/tpm" ]; then
printf "$(tput setaf 1)WARNING:$(tput sgr0) Cannot found TPM (Tmux Plugin Manager) \
at default location: \$HOME/.tmux/plugins/tpm. Install it first\n"
exit 1
fi

if [ -e "$HOME/.tmux.conf" ]; then
printf "Found existing .tmux.conf in your \$HOME directory. Will backup it and overwrite with new .tmux.conf file? OK (y/n): "
read -r answer
if echo "$answer" | grep -iq "^n"; then
printf "Install config manually using command below:\n\n";
printf "\t cd && ln -sf .tmux/tmux.conf .tmux.conf\n";
exit 1;
fi
printf "Found existing .tmux.conf in your \$HOME directory. Will create a backup at $HOME/.tmux.conf.bak\n"
fi

ln -sf --backup=numbered .tmux/tmux.conf "$HOME"/.tmux.conf;
printf "$(tput setaf 2)OK:$(tput sgr0) Files are copied to \$HOME/.tmux and symlink at \$HOME/.tmux.conf is created\n"
git submodule init;

rsync -aq ./tmux/ "$HOME"/.tmux

ln -sf --backup --suffix=.bak .tmux/tmux.conf "$HOME"/.tmux.conf;

"$HOME"/.tmux/plugins/tpm/bin/install_plugins

printf "$(tput setaf 2)OK:$(tput sgr0) Completed\n"












1 change: 1 addition & 0 deletions plugins/sysstat
Submodule sysstat added at 21a3fd
68 changes: 26 additions & 42 deletions tmux/theme.conf
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
# TODO: extract colour to variables

# Status line
set -g status on
set -g status-interval 10
set -g status-justify centre
set -g status-left-length 70
set -g status-right-length 90


wg_battery='#{battery_status_fg} #{battery_icon} #{battery_percentage} #{battery_remain}'

wg_loadavg='#[fg=colour167,bg=colour235]#( \
uptime | cut -d "," -f 3- | cut -d ":" -f2 | sed -e "s/^[ \t]*//" \
)#[default]'

wg_date='#[fg=colour167,bg=colour235] %h %d %H:%M #[default]'

wg_session='#[fg=green]#S:#[fg=default]#I.#P'
wg_host='#[fg=colour167,bg=colour235]#(echo $USER)@#H#[default]'

wg_is_zoomed='#[fg=colour231,bg=colour04]#{?window_zoomed_flag,[Z],}#[default]'
wg_clients_attached='#[fg=cyan]#{?session_many_attached,~#{session_attached},}#[default]'


# CPU is updated to often, put stress on CPU
# wg_cpu='#{cpu_fg_color}#{cpu_percentage}'
# wg_cpu="#(iostat -c -y 5 1 | tail -n 2 | head -n 1)"


set -g status-style fg=white,bg=colour235
set -g status-right "$wg_loadavg $wg_battery $wg_host $wg_date #{online_status}"
set -g status-left "$wg_session $wg_clients_attached $wg_is_zoomed #{prefix_highlight}"


setw -g window-status-style fg=white,dim
setw -g window-status-current-style fg=brightwhite,nodim,bold,bg=brightred
setw -g window-status-activity-style fg=black,bg=cyan


# Appearence
setw -g pane-active-border-style fg=red
set -g message-style fg=green,bold,bg=black
# =====================================
# === Theme ===
# =====================================

# Feel free to NOT use this variables at all (remove, rename)
# this are named colors, just for convenience
color_orange="colour166" # 208, 166
color_purple="colour134" # 135, 134
color_green="colour076" # 070
color_blue="colour39"
color_yellow="colour220"
color_red="colour160"
color_black="colour232"
color_white="white" # 015

# This is a theme CONTRACT, you are required to define variables below
# Change values, but not remove/rename variables itself
color_dark="$color_black"
color_light="$color_white"
color_session_text="$color_blue"
color_status_text="colour245"
color_main="$color_orange"
color_secondary="$color_purple"
color_level_good="$color_green"
color_level_warn="$color_yellow"
color_lelel_achtung="$color_red"
97 changes: 83 additions & 14 deletions tmux/tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ set -g allow-rename off
set -g default-terminal "screen"
set -g remain-on-exit off

# aggressive-resize [on | off]
# alternate-screen [on | off]


# Change prefix key to C-a, easier to type, same to "screen"
unbind C-b
set -g prefix C-a
Expand Down Expand Up @@ -148,12 +152,85 @@ unbind -T copy-mode-vi MouseDragEnd1Pane
bind -T copy-mode-vi MouseDown1Pane select-pane \; send-keys -X copy-selection


# ===================================
# === Appearence and status bar ===
# ===================================
# =====================================
# === Appearence and status bar ===
# ======================================

# Load theme
source ~/.tmux/theme.conf

set -g mode-style "fg=default,bg=$color_main"

# command line style
set -g message-style "fg=$color_main,bg=$color_dark"

# status line style
set -g status-style "fg=$color_status_text,bg=$color_dark"

# window segments in status line
set -g window-status-separator ""
separator_powerline_left=""
separator_powerline_right=""

setw -g window-status-style "fg=$color_status_text,bg=$color_dark"
setw -g window-status-format " #I:#W "
setw -g window-status-current-style "fg=$color_light,bold,bg=$color_main"
setw -g window-status-current-format "#[fg=$color_dark,bg=$color_main]$separator_powerline_right#[default] #I:#W# #[fg=$color_main,bg=$color_dark]$separator_powerline_right#[default]"

# when window has monitoring notification
setw -g window-status-activity-style "fg=$color_main,bg=$color_dark"

# outline for active pane
setw -g pane-active-border-style "fg=$color_main"

# general status bar settings
set -g status on
set -g status-interval 5
set -g status-position top
set -g status-justify left
set -g status-right-length 140

# define widgets we're going to use in status bar
# note, that this is not the complete list, some of them are loaded from plugins
wg_session="#[fg=$color_session_text] #S #[default]"
wg_battery="#{battery_status_fg} #{battery_icon} #{battery_percentage}"
wg_date="#[fg=$color_secondary]%h %d %H:%M#[default]"
wg_host="#[fg=$color_secondary]#(echo $USER)#[default]@#H"
wg_is_zoomed="#[fg=$color_dark,bg=$color_secondary]#{?window_zoomed_flag,[Z],}#[default]"

set -g status-left "$wg_session"
set -g status-right "#{prefix_highlight} $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_host | $wg_date $wg_battery #{online_status}"

# online and offline icon for tmux-online-status
set -g @online_icon "#[fg=$color_level_good]●#[default]"
set -g @offline_icon "#[fg=$color_level_achtung]●#[default]"

# Configure view templates for tmux-plugin-sysstat "MEM" and "CPU" widget
set -g @sysstat_mem_size_unit "G"
set -g @sysstat_mem_view_tmpl '#[fg=#{mem.color}]MEM:#{mem.pused}#[default] (#{mem.used})'
set -g @sysstat_cpu_view_tmpl '#[fg=#{cpu.color}]CPU:#{cpu.pused}#[default]'

# Configure colors for tmux-plugin-sysstat "MEM" and "CPU" widget
set -g @sysstat_cpu_color_low "$color_level_good"
set -g @sysstat_cpu_color_medium "$color_level_warn"
set -g @sysstat_cpu_color_high "$color_level_achtung"
set -g @sysstat_mem_color_ok "$color_level_good"
set -g @sysstat_mem_color_stress "$color_level_achtung"

# Configure tmux-battery widget colors
set -g @batt_color_full_charge "#[fg=$color_level_good]"
set -g @batt_color_high_charge "#[fg=$color_level_good]"
set -g @batt_color_medium_charge "#[fg=$color_level_warn]"
set -g @batt_color_low_charge "#[fg=$color_level_achtung]"

# Configure tmux-prefix-highlight colors
set -g @prefix_highlight_output_prefix '['
set -g @prefix_highlight_output_suffix ']'
set -g @prefix_highlight_fg "$color_dark"
set -g @prefix_highlight_bg "$color_secondary"
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_copy_mode_attr "fg=$color_dark,bg=$color_secondary"

# TODO: Not ready yet
# source ~/.tmux/theme.conf


# ============================
Expand All @@ -174,17 +251,9 @@ set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'samoshkin/tmux-plugin-sysstat'

# Plugin properties
set -g @batt_remain_short true

set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_output_prefix '['
set -g @prefix_highlight_output_suffix ']'

set -g @online_icon "#[fg=green]●#[default]"
set -g @offline_icon "#[fg=red]●#[default]"

set -g @sidebar-tree 't'
set -g @sidebar-tree-focus 'T'
set -g @sidebar-tree-command 'tree -C'
Expand Down

0 comments on commit 8570ef7

Please sign in to comment.