diff --git a/.gitignore b/.gitignore index aeaf2bd..4fe6511 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ .LSOverride # Icon must end with two \r -Icon +Icon # Thumbnails ._* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..aa55d21 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "plugins/sysstat"] + path = plugins/sysstat + url = git@github.com:samoshkin/tmux-plugin-sysstat.git diff --git a/install.sh b/install.sh index e41898e..5e185c4 100755 --- a/install.sh +++ b/install.sh @@ -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" + + + + + + + + + diff --git a/plugins/sysstat b/plugins/sysstat new file mode 160000 index 0000000..21a3fd6 --- /dev/null +++ b/plugins/sysstat @@ -0,0 +1 @@ +Subproject commit 21a3fd61b41c0d073c00d4989ae1b775c7c1ef51 diff --git a/tmux/theme.conf b/tmux/theme.conf index 719657f..6b01db7 100644 --- a/tmux/theme.conf +++ b/tmux/theme.conf @@ -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 +# ===================================== +# === 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 -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 \ No newline at end of file +# 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" diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 1a62a37..efe00fb 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -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 @@ -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 # ============================ @@ -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'