feat: update tmux config

This commit is contained in:
tux
2025-03-15 02:47:22 +05:30
parent 5da37db69c
commit d3627572f3

View File

@ -1,38 +1,136 @@
{...}: { {pkgs, ...}: let
bg = "default";
fg = "default";
bg2 = "brightblack";
fg2 = "white";
color = c: "#{@${c}}";
indicator = let
accent = color "indicator_color";
content = " ";
in "#[reverse,fg=${accent}]#{?client_prefix,${content},}";
current_window = let
accent = color "main_accent";
index = "#[reverse,fg=${accent},bg=${fg}] #I ";
name = "#[fg=${bg2},bg=${fg2}] #W ";
# flags = "#{?window_flags,#{window_flags}, }";
in "${index}${name}";
window_status = let
accent = color "window_color";
index = "#[reverse,fg=${accent},bg=${fg}] #I ";
name = "#[fg=${bg2},bg=${fg2}] #W ";
# flags = "#{?window_flags,#{window_flags}, }";
in "${index}${name}";
battery = let
percentage = pkgs.writeShellScript "percentage" (
if pkgs.stdenv.isDarwin
then ''
echo $(pmset -g batt | grep -o "[0-9]\+%" | tr '%' ' ')
''
else ''
path="/org/freedesktop/UPower/devices/DisplayDevice"
echo $(${pkgs.upower}/bin/upower -i $path | grep -o "[0-9]\+%" | tr '%' ' ')
''
);
state = pkgs.writeShellScript "state" (
if pkgs.stdenv.isDarwin
then ''
echo $(pmset -g batt | awk '{print $4}')
''
else ''
path="/org/freedesktop/UPower/devices/DisplayDevice"
echo $(${pkgs.upower}/bin/upower -i $path | grep state | awk '{print $2}')
''
);
icon = pkgs.writeShellScript "icon" ''
percentage=$(${percentage})
state=$(${state})
if [ "$state" == "charging" ] || [ "$state" == "fully-charged" ]; then echo "󰂄"
elif [ $percentage -ge 75 ]; then echo "󱊣"
elif [ $percentage -ge 50 ]; then echo "󱊢"
elif [ $percentage -ge 25 ]; then echo "󱊡"
elif [ $percentage -ge 0 ]; then echo "󰂎"
fi
'';
color = pkgs.writeShellScript "color" ''
percentage=$(${percentage})
state=$(${state})
if [ "$state" == "charging" ] || [ "$state" == "fully-charged" ]; then echo "green"
elif [ $percentage -ge 75 ]; then echo "green"
elif [ $percentage -ge 50 ]; then echo "${fg2}"
elif [ $percentage -ge 30 ]; then echo "yellow"
elif [ $percentage -ge 0 ]; then echo "red"
fi
'';
in "#[fg=#(${color})]#(${icon}) #[fg=${fg}]#(${percentage})%";
pwd = let
accent = color "main_accent";
icon = "#[fg=${accent}] ";
format = "#[fg=${fg}]#{b:pane_current_path}";
in "${icon}${format}";
git = let
icon = pkgs.writeShellScript "branch" ''
git -C "$1" branch && echo " "
'';
branch = pkgs.writeShellScript "branch" ''
git -C "$1" rev-parse --abbrev-ref HEAD
'';
in "#[fg=magenta]#(${icon} #{pane_current_path})#(${branch} #{pane_current_path})";
separator = "#[fg=${fg}]|";
in {
programs.tmux = { programs.tmux = {
enable = true; enable = true;
extraConfig = " baseIndex = 1;
escapeTime = 0;
mouse = true;
extraConfig = ''
set-option -sa terminal-overrides ",xterm*:Tc"
set-option -g status-position top
unbind r
bind r source-file ~/.config/tmux/tmux.conf
set-option -sa terminal-overrides \",xterm*:Tc\" # remap prefix from C-b to C-Space
set -g mouse on # unbind C-b
set-option -g status-position top # set -g prefix C-Space
set-option -g allow-rename off # bind C-Space send-prefix
unbind r
bind r source-file ~/.config/tmux/tmux.conf
# remap prefix from C-b to C-Space # split panes using | and -
# unbind C-b unbind '"'
# set -g prefix C-Space unbind %
# bind C-Space send-prefix bind | split-window -h
bind - split-window -v
# split panes using | and - # Start windows and panes at 1, not 0
unbind '\"' set -g base-index 1
unbind % set -g pane-base-index 1
bind | split-window -h set-window-option -g pane-base-index 1
bind - split-window -v set-option -g renumber-windows on
# Start windows and panes at 1, not 0 # switch panes using Alt-arrow without prefix
set -g base-index 1 bind -n M-Left select-pane -L
set -g pane-base-index 1 bind -n M-Right select-pane -R
set-window-option -g pane-base-index 1 bind -n M-Up select-pane -U
set-option -g renumber-windows on bind -n M-Down select-pane -D
# switch panes using Alt-arrow without prefix set-option -g default-terminal "screen-256color"
bind -n M-Left select-pane -L set-option -g status-right-length 100
bind -n M-Right select-pane -R set-option -g @indicator_color "yellow"
bind -n M-Up select-pane -U set-option -g @window_color "magenta"
bind -n M-Down select-pane -D set-option -g @main_accent "blue"
set-option -g pane-active-border fg=black
"; set-option -g pane-border-style fg=black
set-option -g status-style "bg=${bg} fg=${fg}"
set-option -g status-left "${indicator}"
set-option -g status-right "${git} ${pwd} ${separator} ${battery}"
set-option -g window-status-current-format "${current_window}"
set-option -g window-status-format "${window_status}"
set-option -g window-status-separator ""
'';
}; };
} }