Skip to content

Instantly share code, notes, and snippets.

@mvillafuertem
Created March 16, 2026 11:26
Show Gist options
  • Select an option

  • Save mvillafuertem/a6b65ee88f6190bc26315e8f8bd1df84 to your computer and use it in GitHub Desktop.

Select an option

Save mvillafuertem/a6b65ee88f6190bc26315e8f8bd1df84 to your computer and use it in GitHub Desktop.
return {
'nvim-lualine/lualine.nvim',
-- Adapted from:
-- https://github.com/catppuccin/tmux/discussions/317#discussioncomment-14030975
opts = function(_, opts)
local auto = require 'lualine.themes.auto'
local colors = require('catppuccin.palettes').get_palette 'mocha'
local function separator()
return {
function()
return '│'
end,
color = { fg = colors.surface0, bg = 'NONE', gui = 'bold' },
padding = { left = 0, right = 0 },
}
end
local function custom_branch()
local gitsigns = vim.b.gitsigns_head
local fugitive = vim.fn.exists '*FugitiveHead' == 1 and vim.fn.FugitiveHead() or ''
local branch = gitsigns or fugitive
if branch == nil or branch == '' then
return ''
else
return ' ' .. branch
end
end
local modes = { 'normal', 'insert', 'visual', 'replace', 'command', 'inactive', 'terminal' }
for _, mode in ipairs(modes) do
if auto[mode] and auto[mode].c then
auto[mode].c.bg = 'NONE'
end
end
opts.options = vim.tbl_deep_extend('force', opts.options or {}, {
theme = auto,
component_separators = '',
section_separators = '',
globalstatus = true,
})
opts.sections = {
lualine_a = {
{
'mode',
fmt = function(str)
return str:sub(1, 1)
end,
padding = { left = 1, right = 1 },
},
},
lualine_b = {
{
custom_branch,
color = { fg = colors.green, bg = 'none' },
padding = { left = 1, right = 1 },
},
{
'diff',
colored = true,
diff_color = {
added = { fg = colors.teal, bg = 'none', gui = 'bold' },
modified = { fg = colors.yellow, bg = 'none', gui = 'bold' },
removed = { fg = colors.red, bg = 'none', gui = 'bold' },
},
source = nil,
padding = { left = 0, right = 1 },
},
separator(),
},
lualine_c = {
{
'filename',
file_status = true,
path = 1,
shorting_target = 20,
symbols = {
modified = '[+]',
readonly = '[-]',
unnamed = '[?]',
newfile = '[!]',
},
color = { fg = colors.blue, bg = 'none' },
padding = { left = 1, right = 1 },
},
{
'diagnostics',
sources = { 'nvim_diagnostic' },
sections = { 'error', 'warn', 'info', 'hint' },
diagnostics_color = {
error = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })
return { fg = (count == 0) and colors.green or colors.red, bg = 'none', gui = 'bold' }
end,
warn = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
return { fg = (count == 0) and colors.green or colors.yellow, bg = 'none', gui = 'bold' }
end,
info = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO })
return { fg = (count == 0) and colors.green or colors.blue, bg = 'none', gui = 'bold' }
end,
hint = function()
local count = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT })
return { fg = (count == 0) and colors.green or colors.teal, bg = 'none', gui = 'bold' }
end,
},
symbols = {
error = '󰅚 ',
warn = '󰀪 ',
info = '󰋽 ',
hint = '󰌶 ',
},
colored = true,
update_in_insert = false,
always_visible = false,
padding = { left = 0, right = 1 },
},
},
lualine_x = {
{
function()
local bufnr_list = vim.fn.getbufinfo { buflisted = 1 }
local total = #bufnr_list
local current_bufnr = vim.api.nvim_get_current_buf()
local current_index = 0
for i, buf in ipairs(bufnr_list) do
if buf.bufnr == current_bufnr then
current_index = i
break
end
end
return string.format(' %d/%d', current_index, total)
end,
color = { fg = colors.yellow, bg = 'none' },
padding = { left = 1, right = 1 },
},
},
lualine_y = {
separator(),
{
'filetype',
icon_only = true,
colored = false,
color = { fg = colors.blue, bg = 'none' },
padding = { left = 1, right = 1 },
},
},
lualine_z = {
separator(),
{
'location',
color = { fg = colors.red, bg = 'none' },
padding = { left = 1, right = 1 },
},
},
}
local dash_cwd = {
sections = {
lualine_y = {
function()
local session_root = vim.fn.environ()['TMUXIFIER_SESSION_ROOT']
local cwd = vim.fn.getcwd()
local local_cwd = vim.fn.fnamemodify(cwd, ':s?' .. session_root .. '?.?')
return local_cwd
end,
},
},
filetypes = { 'snacks_dashboard' },
}
opts.extensions = { dash_cwd }
return opts
end,
}
@mvillafuertem
Copy link
Copy Markdown
Author

# ~/.config/tmux/tmux.conf
bind r source-file "$HOME/.config/tmux/tmux.conf" \; display-message "Config reloading.."
unbind C-b
set-option -g prefix `
bind-key C-a send-prefix
set-option -g mouse on
set -g allow-passthrough on
setw -g monitor-activity on
set -g base-index 1
set -g default-terminal "tmux-256color"
set -s escape-time 0
set -s repeat-time 300
# window
unbind '"'
bind '/' splitw -v -c '#{pane_current_path}'
unbind '%'
bind '\' splitw -h -c '#{pane_current_path}'
bind ` last-window
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R
bind -r ^k resizep -U 4
bind -r ^j resizep -D 4
bind -r ^h resizep -L 8
bind -r ^l resizep -R 8
# copy
setw -g mode-keys vi
bind -r v copy-mode
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel

# bootstrap tpm
if "test ! -d ~/.tmux/plugins/tpm" \
   "run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'thewtex/tmux-mem-cpu-load'
set -g @plugin 'laktak/extrakto'

# config catppucin color
if-shell '[ -f ~/.config/tmux/colors.conf ]' "source-file ~/.config/tmux/colors.conf"

# status left look and feel
set -g status-left-length 100
set -g status-left ""
set -ga status-left "#{?client_prefix,#{#[bg=#{@thm_red},fg=default,bold]   #S },#{#[bg=default,fg=#{@thm_red},bold]   #S }}"
set -ga status-left "#[bg=default,fg=#{@thm_overlay0},none,bold]│"
set -ga status-left "#[bg=default,fg=#{@thm_green},bold]   #{pane_current_command} "
set -ga status-left "#[bg=default,fg=#{@thm_overlay0},none,bold]│"
set -ga status-left "#[bg=default,fg=#{@thm_blue},bold]   #{=/-10/...:#{s|$USER|~|:#{b:pane_current_path}}} "
set -ga status-left "#[bg=default,fg=#{@thm_overlay0},none,bold]#{?window_zoomed_flag,│,}"
set -ga status-left "#[bg=default,fg=#{@thm_yellow},bold]#{?window_zoomed_flag,   zoom ,}"

# status right look and feel
set -g status-right-length 100
set -g status-right ""
set -ga status-right "#[bg=default,fg=#{@thm_blue},bold]  #($TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load -i 2 -m 2 | awk \'{print substr($1, 1, 2)}\')%% "
set -ga status-right "#[bg=default,fg=#{@thm_overlay0},none,bold]│"
set -ga status-right "#[bg=default,fg=#{@thm_green},bold] 󰍛 #{cpu_percentage} "
set -ga status-right "#[bg=default,fg=#{@thm_overlay0},none,bold]│"
set -ga status-right "#[bg=default,fg=#{@thm_red},bold] 󱐋#{?#{e|>=:20,#{battery_percentage}},#{#[bg=#{@thm_red},fg=default,bold]},#{#[bg=default,fg=#{@thm_red},bold]}} #{battery_percentage} "
# set -ga status-right "#[bg=default,fg=#{@thm_red},bold] 󱐋#{?#{e|>=:20,#{battery_percentage}},#{#[bg=#{@thm_red},fg=default,bold]},#{#[bg=default,fg=#{@thm_green},bold]}} #{battery_percentage} "
# set -ga status-right "#[bg=default,fg=#{@thm_overlay0},none,bold]│"
# set -ga status-right "#[bg=default,fg=#{@thm_red},bold] 󰭦 %m-%d 󰅐 %H:%M "

# Configure Tmux
set -g status-position top
set -g status-style "bg=default"
set -g status-justify "absolute-centre"

# pane border look and feel
setw -g pane-border-status off
# setw -g pane-border-status top
setw -g pane-border-format ""
setw -g pane-border-style "bg=default,fg=#{@thm_overlay0}"
setw -g pane-active-border-style "bg=default,fg=#{@thm_red}"
setw -g pane-border-lines single

# window content (number)
# set -wg automatic-rename on
# set -g automatic-rename-format "window"
# set -g window-status-current-format " #I#{?#{!=:#{window_name},window},: #W,} "
# set -g window-status-format " #I#{?#{!=:#{window_name},window},: #W,} "

# set -g window-status-style "bg=default,fg=#{@thm_rosewater}"
# set -g window-status-last-style "bg=default,fg=#{@thm_peach}"
# set -g window-status-activity-style "bg=#{@thm_red},fg=#{@thm_base}"
# set -g window-status-bell-style "bg=#{@thm_red},fg=#{@thm_base},bold"
# set -g window-status-current-style "bg=#{@thm_peach},fg=#{@thm_base},bold"
# set -gF window-status-separator "#[bg=default,fg=#{@thm_overlay0}]│"

# window content (icon)
set -g automatic-rename off
set -g allow-rename off
set -g window-status-format '\
#{?#{==:#{pane_current_command},zsh},  ,\
#{?#{==:#{pane_current_command},fish}, 󰈺 ,\
#{?#{==:#{pane_current_command},nvim},  ,\
#{?#{==:#{pane_current_command},git}, 󰊢 ,\
#{?#{==:#{pane_current_command},htop}, ,\
#{?#{==:#{pane_current_command},yazi}, 󰀶 ,\
#{?#{==:#{pane_current_command},python}, 󰌠 ,\
#{?#{==:#{pane_current_command},bash},  ,\
#{?#{==:#{pane_current_command},ssh},  ,\
#{?#{==:#{pane_current_command},node},  ,\
#{?#{==:#{pane_current_command},cargo},  ,\
#{?#{==:#{pane_current_command},rustc},  ,\
#{?#{==:#{pane_current_command},lua},  ,\
 󰘧 }}}}}}}}}}}}}'
set -g window-status-current-format '\
#{?#{==:#{pane_current_command},zsh},  ,\
#{?#{==:#{pane_current_command},fish}, 󰈺 ,\
#{?#{==:#{pane_current_command},nvim},  ,\
#{?#{==:#{pane_current_command},git}, 󰊢 ,\
#{?#{==:#{pane_current_command},htop}, ,\
#{?#{==:#{pane_current_command},yazi}, 󰀶 ,\
#{?#{==:#{pane_current_command},python}, 󰌠 ,\
#{?#{==:#{pane_current_command},bash},  ,\
#{?#{==:#{pane_current_command},ssh},  ,\
#{?#{==:#{pane_current_command},node},  ,\
#{?#{==:#{pane_current_command},cargo},  ,\
#{?#{==:#{pane_current_command},rustc},  ,\
#{?#{==:#{pane_current_command},lua},  ,\
 󰘧 }}}}}}}}}}}}}'
# window style
set -g window-status-style "bg=default,fg=#{@thm_rosewater}"
set -g window-status-last-style "bg=default,fg=#{@thm_flamingo}"
set -g window-status-current-style "bg=default,fg=#{@thm_peach},bold"
set -g window-status-activity-style "bg=default,fg=#{@thm_pink},bold"
set -g window-status-bell-style "bg=default,fg=#{@thm_red},bold"
# set -gF window-status-separator "#[bg=default,fg=#{@thm_overlay2}]│"

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment