From 2acae0b4f250dbcb16cac551cef4f4712e3659b9 Mon Sep 17 00:00:00 2001 From: Andrejus Date: Tue, 24 Feb 2026 16:05:23 +0000 Subject: [PATCH] vim: add plugins, tmux: status bar, fix Ctrl+A clash - Add vim-gitgutter, vim-commentary, vim-surround via install script - Rebind git log widget from Ctrl+A to Ctrl+T (tmux prefix clash) - Add date, time, and battery indicator to tmux status bar - Set tmux clock colour to teal Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .gitignore | 3 +++ home/.tmux.conf | 5 +++-- home/.tmux/battery.sh | 28 ++++++++++++++++++++++++++++ home/.vimrc | 4 ++++ home/.zsh/widgets.zsh | 4 ++-- install.d/24-tmux.sh | 0 install.d/25-vim.sh | 27 +++++++++++++++++++++++++++ 7 files changed, 67 insertions(+), 4 deletions(-) create mode 100755 home/.tmux/battery.sh mode change 100644 => 100755 install.d/24-tmux.sh create mode 100755 install.d/25-vim.sh diff --git a/.gitignore b/.gitignore index 9eedaab..018629b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ temp **/autoload **/pypoetry +# vim plugins (installed via install script) +home/.vim/pack + diff --git a/home/.tmux.conf b/home/.tmux.conf index d2ca48a..ef9dad3 100644 --- a/home/.tmux.conf +++ b/home/.tmux.conf @@ -61,7 +61,7 @@ set -g status-position bottom set -g status-interval 5 set -g status-style "fg=#728cb8,bg=default" set -g status-left "" -set -g status-right "" +set -g status-right "#[fg=#808080]%a %d %b #[fg=#2cb494,bold]%H:%M #(~/.tmux/battery.sh)" set -g window-status-format " #I:#W " set -g window-status-current-format "#[fg=#2cb494,bold] #I:#W " set -g window-status-bell-style "fg=#f88c14,bold" @@ -71,6 +71,7 @@ set -g message-style "fg=#2cb494,bg=default" set -g message-command-style "fg=#f88c14,bg=default" set -g mode-style "fg=default,bg=#728cb8,bold" -# Auto-rename +# Clock +set -g clock-mode-colour "#2cb494" set -g automatic-rename on set -g automatic-rename-format '#{?#{==:#{pane_current_command},zsh},zsh:#{b:pane_current_path},#{pane_current_command}}' diff --git a/home/.tmux/battery.sh b/home/.tmux/battery.sh new file mode 100755 index 0000000..03ee7ff --- /dev/null +++ b/home/.tmux/battery.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Battery indicator for tmux status bar. +# Shows percentage only when on battery; amber when <=20%. + +pct="" +charging="" + +if command -v pmset &>/dev/null; then + # macOS + info=$(pmset -g batt) + pct=$(echo "$info" | grep -o '[0-9]\+%' | head -1 | tr -d '%') + echo "$info" | grep -q 'AC Power' && charging=1 +elif [[ -f /sys/class/power_supply/BAT0/capacity ]]; then + # Linux + pct=$(cat /sys/class/power_supply/BAT0/capacity) + status=$(cat /sys/class/power_supply/BAT0/status) + [[ "$status" == "Charging" || "$status" == "Full" ]] && charging=1 +fi + +[[ -z "$pct" ]] && exit 0 + +if [[ -n "$charging" ]]; then + echo "#[fg=#808080]AC#[default]" +elif (( pct <= 20 )); then + echo "#[fg=#f88c14,bold]${pct}%#[default]" +else + echo "#[fg=#808080]${pct}%#[default]" +fi diff --git a/home/.vimrc b/home/.vimrc index 5c0923f..4b7dd1b 100644 --- a/home/.vimrc +++ b/home/.vimrc @@ -16,6 +16,7 @@ set undolevels=1000 set undoreload=10000 set belloff=all set noerrorbells +set signcolumn=yes set lazyredraw set synmaxcol=500 @@ -127,6 +128,9 @@ highlight Conceal guifg=#808080 highlight CursorLine guibg=#0A2A1A gui=NONE highlight CursorColumn guibg=#0A2A1A highlight SignColumn guifg=#808080 guibg=NONE +highlight GitGutterAdd guifg=#2CB494 guibg=NONE +highlight GitGutterChange guifg=#4068D4 guibg=NONE +highlight GitGutterDelete guifg=#F40404 guibg=NONE highlight WarningMsg guifg=#FCFC38 highlight ErrorMsg guifg=#F40404 gui=bold highlight ModeMsg guifg=#CCE0D0 gui=bold diff --git a/home/.zsh/widgets.zsh b/home/.zsh/widgets.zsh index 80f2c49..484fd9d 100644 --- a/home/.zsh/widgets.zsh +++ b/home/.zsh/widgets.zsh @@ -91,7 +91,7 @@ _dots_load_keybindings() { zle -N _dots_find_in_files_widget bindkey '^F' _dots_find_in_files_widget - # Ctrl+A: git log browser + # Ctrl+Q: git log browser _dots_git_log_widget() { local commit commit="$(git log --oneline --color --decorate -50 2>/dev/null \ @@ -103,7 +103,7 @@ _dots_load_keybindings() { zle accept-line } zle -N _dots_git_log_widget - bindkey '^A' _dots_git_log_widget + bindkey '^Q' _dots_git_log_widget # Ctrl+K: command help lookup _dots_help_widget() { diff --git a/install.d/24-tmux.sh b/install.d/24-tmux.sh old mode 100644 new mode 100755 diff --git a/install.d/25-vim.sh b/install.d/25-vim.sh new file mode 100755 index 0000000..2420cb3 --- /dev/null +++ b/install.d/25-vim.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# Description: +# Install vim plugins using native vim packages (pack/). +# + +vim_pack_dir="$HOME/.vim/pack/plugins/start" +mkdir -p "$HOME/.vim/pack/plugins/start" + +vim_plugins=( + "https://github.com/airblade/vim-gitgutter.git" + "https://github.com/tpope/vim-commentary.git" + "https://github.com/tpope/vim-surround.git" +) + +for url in "${vim_plugins[@]}"; do + name=$(basename "$url" .git) + dest="$vim_pack_dir/$name" + if [[ -d "$dest" ]]; then + git -C "$dest" pull --quiet + log_pass "$name updated" + else + git clone --depth 1 --quiet "$url" "$dest" + log_pass "$name installed" + fi +done