Skip to content

Instantly share code, notes, and snippets.

@mchaver
Last active March 11, 2022 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mchaver/8785674c9a55e5fc05d2b0535decef25 to your computer and use it in GitHub Desktop.
Save mchaver/8785674c9a55e5fc05d2b0535decef25 to your computer and use it in GitHub Desktop.
My personal tmux configuration file
##############################################################################
# DON'T USE A LOGIN SHELL
# set -g default-command "${SHELL}"
##############################################################################
# ALWAYS START A SESSION (IF NEEDED)
# new-session
# plugins
set -g @plugin 'thewtex/tmux-mem-cpu-load'
set -g @plugin 'samoshkin/tmux-plugin-sysstat'
##############################################################################
# SWAP CTRL-B PREFIX KEY WITH CTRL-Z
unbind C-b
set-option -g prefix C-z
bind-key C-z send-prefix
##############################################################################
# SESSIONS
bind C new-session
bind R command-prompt "rename-session %%"
bind K command-prompt "kill-session"
##############################################################################
# WINDOWS
# START WINDOWS AND PANES AT 1, NOT 0
set -g base-index 1
setw -g pane-base-index 1
# RENUMBER THE WINDOWS WHEN ONE IS CLOSED
set-option -g renumber-windows on
bind c new-window -c "#{pane_current_path}"
bind r command-prompt "rename-window -t %%"
bind k command-prompt "kill-window ~"
bind-key h split-window -h
bind-key v split-window -v
unbind '"'
unbind %
bind P swap-window -t -1
bind N swap-window -t +1
##############################################################################
# PANES
# bind w select-pane -D
# bind a select-pane -L
# bind s select-pane -U
# bind d select-pane -R
# bind W resize-pane -D 5
# bind A resize-pane -L 5
# bind S resize-pane -U 5
# bind D resize-pane -R 5
##############################################################################
# ENABLE MOUSE MODE (tmux 2.1 and above)
set -g mouse on
##############################################################################
# APPLICATIONS
bind C-t new-window -n monitor "exec htop"
bind C-m new-window -n commander "exec mc"
##############################################################################
# GLOBAL SETTINGS
set -g aggressive-resize on
set -g automatic-rename off
set -g monitor-activity off
set -g visual-activity off
##############################################################################
# RELOAD THE CONFIG FILE
bind r source-file ~/.tmux.conf
##############################################################################
# THEME
set -g default-terminal "screen-256color"
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_ok="$color_green"
color_level_warn="$color_yellow"
color_level_stress="$color_red"
color_window_off_indicator="colour088"
color_window_off_status_bg="colour238"
color_window_off_status_current_bg="colour254"
# ======================================
# === Appearence and status bar ========
# ======================================
# set -g mode-style "fg=default,bg=$color_main"
# command line style
# set -g message-style "fg=$color_main,bg=$color_green"
# status line style
# set -g status-style "fg=$color_status_text,bg=$color_green"
# set -g status-style 'bg=colour2'
# pane border
pane_border="#6272a4"
active_pane_border="#ff79c6"
set -g pane-border-style fg="$pane_border"
set -g pane-active-border-style fg="$active_pane_border"
# message text
message_bg="#44475a"
message_fg="#8be9fd"
set -g message-style bg="$message_bg",fg="$message_fg"
# status left
status_style_bg="#44475a"
status_style_fg="#bd93f9"
set -g status-style bg="$status_style_bg",fg="$status_style_fg"
set -g status-interval 1
status_left_active="#[bg=#f8f8f2]#[fg=#282a36]#{?client_prefix,#[bg=#ff79c6],} 發大財 "
status_left_inactive="#[bg=#f8f8f2]#[fg=#282a36]#{?client_prefix,#[bg=#ff79c6],} 雲端 "
set -g status-left "$status_left_active"
# are we zoomed into a pane?
set -ga status-left '#[bg=#44475a]#[fg=#ff79c6] #{?window_zoomed_flag, ↕ , }'
# window status
set-window-option -g window-status-style fg='#bd93f9',bg=default
set-window-option -g window-status-current-style fg='#ff79c6',bg='#282a36'
set -g window-status-current-format "#[fg=#44475a]#[bg=#bd93f9]#[fg=#f8f8f2]#[bg=#bd93f9] #I #W #[fg=#bd93f9]#[bg=#44475a]"
set -g window-status-format "#[fg=#f8f8f2]#[bg=#44475a]#I #W #[fg=#44475a] "
# set -g status-right '#[fg=#8be9fd,bg=#44475a]#[fg=#44475a,bg=#8be9fd] #(tmux-mem-cpu-load -g 5 --interval 2) '
# run-shell 'source ~/.time-zh.sh'
# set -g status-right '#[fg=#8be9fd,bg=#44475a]#[fg=#44475a,bg=#8be9fd] '
# set -g status-right '#[fg=#8be9fd,bg=#44475a]#[fg=#44475a,bg=#8be9fd] #(tmux-mem-cpu-load -g 5 --interval 2) '
set -g @sysstat_cpu_view_tmpl '#{cpu.pused}'
set -g @sysstat_mem_view_tmpl '#{mem.used}/#{mem.total}'
set -g status-right '#[fg=#8be9fd,bg=#44475a]#[fg=#44475a,bg=#8be9fd] '
set -ga status-right "CPU: #{sysstat_cpu} "
set -ga status-right '#[fg=#b0fd8b,bg=#8be9fd]#[fg=#44475a,bg=#b0fd8b]'
set -ga status-right " #{sysstat_mem} "
#b0fd8b
set -ga status-right '#[fg=#ff79c6,bg=#b0fd8b]#[fg=#44475a,bg=#ff79c6] #(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") '
set -ga status-right '#[fg=#bd93f9,bg=#ff79c6]#[fg=#f8f8f2,bg=#bd93f9] %H:%M:%S #[fg=#6272a4]%Y-%m-%d '
set -g status-right-length 150
# set -ga status-right "#[fg=#f8f8f2,bg=#bd93f9] $day_of_week_zh "
# set -ga status-right '#[fg=#6272a4]%Y-%m-%d '
# ==============================================
# === Nesting local and remote sessions ========
# ==============================================
# Session is considered to be remote when we ssh into host
if-shell 'test -n "$SSH_CLIENT"' \
'source-file ~/.tmux.remote.conf'
# We want to have single prefix key "C-a", usable both for local and remote session
# we don't want to "C-a" + "a" approach either
# Idea is to turn off all key bindings and prefix handling on local session,
# so that all keystrokes are passed to inner/remote session
# see: toggle on/off all keybindings · Issue #237 · tmux/tmux - https://github.com/tmux/tmux/issues/237
# Also, change some visual styles when window keys are off
bind -T root F12 \
set prefix None \;\
set key-table off \;\
# set -g status-left "$status_left_inactive" \;\
# set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
# set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
# set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off F12 \
set -u prefix \;\
set -u key-table \;\
# set -g status-left "$status_left_active" \;\
# set -u status-style \;\
# set -u window-status-current-style \;\
# set -u window-status-current-format \;\
refresh-client -S
run '~/.tmux/plugins/tpm/tpm'
##############################################################################
# DON'T USE A LOGIN SHELL
# set -g default-command "${SHELL}"
##############################################################################
# ALWAYS START A SESSION (IF NEEDED)
# new-session
##############################################################################
# SWAP CTRL-B PREFIX KEY WITH CTRL-Z
unbind C-b
set-option -g prefix C-z
bind-key C-z send-prefix
##############################################################################
# SESSIONS
bind C new-session
bind R command-prompt "rename-session %%"
bind K command-prompt "kill-session"
##############################################################################
# WINDOWS
# START WINDOWS AND PANES AT 1, NOT 0
set -g base-index 1
setw -g pane-base-index 1
# RENUMBER THE WINDOWS WHEN ONE IS CLOSED
set-option -g renumber-windows on
bind c new-window -c "#{pane_current_path}"
bind r command-prompt "rename-window -t %%"
bind k command-prompt "kill-window ~"
#bind | split-window -c "#{pane_current_path}" -h
#bind - split-window -c "#{pane_current_path}"
bind-key h split-window -h
bind-key v split-window -v
unbind '"'
unbind %
bind P swap-window -t -1
bind N swap-window -t +1
##############################################################################
# PANES
bind w select-pane -D
bind a select-pane -L
bind s select-pane -U
bind d select-pane -R
bind W resize-pane -D 5
bind A resize-pane -L 5
bind S resize-pane -U 5
bind D resize-pane -R 5
##############################################################################
# ENABLE MOUSE MODE (tmux 2.1 and above)
set -g mouse on
##############################################################################
# APPLICATIONS
bind C-t new-window -n monitor "exec htop"
bind C-m new-window -n commander "exec mc"
##############################################################################
# GLOBAL SETTINGS
set -g aggressive-resize on
set -g automatic-rename off
set -g monitor-activity off
set -g visual-activity off
##############################################################################
# RELOAD THE CONFIG FILE
bind r source-file ~/.tmux.conf
##############################################################################
# show status bar at bottom for remote session,
# so it do not stack together with local session's one
set -g status-position top
# Set port of SSH remote tunnel, where tmux will pipe buffers to transfer on local machine for copy
set -g @copy_backend_remote_tunnel_port 11988
# In remote mode we don't show "clock" and "battery status" widgets
set -g status-left "$wg_session"
set -g status-right "#{prefix_highlight} $wg_is_keys_off $wg_is_zoomed #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host | #{online_status}"
#!/bin/bash
echo "1"
day=$(date +"%A")
echo "1"
declare -A days_of_week=( ["Monday"]="一" ["Tuesday"]="二" ["Wednesday"]="三" ["Thursday"]="四" ["Friday"]="五" ["Saturday"]="六" ["Sunday"]="日")
echo "1"
day_of_week_zh="${days_of_week[$day]}"
echo "1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment