Skip to content

Instantly share code, notes, and snippets.

@hunzo
Last active August 29, 2025 15:21
Show Gist options
  • Save hunzo/ceb2bc417a79b3454d99c8d2411a8e9f to your computer and use it in GitHub Desktop.
Save hunzo/ceb2bc417a79b3454d99c8d2411a8e9f to your computer and use it in GitHub Desktop.
#!/bin/bash
# ตรวจสอบและติดตั้ง git / tmux หากยังไม่มี
if ! command -v git &>/dev/null; then
echo "git not found, installing..."
sudo apt update && sudo apt install -y git
fi
if ! command -v tmux &>/dev/null; then
echo "tmux not found, installing..."
sudo apt update && sudo apt install -y tmux
fi
# ติดตั้ง tmux plugin manager
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# เขียน tmux config
cat >>~/.tmux.conf <<'EOF'
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @catppuccin_directory_text "#{pane_current_path}"
set -g @catppuccin_status_modules_right "directory"
set -g @catppuccin_window_left_separator ""
set -g @catppuccin_window_right_separator " "
set -g @catppuccin_status_left_separator "█"
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 -n M-K resize-pane -U 5
bind -n M-J resize-pane -D 5
bind -n M-H resize-pane -L 5
bind -n M-L resize-pane -R 5
set -g mouse on
set -g default-terminal 'xterm-256color'
set -as terminal-overrides ',xterm*:Tc:sitm=\E[3m'
set-window-option -g mode-keys vi
# set-option -ga terminal-overrides ',xterm-256color:clipboard=external'
run '~/.tmux/plugins/tpm/tpm'
EOF
# โหลด config ใหม่
tmux source ~/.tmux.conf
# เพิ่ม alias ให้ tmux รองรับ true color
if ! grep -q "alias tmux='tmux -u'" ~/.bashrc; then
echo -e "\n# add from script install tmux" >>~/.bashrc
echo "alias tmux='tmux -u'" >>~/.bashrc
fi
echo "✅ tmux configuration installed. You can now run tmux and press 'prefix + I' to install plugins."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment