The greatest value of Tmux to me: Avoiding the need to spend a lot of time restoring to the previous state due to network disconnection or Terminal crash. Additionally, the functionality of Tmux windows makes it more convenient for me to operate under Git Bash on Windows system.
Install Tmux on iSH
apk add tmux
Type tmux command to start Tmux,and type exit or Ctrl-d exit Tmux and released the session.
Type Ctrl-B ? to display a list of keyboard shortcuts,⚠️ Please hold down the Ctrl
and B keys simultaneously, then release them and press the ?
key.
session > window > pane
Tmux
|__ Session A
| |__ Window A1
| | |__ Pane A1a
| | |__ Pane A1b
| |
| |__ Window A2
| |__ Pane A2a
|
|__ Session B
|__ Window B1
| |__ Pane B1a
|
|__ Window B2
|__ Pane B2a
|__ Pane B2b
Session
- tmux a # attach the detached-session, when i ssh to server
- ctrl-b d : Detach from a session, leaving everything running in the background
- ctrl-d: ⚠️ Exit Tmux and release the session
- ctrl-b w: Choose window from a list, see screenshot above
Windows
- ctrl-b c: Create a new window
- ctrl-b p: Select the previous window
- ctrl-b n: Select the next window
- ctrl-b w: Choose window from a list, see screenshot above
- ctrl-b ,: Rename the current window
Tmux windows are a very useful feature because Git Bash on Windows system lacks tab functionality and can only open multiple cascaded windows, which is inconvenient. However, with Tmux installed, Git Bash can switch between windows effectively.
Panes
- ctrl-b %: Split window horizontally
- ctrl-b “: Split window vertically
- ctrl-d: Exit the pane
- ctrl-b <arrow key>: switch to the pane in whichever direction you press
- ctrl-b o: swith to another pane
- ctrl-b z: Zoom the active pane
- ctrl-b-<arrow key> (Don’t release Ctrl-b then press arrow key): Resizing panes
- ctrl-b {: Swap the active pane with the pane above
- ctrl-b }: Swap the active pane with the pane below
Others
The vim paste under Tmux will automatically indent, which is not what everyone wants to see. Enter :set paste before pasting, and enter :set nopaste after pasting(set nopaste will affect automatic indentation).
You can also write a vim mapping shortcut key to implement pasting.
nnoremap ,p :set paste<CR>"+p:set nopaste<CR>