Make your Tmux beautiful

Install Tmux
Follow https://github.com/tmux/tmux/wiki to install Tmux in your preferred OS.
Mac os users:
brew install tmux
Ubuntu users:
sudo apt update && sudo apt -y install tmux
Start using tmux
Create a new Tmux session and we will customize it.
tmux new -S <your session name>
# example:
tmux new -S tmux-conf
Create a Tmux configuration file
Create a tmux config file in your root directory ~/.tmux.conf and start adding the following scripts to customize the default Tmux UI and behaviors.
vim ~/.tmux.conf
# ~/.tmux.conf
unbind -r
bind r source-file ~/.tmux.conf
set -g prefix C-b
Here we are telling Tmux set r to reload the Tmux config and apply the changes to the current tmux session. And also we are setting C-b as a prefix key.
So if you do C-b + r your Tmux session should reload and new changes will get applied
Next we will set Vim keybindings to switch between panes
# act like vim
setw -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
Install Tmux Plugin Manager
Next, lets install Tmux plugin manager https://github.com/tmux-plugins/tpm.
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Put this at the bottom of ~/.tmux.conf
# ...
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
# Navigate tmux panes with `C-hjkl` just like vim.
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'dracula/tmux'
set -g @dracula-show-powerline true
set -g @dracula-fixed-location "<Your city>"
set -g @dracula-show-fahrenheit false
set -g @dracula-plugins "weather"
set -g @dracula-show-flags true
set -g @dracula-show-left-icon session
set -g @dracula-show-empty-plugins false
set -g status-position top
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Run C-b + I to install all the tmux plugins from your config file anytime you add new plugins
My complete .tmux.conf
###########################
# Configuration
###########################
# use 256 term for pretty colors
# set -g default-terminal "screen-256color" # making tmux slow
set -g default-terminal "xterm-256color"
# Enable mouse support
set -g mouse on
# increase scroll-back history
set -g history-limit 5000
# use vim key bindings
setw -g mode-keys vi
# decrease command delay (increases vim responsiveness)
set -sg escape-time 1
# increase repeat time for repeatable commands
set -g repeat-time 1000
# start window index at 1
set -g base-index 1
# start pane index at 1
setw -g pane-base-index 1
# highlight window when it has new activity
setw -g monitor-activity on
set -g visual-activity on
# re-number windows when one is closed
set -g renumber-windows on
# Fix nightfly color scheme to display correctly inside tmux
set -ga terminal-overrides ',xterm-256color:Tc'
# enable pbcopy and pbpaste
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/README.md
# set-option -g default-command "reattach-to-user-namespace -l zsh"
###########################
# Key Bindings
###########################
# tmux prefix
set -g prefix C-b
# paste
unbind C-p
bind C-p paste-buffer
# window splitting
unbind %
bind | split-window -h
unbind '"'
bind - split-window -v -p 20
# quickly switch panes
unbind ^B
bind ^B select-pane -t :.+
# switch panes using Alt-arrow without prefix
bind -n M-h select-pane -L
bind -n M-l select-pane -R
bind -n M-k select-pane -U
bind -n M-j select-pane -D
# swap windows
bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
# Quickly view system & process info in htop
bind-key h split-window -h "htop"
# Quickly edit todo list
bind-key w split-window -h "vim ~/vimwiki/index.md"
# rails specific
bind-key -n M-s split-window -h "bundle exec sidekiq"
bind-key -n M-r split-window -v -p 20 "redis-server"
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
###########################
# Status Bar
###########################
# set refresh interval for status bar
set -g status-interval 30
# center the status bar
set -g status-justify left
# show session, window, pane in left status bar
set -g status-left-length 40
set -g status-left '#[fg=green]#S#[fg=blue] #I:#P #[default]'
# show hostname, date, time, and battery in right status bar
set-option -g status-right '#[fg=green]#H#[default] %m/%d/%y %I:%M #[fg=red]#(battery discharging)#[default]#(battery charging)#{net_speed}'
###########################
# Colors
###########################
# color status bar
set -g status-style bg=colour235
set -g status-style fg=white
# highlight current window
set-window-option -g window-status-current-style bg=black
set-window-option -g window-status-current-style fg=green
# set color of active pane
set -g pane-border-style bg=colour235
set -g pane-border-style fg=black
set -g pane-active-border-style bg=green
set -g pane-active-border-style fg=black
# Resize pane
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
###########################
# Plugins
###########################
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'christoomey/vim-tmux-navigator'
# Display internet download and upload speed
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
About the author
I am a full-stack Ruby on Rails developer with experience in PostgreSQL, Docker, Heroku, and performance optimization. I love exploring new technology stacks and have recently developed an interest in mobile app development using Flutter. My skills in test-driven development and fixing security vulnerabilities have helped me deliver high-quality, reliable code. I am also currently learning about machine learning and its applications in real-world problem-solving. I bring a unique combination of technical expertise, creative problem-solving, and a passion for learning to any team. I am committed to delivering elegant and efficient software solutions and excited to contribute to an innovative and dynamic team that shares this vision.
Comments
Join the discussionNo comments yet. Be the first to comment.

