
Cấu hình
Cấu hình cho tmux có thể được thêm vào file $HOME/.tmux.conf.
Phím tắt
-
Reload
.tmux.confReload file cấu hình với phím tắt
Ctrl-b r:bind-key r source ~/.tmux.conf
-
Cửa sổ gần đây
Mặc định phím tắt cho việc nhảy đến cửa sổ gần đây làCtrl-b l, nhưng để cho nhanh hơn chúng ta có thể chuyển nó sangCtrl-b-b:bind-key C-b last-window -
Chuyển khung
Thông thường để chuyển đến các khung khác nhau trong cùng cửa sổ, ta thường dùng phím tắtCtrl-b ArrrowKey, để bớt số lượng phím cần bấm chúng ta có thể thêm phím tắtAlt-ArrowKeycho việc này:bind -n M-Left select-pane -L bind -n M-Right select-pane -R bind -n M-Up select-pane -U bind -n M-Down select-pane -D
Giao diện
Cho thanh status bar dễ nhìn hơn chút
set -g status-justify left
set -g status-style "bg=colour0"
set -ag status-style "fg=colour7"
set -g status-left ''
set -g status-right "'#H' #[fg=colour15]#(date +"%H:%M") "
set -ag status-right "#[fg=colour15]#(date +"%d/%m")#[fg=colour8] #(date +"%Y") "
set -g window-status-current-format "#[fg=colour15] #F#I:#W#F "
set -g window-status-format "#[fg=colour8] #F#I:#W#F "
set -g default-terminal "screen-256color"Chức năng thường dùng
| Câu lệnh / Phím tắt | Hành động |
|---|---|
| tmux | Bắt đầu một phiên mới |
| tmux new -s saymyname | Bắt đầu một phiên mới với tên saymyname |
| Ctrl-b ? | Xem tất cả các phím tắt khả dụng |
| Ctrl-b c | Tạo cửa sổ mới |
| Ctrl-b , | Đổi tên cửa sổ |
| Ctrl-b 1 | Nhảy đến cửa sổ 1 |
| Ctrl-b-b | Nhảy đến cửa sổ gần đây |
| Ctrl-b " | Chia đôi cửa sổ theo chiều ngang |
| Ctrl-b % | Chia đôi cửa sổ theo chiều dọc |
| Ctrl-b ArrowKey, Alt-ArrowKey | Nhảy sang khung tương ứng theo phím mũi tên |
| Ctrl-b ESC-[1-5] | Đổi layout của khung sang tương ứng với các layout từ 1 đến 5 |
| Ctrl-b z | Bật tắt chế độ phóng to của khung hiện tại |
| Ctrl-b [ | Đổi sang chế độ cuộn (bấm 'q' để thoát chế độ cuộn) |
| Ctrl-b d | Nhảy ra khỏi phiên |
| tmux ls | Xem tất cả các phiên hiện có |
| tmux a | Nhảy vào phiên gần đây |
| tmux a -t saymyname | Nhảy vào phiên có tên saymyname |
Ví dụ file ~/.tmux.conf
bind-key C-b last-window
# unbind key for helix
unbind-key -T prefix /
# reload tmux conf
bind-key r source ~/.tmux.conf
# Switch pane with Alt-Arrow
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Support true color
set -ga terminal-overrides ",*256col*:Tc"
# set -g default-terminal "tmux-256color"
# Disable escape timeout for helix
set -sg escape-time 10
# Theme
set -g status-justify left
## COLORSCHEME: gruvbox dark (medium)
set-option -g status "on"
# default statusbar color
set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
# default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
# default window with an activity alert
set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
# active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
# pane border
set-option -g pane-active-border-style fg=colour250 #fg2
set-option -g pane-border-style fg=colour237 #bg1
# message infos
set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
# writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
# pane number display
set-option -g display-panes-active-colour colour250 #fg2
set-option -g display-panes-colour colour237 #bg1
# clock
set-window-option -g clock-mode-colour colour109 #blue
# bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
## Theme settings mixed with colors (unfortunately, but there is no cleaner way)
set-option -g status-justify "left"
set-option -g status-left-style none
set-option -g status-left-length "80"
set-option -g status-right-style none
set-option -g status-right-length "80"
set-window-option -g window-status-separator ""
set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h "
set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W#{?window_zoomed_flag,*Z,} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]"
set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]"
Bình luận