TMux: Difference between revisions
Jump to navigation
Jump to search
Line 379: | Line 379: | ||
* [https://www.ricalo.com/blog/install-powerline-virtualenv/ Powerline in a Python virtual environment] | * [https://www.ricalo.com/blog/install-powerline-virtualenv/ Powerline in a Python virtual environment] | ||
* [https://www.ricalo.com/blog/install-powerline-ubuntu/ Installing Powerline on Ubuntu Linux] | * [https://www.ricalo.com/blog/install-powerline-ubuntu/ Installing Powerline on Ubuntu Linux] | ||
* [https://medium.com/codex/how-to-pimp-my-powerline-in-powershell-156f4e4936e Pimp my Powerline in PowerShell] | |||
* [https://stackoverflow.com/questions/42716734/ JSON file in-place using <code>jq</code>] | * [https://stackoverflow.com/questions/42716734/ JSON file in-place using <code>jq</code>] | ||
* [https://askubuntu.com/questions/868186/ TMux » Kill All Sessions] | * [https://askubuntu.com/questions/868186/ TMux » Kill All Sessions] |
Revision as of 05:50, 23 February 2023
tmux
is an open-source terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time.
Cheat Sheet
misc: ─────────────────────────────────────────────────────── Ctrl + a → : » Enter command mode |
misc: ─────────────────────────────────────────────────────── Ctrl + a → ? » List key bindings |
| |
session: ─────────────────────────────────────────────────────── Ctrl + a → w » Session and Window Preview Ctrl + a → ( » Move to previous session Ctrl + a → ) » Move to next session Ctrl + a → d » Detach from session Ctrl + a → s » Show all sessions Ctrl + a → $ » Rename session Ctrl + a → ʘ » Ctrl + a → ʘ » |
window: ─────────────────────────────────────────────────────── Ctrl + a → n » Next window Ctrl + a → w » List windows Ctrl + a → p » Previous window Ctrl + a → c » Create a new window Ctrl + a → & » Close active window Ctrl + a → , » Rename active window Ctrl + a → 1 » Toggle last active window Ctrl + a → 0…9 » Switch to window by number |
| |
pane: ─────────────────────────────────────────────────────── Ctrl + a → x » Close active pane Ctrl + a → q » Show pane numbers Ctrl + a → q + 0…9 » Switch pane by number Ctrl + a → | » Split pane vertically Ctrl + a → - » Split pane horizontally Ctrl + a → ; » Toggle last active pane Ctrl + a → z » Toggle active pane zoom Ctrl + a → { » Move the active pane left Ctrl + a → } » Move the active pane right Ctrl + a → ! » Convert pane into a window |
pane: ─────────────────────────────────────────────────────── Ctrl + a → Ctrl + ← » Pane width resize Ctrl + a → Ctrl + → » Pane width resize Ctrl + a → Ctrl + ↑ » Pane height resize Ctrl + a → Ctrl + ↓ » Pane height resize Ctrl + a → ↑ » Switch to pane up Ctrl + a → ↓ » Switch to pane down Ctrl + a → o » Switch to next pane Ctrl + a → ← » Switch to pane left Ctrl + a → → » Switch to pane right Ctrl + a → Spacebar » Toggle between pane layouts |
| |
vi copy: ─────────────────────────────────────────────────────── Ctrl + a → [ » Enter copy mode Ctrl + a → PgUp » Copy mode & scroll one page up → g » Go to top line → G » Go to bottom line → h » Move cursor left → j » Move cursor down → k » Move cursor up → l » Move cursor right → w » Move cursor forward one word → b » Move cursor backward one word |
vi copy: ─────────────────────────────────────────────────────── → q » Quit mode → ↑ » Scroll up → ↓ » Scroll down → / » Search forward → ? » Search backward → Spacebar » Start selection → Esc » Clear selection → n » Next keyword occurrence → N » Previous keyword occurrence Ctrl + a → ] » Paste contents of buffer_0 |
Installation
sudo apt install tmux
sudo apt install powerline
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
cat << EOF | tee ${HOME}/.tmux.conf >/dev/null
set -g base-index 1
# remap prefix from 'c-b' to 'c-a'
unbind C-b
set-option -g prefix c-a
bind-key c-a send-prefix
set -g default-terminal 'screen-256color'
set -g history-limit 10000
# window/pane split
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# list of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
# initialize tmux plugin manager
run '~/.tmux/plugins/tpm/tpm'
EOF
Powerline
sudo apt install build-essential libssl-dev libffi-dev libgmp3-dev libpq-dev
sudo apt install python-is-python3 python3-dev python3-pip python3-venv
python3 -m venv ~/.venv/powerline --prompt="Powerline"
source ~/.venv/powerline/bin/activate
pip install wheel
pip install powerline-status
# powerline font installation:
# ────────────────────────────
git clone https://github.com/powerline/fonts.git --depth=1
./fonts/install.sh && rm -rf fonts/
ls -lah ${HOME}/.local/share/fonts/
# powerline daemon config:
# ────────────────────────
mkdir -p ${HOME}/.config/powerline
cp -r ${HOME}/.venv/powerline/lib/python3.10/site-packages/powerline/config_files/* ${HOME}/.config/powerline/
powerline-daemon --replace
echo -E "$(jq '(.ext.shell|select(.theme=="default")).theme="default_leftonly"'\
${HOME}/.config/powerline/config.json)">\
${HOME}/.config/powerline/config.json
echo -E "$(jq '(.segments.left[]|select(.function=="powerline.segments.common.vcs.branch")).args={"status_colors":true}'\
${HOME}/.config/powerline/themes/shell/default_leftonly.json)">\
${HOME}/.config/powerline/themes/shell/default_leftonly.json
Powerline » Vim
# ~/.vimrc
set rtp+=${HOME}/.venv/powerline/lib/python3.10/site-packages/powerline/bindings/vim/
set laststatus=2
Powerline » Bash
# powerline configuration
if [ -f ${HOME}/.venv/powerline/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
source ${HOME}/.venv/powerline/lib/python3.10/site-packages/powerline/bindings/bash/powerline.sh
fi
Powerline » TMux
# ~/.tmux.conf
set -g default-terminal "screen-256color"
source "${HOME}/.venv/powerline/lib/python3.10/site-packages/powerline/bindings/tmux/powerline.conf"
Knowledge
tmux ls tmux new -s my_session tmux attach-session -t 0 tmux attach-session -t my_session Ctrl + a % » Split pane horizontally Ctrl + a " » Split pane vertically Ctrl + a x » Close current pane |
Ctrl + a c » Create a new window Ctrl + a w » Choose window from a list Ctrl + a 0 » Switch to window by number Ctrl + a , » Rename the current window Ctrl + a o » Go to the next pane Ctrl + a ; » Toggle between pane Ctrl + a d » Detach the session |
tmux ls tmux kill-server tmux list-sessions tmux kill-session -a tmux kill-session -t {index} pkill -f tmux ps aux | grep tmux |
| ||
GIT_INSTALL_STATUS="$(dpkg-query -W --showformat='${db:Status-Status}' 'git' 2>&1)"
if [[ ! $? -eq 0 ]]||[[ ! "${GIT_INSTALL_STATUS}" -eq 'installed' ]];then
printf 'sudo apt install --yes \033[0;31mgit \033[0m\n';exit 1
fi
TMUX_INSTALL_STATUS="$(dpkg-query -W --showformat='${db:Status-Status}' 'tmux' 2>&1)"
if [[ ! $? -eq 0 ]]||[[ ! "${TMUX_INSTALL_STATUS}" -eq 'installed' ]];then
printf 'sudo apt install --yes \033[0;31mtmux \033[0m\n';exit 1
fi
POWERLINE_INSTALL_STATUS="$(dpkg-query -W --showformat='${db:Status-Status}' 'powerline' 2>&1)"
if [[ ! $? -eq 0 ]]||[[ ! "${POWERLINE_INSTALL_STATUS}" -eq 'installed' ]];then
printf 'sudo apt install --yes \033[0;31mpowerline \033[0m\n';exit 1
fi
PYTHON3_INSTALL_STATUS="$(dpkg-query -W --showformat='${db:Status-Status}' 'python3' 2>&1)"
if [[ ! $? -eq 0 ]]||[[ ! "${PYTHON3_INSTALL_STATUS}" -eq 'installed' ]];then
printf 'sudo apt install --yes \033[0;31mpython3 \033[0m\n';exit 1
fi
PYTHON3_PIP_INSTALL_STATUS="$(dpkg-query -W --showformat='${db:Status-Status}' 'python3-pip' 2>&1)"
if [[ ! $? -eq 0 ]]||[[ ! "${PYTHON3_PIP_INSTALL_STATUS}" -eq 'installed' ]];then
printf 'sudo apt install --yes \033[0;31mpython3-pip \033[0m\n';exit 1
fi
PYTHON3_VENV_INSTALL_STATUS="$(dpkg-query -W --showformat='${db:Status-Status}' 'python3-venv' 2>&1)"
if [[ ! $? -eq 0 ]]||[[ ! "${PYTHON3_VENV_INSTALL_STATUS}" -eq 'installed' ]];then
printf 'sudo apt install --yes \033[0;31mpython3-venv \033[0m\n';exit 1
fi
| ||
| ||
python3 -m site --user-site python3 -m site | grep packages python3 -m sysconfig | grep packages |
windows 11 C:\> py -c "import sysconfig; print(sysconfig.get_path('purelib'))" python3 -c "import sysconfig; print(sysconfig.get_path('purelib'))" | |
| ||
python3 -m venv ~/.venv/powerline --prompt="Powerline"
# source .venv/bin/activate
# (Powerline) $
| ||
| ||
python -m venv ~/.venv/powerline --prompt="Powerline"
# .venv\Scripts\activate
# (Powerline) PS>
| ||
| ||
uptime | cut -f 4-5 -d ' ' | cut -f 1 -d ',' | ||
| ||
cat ${HOME}/.config/powerline/config.json|jq '.ext.shell.theme'
cat ${HOME}/.config/powerline/themes/shell/default_leftonly.json|\
jq '.segments.left[].function'
jq '.ext.shell|select(.theme=="default")' ${HOME}/.config/powerline/config.json
jq '.segments.left[]|select(.function=="powerline.segments.common.vcs.branch")'\
${HOME}/.config/powerline/themes/shell/default_leftonly.json
| ||
| ||
cat ${HOME}/.config/powerline/config.json |\
jq '.ext.shell|select(.theme=="default")|.theme="default_leftonly"'
cat ${HOME}/.config/powerline/themes/shell/default_leftonly.json |\
jq '.segments.left[]|select(.function=="powerline.segments.common.vcs.branch")|.args={"status_colors":true}'
jq '(.ext.shell|select(.theme=="default")).theme="default_leftonly"'\
${HOME}/.config/powerline/config.json
jq '(.segments.left[]|select(.function=="powerline.segments.common.vcs.branch")).args={"status_colors":true}'\
${HOME}/.config/powerline/themes/shell/default_leftonly.json
|
References
| ||