Files

353 lines
13 KiB
Bash

# ==========================================================
# tmux — Catppuccin Mocha
# CachyOS + Ghostty + fish
# Muat ulang: prefix + r
# ==========================================================
# ----------------------------------------------------------
# TERMINAL
# ----------------------------------------------------------
set -g default-terminal "tmux-256color"
# Catatan: koma di depan ",xterm-..." itu habitsaya orang, bukan
# sintaks tmux. tmux membuang koma itu lalu MENYAPPEND entri, jadi
# nilainya tidak prepend. Semua entri yang cocok digabung (OR),
# jadi urutan tidak berpengaruh.
# Penting: default bawaan tmux hanya punya xterm*, screen*, rxvt*.
# Tidak ada satupun yang cocok dengan "tmux-256color", jadi tanpa
# baris di bawah pane di dalam tmux TIDAK dapat RGB / clipboard /
# extkeys -- cuma Colors 256.
set -as terminal-features "tmux*:clipboard:ccolour:cstyle:focus:title:RGB:extkeys"
set -as terminal-features "xterm-ghosty:RGB"
set -as terminal-features "xterm-256color:RGB"
# Tombol modifier ikut terkirim (Shift+Up, Ctrl+Left, ...)
set -s extended-keys on
set -as terminal-features "xterm*:extkeys"
# ----------------------------------------------------------
# PALET CATPPUCCIN MOCHA
#
# tmux >= 3.3 memakai "pane-colours" (opsi lama "palette" sudah
# dihapus) dan itu sebuah *pane option*.
#
# Dua akibatnya, keduanya sudah diverifikasi di tmux 3.7:
# 1. "set -g pane-colours[...]" (tanpa -p) DIABAIKAN total —
# tidak masuk ke pane yang sudah ada maupun pane baru.
# 2. "set -g -p ..." hanya berlaku untuk SATU pane, dan pane
# baru TIDAK mewarisi palet dari pane induknya.
# Jadi palet wajib di-apply per-pane, lewat hook di bawah
# (pane pertama = session-created, pane berikutnya = after-*).
#
# Palet untuk pane yang SUDAH hidup sebelum reload config
# ditangani oleh apply-palette.sh (dijalankan dari bind r).
# ----------------------------------------------------------
set-hook -g session-created 'source-file ~/.config/tmux/palette.conf'
set-hook -g after-new-window 'source-file ~/.config/tmux/palette.conf'
set-hook -g after-split-window 'source-file ~/.config/tmux/palette.conf'
# ----------------------------------------------------------
# PESAN & PROMPT
# ----------------------------------------------------------
set -g message-style "fg=#1e1e2e,bg=#89b4fa,bold"
set -g message-command-style "fg=#cdd6f4,bg=#313244"
# ----------------------------------------------------------
# PREFIX
# ----------------------------------------------------------
# Default C-b. Ingin ganti? ubah baris ini + unbind-nya.
set -g prefix C-b
unbind C-b
bind C-b send-prefix
# Tekan C-b dua kali = kirim prefix ke aplikasi
bind -n C-b send-prefix
# Muat ulang konfigurasi + terapkan palet ke pane yang sudah ada
# (hook hanya berlaku untuk pane yang lahir SESUDAH reload)
bind r source-file ~/.config/tmux/tmux.conf \; run-shell -b "sh ~/.config/tmux/apply-palette.sh" \; display-message "tmux.conf dimuat ulang"
# ----------------------------------------------------------
# DASAR
# ----------------------------------------------------------
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
set -g automatic-rename on
set -g allow-rename off
set -g set-titles on
set -g set-titles-string " #S | #W "
# ----------------------------------------------------------
# SCROLLBACK, MOUSE, INPUT
# ----------------------------------------------------------
set -g history-limit 100000
set -g mouse on
set -g mode-keys vi
set -g status-keys vi
set -g set-clipboard on
# Penting: memberitahu fish/aplikasi kalau window tmux aktif,
# supaya ikon lock, progress bar, dan prompt bisa akurat
set -g focus-events on
set -g escape-time 10
set -g repeat-time 500
set -g display-time 3000
set -g focus-follows-mouse off
# ----------------------------------------------------------
# SPLIT
# ----------------------------------------------------------
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# !!! JANGAN pakai "bind -n <huruf/angka>".
#
# "bind -n" menaruh binding di ROOT table, yang dicek tmux SEBELUM
# key dikirim ke aplikasi. Efeknya key tersebut hilang total.
# Sudah diuji lewat pty (bukan send-keys, yang bypass key table):
#
# bind -n Space -> SPASI tidak bisa diketik sama sekali
# bind -n 1..9 -> semua angka tidak bisa diketik
# bind -n f -> huruf f tidak bisa diketik
# bind -n h j k l-> tidak bisa mengetik hjkl
# bind -n n p -> huruf n dan p tidak bisa diketik
# bind -n H K -> huruf H dan K tidak bisa diketik
# bind -n C-h -> C-h = backspace di fish/readline ikut hilang
#
# Semua yang biasa "tanpa prefix" sekarang dipindah ke prefix table.
# Kalau memang mau jalan tanpa prefix, pakai modifier yang tidak
# dipakai aplikasi: M- (Alt), C-M, atau S- (Shift), bukan huruf polos.
#
# PENTING: menghapus baris "bind" dari file ini TIDAK cukup untuk
# melepas binding yang sudah terlanjur aktif di server yang jalan.
# "source-file" hanya menambahkan/menimpa, tidak pernah unbound.
# Semua binding yang sengaja dibuang WAJIB di-unbind di sini, kalau
# tidak binding lama tetap hidup sampai server di-restart.
unbind-key -T root Space
unbind-key -T root f
unbind-key -T root h
unbind-key -T root j
unbind-key -T root k
unbind-key -T root l
unbind-key -T root n
unbind-key -T root p
unbind-key -T root H
unbind-key -T root K
unbind-key -T root 0
unbind-key -T root 1
unbind-key -T root 2
unbind-key -T root 3
unbind-key -T root 4
unbind-key -T root 5
unbind-key -T root 6
unbind-key -T root 7
unbind-key -T root 8
unbind-key -T root 9
unbind-key -T root C-h
unbind-key -T root C-j
unbind-key -T root C-k
unbind-key -T root C-l
# Pindah pane
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Geser pane
bind H swap-pane -U
bind K swap-pane -D
# Pindah pane tanpa prefix tapi dengan modifier (tidak menabrak teks)
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# Resize tanpa prefix, pakai Alt+Shift+panah (Ctrl+Shift dipakai KDE)
bind -n M-H resize-pane -L 5
bind -n M-J resize-pane -D 5
bind -n M-K resize-pane -U 5
bind -n M-L resize-pane -R 5
# Resize dengan prefix
bind -r h resize-pane -L 5
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r l resize-pane -R 5
bind -r H resize-pane -L 15
bind -r J resize-pane -D 15
bind -r K resize-pane -U 15
bind -r L resize-pane -R 15
bind z resize-pane -Z
bind f resize-pane -Z
bind w kill-pane
bind = select-layout -t: even-horizontal
bind Space select-layout -t: tiled
bind s select-layout -t: tiled
# Copy mode tanpa prefix, pakai Shift+Space (tidak dipakai editor)
bind -n S-Space copy-mode
# ----------------------------------------------------------
# WINDOW
# ----------------------------------------------------------
bind c new-window -c "#{pane_current_path}"
bind n new-window -c "#{pane_current_path}"
# Rename manual sekaligus mematikan auto-rename utk window itu,
# supaya nama tidak ditimpa jadi "~" atau path lain.
bind , command-prompt -p "Rename window: " "rename-window '%%' ; set-window-option automatic-rename off"
# Kembalikan auto-rename utk window aktif
bind M-, set-window-option automatic-rename on \; display-message "auto-rename ON untuk window ini"
bind & kill-window
bind W kill-window
bind -r p previous-window
bind -r n next-window
# Pindah window tanpa prefix, tapi pakai modifier supaya tidak
# memblokir pengetikan angka di shell/editor.
# Alt+1..9 = pindah window, Alt+Shift+1..9 = window ke-10..18
bind -n M-1 select-window -t :1
bind -n M-2 select-window -t :2
bind -n M-3 select-window -t :3
bind -n M-4 select-window -t :4
bind -n M-5 select-window -t :5
bind -n M-6 select-window -t :6
bind -n M-7 select-window -t :7
bind -n M-8 select-window -t :8
bind -n M-9 select-window -t :9
bind -n M-p previous-window
bind -n M-n next-window
bind -r 1 select-window -t :1
bind -r 2 select-window -t :2
bind -r 3 select-window -t :3
bind -r 4 select-window -t :4
bind -r 5 select-window -t :5
bind -r 6 select-window -t :6
bind -r 7 select-window -t :7
bind -r 8 select-window -t :8
bind -r 9 select-window -t :9
# ----------------------------------------------------------
# SESSION
# ----------------------------------------------------------
bind s choose-tree
bind S choose-tree -Zs
bind d detach-client
bind x kill-server
bind C-x kill-server
bind e new-session
# ----------------------------------------------------------
# COPY MODE (vi)
# ----------------------------------------------------------
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi Y send -X copy-line
bind -T copy-mode-vi w send -X copy-selection-and-cancel
bind -T copy-mode-vi Escape send -X cancel
bind -T copy-mode-vi q send -X cancel
bind -T copy-mode-vi h send -X cursor-left
bind -T copy-mode-vi j send -X cursor-down
bind -T copy-mode-vi k send -X cursor-up
bind -T copy-mode-vi l send -X cursor-right
bind -T copy-mode-vi 0 send -X cursor-leftmost
bind -T copy-mode-vi 4 send -X cursor-rightmost
bind -T copy-mode-vi ^ send -X history-top
bind -T copy-mode-vi $ send -X history-bottom
bind -T copy-mode-vi g send -X history-top
bind -T copy-mode-vi G send -X history-bottom
bind -T copy-mode-vi d send -X half-page-down
bind -T copy-mode-vi u send -X half-page-up
bind -T copy-mode-vi f send -X page-down
bind -T copy-mode-vi b send -X page-up
bind -T copy-mode-vi / send -X begin-search-forward
bind -T copy-mode-vi ? send -X begin-search-backward
bind -T copy-mode-vi n send -X search-again
bind -T copy-mode-vi N send -X search-again
# (baris "bind -T copy-mode-vi C-e copy-mode -e" dihapus: "copy-mode"
# bukan command yang valid di copy-mode table, selalu error saat ditekan)
#
# "bind -n S-Space copy-mode" sudah didefinisikan di bagian SPLIT.
# ----------------------------------------------------------
# (digantikan oleh catppuccin/tmux — lihat blok TEMA di akhir file)
# # STATUS BAR — Catppuccin Mocha
# # Font: MesloLGS Nerd Font Mono (glyph powerline tersedia)
# # ----------------------------------------------------------
# set -g status on
# set -g status-position bottom
# set -g status-interval 2
# set -g status-justify left
# set -g status-style "bg=#1e1e2e,fg=#bac2de"
# set -g status-left-length 30
# set -g status-right-length 45
# # Sesi aktif
# set -g status-left "#[fg=#1e1e2e,bg=#89b4fa,bold] #S #[default]"
# # Jam + info window di kanan
# set -g status-right "#[fg=#89dceb,bg=#1e1e2e]%H:%M #[fg=#313244]#[bg=#1e1e2e] #S:#I #W #[default]"
# # Warna tiap window
# setw -g window-status-style "bg=#1e1e2e,fg=#313244"
# setw -g window-status-current-style "bg=#89b4fa,fg=#1e1e2e,bold"
# setw -g window-status-activity-style "bg=#f9e2af,fg=#1e1e2e"
# setw -g window-status-bell-style "bg=#f38ba8,fg=#1e1e2e"
# setw -g window-status-separator "#[fg=#313244,bg=#1e1e2e] #( #[default]"
# setw -g window-status-format " #I:#W#{?window_zoomed_flag,(Z),} "
# setw -g window-status-current-format "#[bg=#89b4fa,fg=#1e1e2e,bold] #I:#W#{?window_zoomed_flag, ,} #[default]"
# ----------------------------------------------------------
# PANE
# ----------------------------------------------------------
setw -g pane-border-style "fg=#313244"
setw -g pane-active-border-style "fg=#89b4fa"
setw -g pane-border-format " #{pane_index} "
# ----------------------------------------------------------
# MODE (copy mode, dll)
# ----------------------------------------------------------
setw -g mode-style "bg=#89b4fa,fg=#1e1e2e,bold"
# ----------------------------------------------------------
# HOOK
# ----------------------------------------------------------
set-hook -g alert-bell "display-message 'Ada aktivitas di #S:#I'"
# ----------------------------------------------------------
# PLUGIN (TPM) — Catppuccin Mocha
# Pasang: prefix + I | Update: prefix + U | Hapus: prefix + alt + u
# ----------------------------------------------------------
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-yank'
# resurrect / continuum
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '15'
# yank
set -g @yank_selection_mouse 'clipboard'
# ----------------------------------------------------------
# TEMA RESMI: catppuccin/tmux v2.3.1
# ----------------------------------------------------------
set -g @catppuccin_flavor "mocha"
set -g @catppuccin_window_status_style "rounded"
run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
# Status line: modul
set -g status-right-length 100
set -g status-left-length 100
set -g status-left ""
set -g status-right "#{E:@catppuccin_status_application}"
set -agF status-right "#{E:@catppuccin_status_cpu}"
set -agF status-right "#{E:@catppuccin_status_ram}"
set -ag status-right "#{E:@catppuccin_status_session}"
set -ag status-right "#{E:@catppuccin_status_uptime}"
set -agF status-right "#{E:@catppuccin_status_battery}"
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'tmux-plugins/tmux-battery'
run '~/.config/tmux/plugins/tpm/tpm'