Using Tmux
By Aravind
Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Installing Tmux
brew install tmux
Splitting screen
Horizontal
ctrl+b %
Vertical
ctrl+b "
Navigating
ctrl + b arrow keys
Exit
type "exit" or ctrl +d
Create new window
ctrl + b c
This switches to new window
Navigate to old window
This navigates to previous window
ctrl + b p
To navigate to a specific window. use the number which would be displayed at the bottom
ctrl +b <number>
Detach
ctrl + b d
Reattach
First display tmux sessions
tmux ls
To reattach
tmux attach -t <number>
Create a new window with name
tmux new -s r0
Rename existing session
tmux rename-session -t 0 <name>
View all commands
ctrl +b ?
View all windows
This can be typed while inside a tmux session and can navigate to various windows.
ctrl +b s
View clock
ctrl+b t
Send same command across all window panes
You can send the same command to all window panes
ctrl +b : set-window-option synchronize-panes on
to turn off synchronzie
ctrl +b : set-window-option synchronize-panes off
Configure tmux.conf file
set -g mouse on
set-window-option -g clock-mode-colour green #green
bind-key -n F1 set-window-option synchronize-panes on
bind-key -n F2 set-window-option synchronize-panes off
incase you get dotted lines saying (attached from a smaller client)
In this case, its because there are different attachments to the tmux session . we just need to detach from other screens
ctrl +b shift +d
the above will display all the attachments. Just choose and detach using
ctrl + d
Tmux conf that I use
# save as ~/.tmux.conf
# C-b is not acceptable -- Vim uses it
set-option -g prefix `
bind-key ` last-window
# Start numbering at 1
set -g base-index 1
# Allows for faster key repetition
set -s escape-time 0
# Set status bar
set -g status-bg black
set -g status-fg white
set -g status-left ""
set -g status-right "#[fg=green]#H"
# Rather than constraining window size to the maximum size of any client
# connected to the *session*, constrain window size to the maximum size of any
# client connected to *that window*. Much more reasonable.
setw -g aggressive-resize on
# Allows us to use C-a a <command> to send commands to a TMUX session inside
# another TMUX session
bind-key a send-prefix
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity on
# Example of using a shell command in the status line
set -g status-right "#[fg=yellow]#(uptime | cut -d ',' -f 2-)"
# Highlight active window
set-window-option -g window-status-current-bg red
# Set mode to vi
set-window-option -g mode-keys vi
# scroll on
set -g mouse on
set-window-option -g clock-mode-colour green #green
#synchronize panes
bind-key -n F1 set-window-option synchronize-panes on
bind-key -n F2 set-window-option synchronize-panes off
linux
]
tags: linux