Tmux
TMux is a better ‘Screen’ alternative
In tmux
, there are Sessions (Windows) and panes. Great stuff.
A tmux Crash Course
greymd/tmux-xpanes: Awesome tmux-based terminal divider
Tmux odlična postavka
https://wbk.one/article/15/tmux-mouse-support
savršeno: https://github.com/wbkang/wbk-stow/blob/master/tmux-config/.tmux.conf
Mostly obsolete Tmux improvemenrs
Switch from Ctrl+B to Ctrl+A.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
cat <<'EOF' > ~/.tmux.conf
# Notes:
# set -> is equivalent to set-option
# setw -> set-window-option
# bind -> bind-key
# unbind -> unbind-key
#
# Change Ctrl-b to Ctrl-a as Vim uses Ctrl-b
#
# General:
# C-a Prefix
# C-a r Source .tmux.conf
# C-a ? Show key bindings
# C-a t Show time
#
# Sessions:
# C-a s List sessions
# C-a $ Rename session
#
# Windows (tabs):
# C-a c Create window
# C-a w List windows
# C-a f Find window
# C-a , Name window
# C-a & Kill window
#
# Panes (splits):
# C-a | Vertical split
# C-a - Horizontal split
# C-a o Jump between panes
# C-a q Show pane numbers (type number to jump)
# C-a x Kill pane
# C-a ! Break pane out into a window
# C-a j Create pane from an existing window
# C-a arrow Move between panes
#
# remap prefix to C-a
unbind C-b
set -g prefix C-a
# C-a C-a jumps to previous window
bind C-a last-window
# for nested sessions, C-a a sends a command to the inner session
bind C-a send prefix
# Use C-r to reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# better splits with | and -
bind | split-window -h
bind - split-window -v
# convert window into a pane
bind j command-prompt -p "Create pane from window #:" "join-pane -s ':%%'"
# show activity
setw -g monitor-activity on
set -g visual-activity on
# resize windows on larger screens - if off the size is capped to the smallest
# screen size that has ever looked at it
setw -g aggressive-resize on
# use UTF8
set -g utf8 on
set -g status-utf8 on
# internal speedup
set -s escape-time 0
# enable 256 colors mode
# important if you want the solarized theme look
#
set -g default-terminal "screen-256color"
# longer scroll-back history to 100k
set -g history-limit 100000
# windows and panes index start from 1 instead of 0
set -g base-index 1
set -g pane-base-index 1
# enable mouse
set -g mouse on
# better mouse scrolling
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# useful info in the status bar
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name, active(or not)
# highlight the current window in the status bar (blue background)
# #I - window index
# #W - window title
# #F - window flag
set-window-option -g window-status-current-format '#[bg=blue,fg=cyan,bold]#I#[bg=blue,fg=cyan]:#[fg=white]#W#[fg=dim]#F'
# Right side of status bar
# $(echo $USER) - shows the current username
# #H - shows the hostname of your computer
# %h %d %Y - date in the [Mon DD YYYY] format
# %l:%M %p - time in the [HH:MM AM/PM] format
set -g status-right '#[fg=green][#[fg=whitfe]#(echo $USER) @ #H#[fg=green]][#[fg=black,bold]%h %d %Y #[bg=green,fg=white,bold]%l:%M %p#[default]#[fg=green]]'
EOF
|
Couple of notes about tmux:
- To copy-paste with the mouse, you need to hold down the Shift key
Very-very advanced Tmux improvenments
Restoring tmux Sessions after reboot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
cat << EOF | sudo tee -a ~/.tmux.conf
# enable mouse
set -g mouse on
# install tmux-plugin-manager
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
# enable two plugins
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on'
# set -g @resurrect-save-shell-history 'on'
# part of tmux-plugin-manager, leave it eof
run '~/.tmux/plugins/tpm/tpm'
EOF
Later, in tmux, hit <tmux-prefix>, then I, to fetch and install plugins. You should now be able to use the plugin.
|
Links from okt 2017
Making tmux Pretty and Usable - A Guide to Customizing your tmux.conf
Show terminal colors with oneliner tmux_colors.sh
nano error: Error opening terminal: xterm-256color - Stack Overflow
tmux.conf include - Google Search
The best and greatest tmux.conf ever
TMUX configuration file
Tools I use: Tmux
Terminal multiplexers
Terminal multiplexers are tools to create multiple screens, tabs, etc.
tmux is standard, but there are lot of alternatives with improvements.
- tmuxinator manages complex tmux sessions
- byobu uses tmux as its engine but does a better job in user interface and key combinations
Some tmux config: tmux configuration, mouse copy & paste added
There is a new Rust kid on the block:
Zellij
About Zellij
Sada mislim da je i ovo dovoljno:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
cat <<'EOF' > ~/.tmux.conf
# General:
# C-a Prefix
# C-a r Source .tmux.conf
# Ctl-B ? Show keyboard shortcuts
# C-a t Show time
#
# Sessions:
# C-a s List sessions
# C-a $ Rename session
#
# Windows (tabs):
# C-a c Create window
# C-a w List windows
# C-a f Find window
# C-a , Name window
# C-a & Kill window
#
# Panes (splits):
# C-a | Vertical split
# C-a - Horizontal split
# C-a o Jump between panes
# C-a q Show pane numbers (type number to jump)
# C-a x Kill pane
# C-a ! Break pane out into a window
# C-a j Create pane from an existing window
# C-a arrow Move between panes
#
# remap prefix to C-a
unbind C-b
set -g prefix C-a
# C-a C-a jumps to previous window
bind C-a last-window
# for nested sessions, C-a a sends a command to the inner session
bind C-a send prefix
# Use C-r to reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# better splits with | and -
bind | split-window -h
bind - split-window -v
# convert window into a pane
bind j command-prompt -p "Create pane from window #:" "join-pane -s ':%%'"
# show activity
setw -g monitor-activity on
set -g visual-activity on
# resize windows on larger screens - if off the size is capped to the smallest
# screen size that has ever looked at it
setw -g aggressive-resize on
# use UTF8
set -g utf8 on
set -g status-utf8 on
# internal speedup
set -s escape-time 0
# enable 256 colors mode
# important if you want the solarized theme look
#
set -g default-terminal "screen-256color"
# longer scroll-back history to 100k
set -g history-limit 100000
# windows and panes index start from 1 instead of 0
set -g base-index 1
set -g pane-base-index 1
# enable mouse
set -g mouse on
# better mouse scrolling
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# useful info in the status bar
set-option -g set-titles on
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # window number,program name, active(or not)
# highlight the current window in the status bar (blue background)
# #I - window index
# #W - window title
# #F - window flag
set-window-option -g window-status-current-format '#[bg=blue,fg=cyan,bold]#I#[bg=blue,fg=cyan]:#[fg=white]#W#[fg=dim]#F'
# Right side of status bar
# $(echo $USER) - shows the current username
# #H - shows the hostname of your computer
# %h %d %Y - date in the [Mon DD YYYY] format
# %l:%M %p - time in the [HH:MM AM/PM] format
set -g status-right '#[fg=green][#[fg=whitfe]#(echo $USER) @ #H#[fg=green]][#[fg=black,bold]%h %d %Y #[bg=green,fg=white,bold]%l:%M %p#[default]#[fg=green]]'
EOF
|
Clear screen in tail inside tmux
Ovo mi je najbitniji shortcut:
iterm - How do i clear tmux screen while tailing logs? - Stack Overflow
bind l send-keys -R ; display “Cleared”
Pa zatim sa + clearuj screen dok si u tail.
Ima i fora još
Keys in this table can just be pressed, without any prefix. Use -n (a shortcut for -T root) to bind keys in this table. Example: bind -n C-t new-window
Binding Keys in tmux | seanh.cc
bind -n C-k send-keys -R \; display "Screen Cleared"
ili mišem savršeno:
bind-key -n DoubleClick1Pane send-keys -R \; display "Screen Cleared"