-
-
Save Cergoo/3d4e5035008db996f2760e64dbdc8b43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://wiki.archlinux.org/index.php/Tmux_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9) | |
http://gimmor.blogspot.ru/2012/10/tmux.html | |
Очень хороший способ запустить tmux: | |
tmux attach || tmux new — делая так, вы сперва пытаетесь подключиться к уже существующему серверу tmux, если он существует; если такого ещё нет — создаёте новый. | |
После этого вы попадаете в полноценную консоль. | |
Ctrl+b d — отключиться. (Точно так же вы отключитесь, если прервётся соединение. Как подключиться обратно и продолжить работу — см. выше.) | |
В одной сессии может быть сколько угодно окошек: | |
Ctrl+b c — создать окошко; | |
Ctrl+b 0...9 — перейти в такое-то окошко; | |
Ctrl+b p — перейти в предыдущее окошко; | |
Ctrl+b n — перейти в следующее окошко; | |
Ctrl+b l — перейти в предыдущее активное окошко (из которого вы переключились в текущее); | |
Ctrl+b & — закрыть окошко (а можно просто набрать exit в терминале). | |
Мой ~/.tmux.conf:префикс для клавишных комбинаций - ctrl+a, vi-подобное управление. Для разделения окна на два равных региона по вертикали использую ctrl+a+v, по горизонтали - ctrl+a+h, для циклического переключения по регионам - ctrl+a+o, смена расположения регионов - ctrl+a+Space, часы - ctrl+a+t. | |
---------- | |
# tmux config by proft [http://proft.me] | |
# base | |
set -g set-titles on | |
set -g set-titles-string "#H > #W" | |
# automatically set window title | |
setw -g automatic-rename | |
set -g base-index 1 | |
set -g history-limit 5000 | |
# mouse scrolling | |
set -g mode-mouse on | |
#set window notifications | |
#setw -g monitor-activity on | |
#set -g visual-activity on | |
set -g display-time 2000 | |
set -g status-interval 10 | |
set -g status-left '' | |
set -g status-right '#[fg=green][#H]#[fg=cyan][#(cut -d " " -f 1-3 /proc/loadavg)]#[fg=yellow][%H:%M, %d-%m-%y]' | |
set -g status-right-length 45 | |
# colors | |
set -g status-fg white | |
set -g status-bg default | |
set -g status-attr default | |
set-window-option -g window-status-fg cyan | |
set-window-option -g window-status-bg default | |
set-window-option -g window-status-attr dim | |
set-window-option -g window-status-current-fg white | |
set-window-option -g window-status-current-bg default | |
set-window-option -g window-status-current-attr bright | |
setw -g window-status-alert-attr default | |
setw -g window-status-alert-fg yellow | |
set -g message-fg white | |
set -g message-bg black | |
set -g message-attr bright | |
# keys | |
unbind C-b | |
set -g prefix C-a | |
set -g status-keys vi | |
setw -g mode-keys vi | |
# switch between tabs with alt+larrow && alt+rarrow | |
bind-key -n M-Right next | |
bind-key -n M-Left prev | |
# vim resize panel | |
bind < resize-pane -L 1 | |
bind > resize-pane -R 1 | |
# splitting | |
unbind % | |
bind h split-window -h | |
unbind '"' | |
bind v split-window -v | |
# last window | |
unbind l | |
bind a last-window | |
# reload config | |
bind r source-file ~/.tmux.conf | |
# kill current window | |
bind-key k confirm kill-window | |
# detach | |
bind-key -n C-j detach | |
# switch windows alt+number | |
bind-key -n M-1 select-window -t 1 | |
bind-key -n M-2 select-window -t 2 | |
bind-key -n M-3 select-window -t 3 | |
bind-key -n M-4 select-window -t 4 | |
bind-key -n M-5 select-window -t 5 | |
bind-key -n M-6 select-window -t 6 | |
bind-key -n M-7 select-window -t 7 | |
bind-key -n M-8 select-window -t 8 | |
bind-key -n M-9 select-window -t 9 | |
------------ | |
# Erik Westrup's tmux configuration. | |
# Modeline { | |
# vi: foldmarker={,} foldmethod=marker foldlevel=0: tabstop=8: | |
# } | |
# General { | |
set-option -g default-path ~/ # Default working directory. | |
set-option -g status-keys vi # Use Vi bindings in tmux command prompt. | |
set-option -g history-limit 65536 # Number of tmux commands to remember (2^16). | |
set-option -g buffer-limit 16 # Number of copy buffers. | |
set-option -g bell-action any # Any window can cause bell action. | |
set-option -g bell-on-alert on # Ring terminal bell on acitivity. | |
#set-option -g lock-after-time 1800 # Lock session after X seconds. | |
set-option -g display-time 750 # Time (ms) the message bar is shown. | |
# set-option -g set-clipboard # Try to set the X clipboard. Requires a modification in ~/.Xresources. Does not seems to work. | |
set-option -g mouse-resize-pane on # Resize panes with the mouse. | |
set-option -g mouse-select-pane on # Select panes with the mouse. | |
# set-option -g mouse-select-window on # Select windows with the mouse. | |
# Window { | |
set-window-option -g mode-keys vi # Use Vi bindings in copy and choice mode. | |
# set-window-option -g mode-mouse on # Enter copy mode by using the mouse. | |
set-window-option -g monitor-activity on # Monitor windows for activity. | |
set-window-option -g utf8 on # Expect UTF8. | |
# } | |
# } | |
# UI { | |
# Different UI depending on if we're in X or not. | |
#if '[ -n "$DISPLAY" ]' 'source-file ~/.tmux/x' | |
#if '[ -z "$DISPLAY" ]' 'source-file ~/.tmux/xless' | |
source ~/git/tmux-colors-solarized/tmuxcolors-256.conf | |
set-option set-titles off # Try to set the title of the client terminal. Set to off or will hinder automatic-rename from working! | |
set-option -g default-terminal "screen-256color" # Use colors. | |
#set-window-option -g window-status-current-bg red # Highlight active window. | |
set-option -g pane-active-border-fg colour33 # Highlight active pane border with blue. | |
set-option -g message-bg "default" # Color of the message bar. | |
set-option -g message-attr "bold" # Style attributes for status line messages. | |
set-option -g visual-activity on # Notify visually events in monitor-activity enabled windows. | |
set-option -g visual-content on # Notify visually when monitor-contents matches. | |
set-option -g visual-bell off # Don't disturb. | |
# Window { | |
set-window-option -g clock-mode-style 24 # Use 24 hour clock. | |
#set-window-option -g clock-mode-colour green # Color of the clock. | |
set-window-option -g allow-rename # Allow programs to rename titles. | |
set-window-option -g automatic-rename # Rename titles automatically. | |
set-window-option -g window-status-format "#I ⮁ #W#F" # Format for non active windows. | |
# Format of the active window. | |
#set-window-option -g window-status-current-format "[#I:#W#F]" | |
set-window-option -g window-status-current-format "#[fg=colour235, bg=colour27]⮀#[fg=colour255, bg=colour27] #I ⮁ #W #[fg=colour27, bg=colour235]⮀" | |
# } | |
set-option -g status on # Always show the status bar. | |
#set-option -g status-position "bottom" # Position of the status bar. | |
set-option -g status-interval 2 # Update interval in seconds for status bar. | |
set-option -g status-utf8 on # Interpret UTF-8 characters in status bar. | |
# Left status { | |
#set-option -g status-justify "left" # Justification of the window list. | |
set-option -g status-justify "centre" # Justification of the window list. | |
set-option -g status-left-length 90 # Maximum length of status. | |
# String for the left status. | |
set-option -g status-left "#(~/git/tmux-powerline/powerline.sh left)" | |
# } | |
# Right status { | |
set-option -g status-right-length 120 # Maximum length of status. | |
# String for the right status. | |
# load avg. alternative: awk \'{ print $1,$2,$3 }\' </proc/loadavg | |
# %F == %Y-%m-%d ISO8601 | |
set-option -g status-right "#(~/git/tmux-powerline/powerline.sh right)" | |
# } | |
# } | |
# Bindings { | |
# GNU Screen-like { | |
unbind-key C-b # Unbind default prefix key. | |
set-option -g prefix C-a # Prefix key like GNU Screen. | |
bind-key a send-prefix # Send ^A. | |
bind-key C-a last-window # Toogle last window. | |
#set-option -g prefix2 C-t # Prefix that don't interfere with Emacs (so much). | |
#bind-key t send-prefix -2 # Send ^T. | |
#bind-key C-t last-window # Toogle last window. | |
unbind-key * | |
bind-key * list-clients # List connected clients. | |
unbind-key A | |
bind-key A command-prompt "rename-window %%" # Rename window. | |
unbind-key " " | |
bind-key " " next-window # Go to next window. | |
unbind-key BSpace | |
bind-key BSpace previous-window # Go to previous window. | |
unbind-key ^@ | |
bind-key ^@ next-layout # Toggle default pane layouts. | |
unbind-key '"' | |
bind-key '"' choose-window # Select window from list. | |
#unbind-key q | |
bind-key Q confirm-before "kill-session" # Kill active session. | |
#bind-key '`' display-panes # Enumerate panes. | |
unbind-key k | |
bind-key k confirm-before -p "kill-pane #P? (y/n)" "kill-pane" # Kill active pane. | |
bind-key K confirm-before -p "kill-window #I? (y/n)" "kill-window" # Kill active window. | |
unbind-key l | |
bind-key l refresh-client # Redraw screen. | |
#bind-key C-l refresh-client # Redraw screen. | |
unbind-key Tab | |
bind-key Tab select-pane -t:.+ # Cycle panes forwards. | |
unbind-key BTab | |
bind-key BTab select-pane -t:.- # Cycle panes backwards. | |
unbind-key x | |
bind-key x lock-server | |
set-option -g lock-command 'tput civis && read -s -n1' # Blank screen as lock command. | |
# Lock screen with password. | |
#bind-key x set-option lock-command 'vlock' \; lock-client \; set-option lock-command 'tput civis && read -s -n1' | |
# } | |
# Vi-like { | |
bind-key M-h select-pane -L # Select pane left. | |
bind-key M-j select-pane -D # Select pane down. | |
bind-key M-k select-pane -U # Select pane up. | |
bind-key M-l select-pane -R # Select pane right. | |
#bind-key M-a last-pane # Toggle last pane. | |
bind-key M-n select-pane -t:.+ # Cycle panes forwards. | |
bind-key M-p select-pane -t:.- # Cycle panes backwards. | |
bind-key < resize-pane -L 2 # Resize width to the left. | |
bind-key > resize-pane -R 2 # Resize width to the right. | |
#bind-key - resize-pane -D 2 # Resize height down. | |
#bind-key + resize-pane -U 2 # Resize height up. | |
bind-key -t vi-edit C-p history-up # Previous command. | |
bind-key -t vi-edit C-n history-down # Next command. | |
# } | |
# Copy mode { | |
bind-key -t vi-copy 'v' begin-selection # Begin selection in copy mode. | |
bind-key -t vi-copy 'C-v' rectangle-toggle # Begin selection in copy mode. | |
bind-key -t vi-copy 'y' copy-selection # Yank selection in copy mode. | |
# } | |
#bind-key - split-window -v # "Horizontal" split. | |
#bind-key | split-window -h # "Vertical" split. | |
# Open a new window with CWD set-option in PS1. | |
unbind-key c | |
bind-key c run-shell 'tmux new-window "cd \"$(tmux display -p "\$TMUXPWD_#D" | tr -d %)\"; exec $SHELL"' | |
bind-key C new-window | |
bind-key N select-pane -t:.+ # Cycle panes forwards. | |
bind-key P select-pane -t:.- # Cycle panes backwards. | |
# Split horizontally with CWD. | |
bind-key - run-shell 'tmux split-window -v "cd \"$(tmux display -p "\$TMUXPWD_#D" | tr -d %)\"; exec $SHELL"' | |
# Split vertically with CWD. | |
bind-key | run-shell 'tmux split-window -h "cd \"$(tmux display -p "\$TMUXPWD_#D" | tr -d %)\"; exec $SHELL"' | |
# Join window/pane to this window. The oposite of 'C-b !'. | |
bind-key @ command-prompt -p "create pane from:" "join-pane -s ':%%'" | |
#bind-key . command-prompt "move-window -t '%%'" # Move window to a new number. Default in newer tmux versions. | |
# Open urlview for current buffer. | |
bind-key o capture-pane \; save-buffer /tmp/${USER}_tmux-urlview \; split-window -v -l 10 "urlview /tmp/${USER}_tmux-urlview" | |
#bind-key O capture-pane \; save-buffer /tmp/${USER}_tmux-urlview \; split-window -h -l 50 "urlview /tmp/${USER}_tmux-urlview" | |
#bind-key O capture-pane \; save-buffer /tmp/${USER}_tmux-urlview \; new-window "urlview /tmp/${USER}_tmux-urlview" | |
bind-key O select-pane -t :.+ # Toggle panes. | |
bind-key r source-file ~/.tmux.conf; display-message "source-file done" # Source tmux configuration file. | |
bind-key M set-window-option monitor-activity # Toggle activity monitoring for the current window. | |
# Toggle logging of pane to file. | |
bind-key H pipe-pane -o "exec cat >>$HOME/'#W-tmux.log'" \; display-message 'Toggled logging to $HOME/.log/tmux/#I_#P-tmux.log' | |
# Copy tmux paste buffer to CLIPBOARD. | |
bind-key C-c run "tmux show-buffer | xclip -i -selection clipboard" \; display-message 'Copied tmux buffer to X clipboard.' | |
# Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer. | |
bind-key C-v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer" | |
# Zoom in pane by creating a new window and swap them. | |
bind z new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom | |
# Zoom out by swapping the pane back and kill the temporary window. | |
bind Z last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom | |
bind C-[ run '~/git/tmux-powerline/mute_powerline.sh left' # Mute left statusbar. | |
bind C-] run '~/git/tmux-powerline/mute_powerline.sh right' # Mute right statusbar. | |
bind / command-prompt "split-window -h 'exec man %%'" # Open man page in a split. | |
# } | |
--------------------- | |
tmux-start.sh | |
#!/bin/sh | |
# http://stackoverflow.com/questions/8537149/how-to-start-tmux-with-several-windows-in-different-directories | |
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/#tmux-shell-scripting | |
# http://www.tofu.org/drupal/node/183 | |
# https://github.com/dlbewley/tmux-scripts/blob/master/tmuxgo | |
SESSION="dataalpha" | |
ROOTDIR="~/work/dataalpha/lift_25_bootmetro_css" | |
#echo """ | |
# create new tmux session, name it $SESSION | |
tmux new-session -d -s $SESSION | |
# create new tabs, attach all to $SESSION | |
tmux new-window -t $SESSION:1 -n "Server1" "cd $ROOTDIR" # ./sbt container:start | |
tmux new-window -t $SESSION:2 -n "Server2" "cd $ROOTDIR" # git-sh | |
tmux new-window -t $SESSION:3 -n "Server3" "cd $ROOTDIR/cloudbees" # bees app:deploy | |
tmux new-window -t $SESSION:4 -n "Server4" "cd $ROOTDIR/src/main/scala/bootstrap/liftweb" #vim Boot.scala | |
tmux new-window -t $SESSION:5 -n "Server5" "cd $ROOTDIR/src/main/webapp" | |
tmux new-window -t $SESSION:6 -n "Server6" "cd $ROOTDIR/src/main/webapp" | |
tmux new-window -t $SESSION:7 -n "Server7" "cd $ROOTDIR/src/main/webapp" | |
tmux new-window -t $SESSION:8 -n "Server8" "cd $ROOTDIR/src/main/webapp" | |
tmux new-window -t $SESSION:9 -n "Server9" "cd $ROOTDIR/src/main/webapp" | |
tmux new-window -t $SESSION:10 -n "Server10" "cd $ROOTDIR/src/main/webapp" | |
tmux select-window -t $SESSION:1 | |
tmux -2 attach-session -t $SESSION | |
#""" | |
---------------- | |
УДЕРЖИВАЯ option (ALT) можно мышкой выделить и копировать | |
### Панели | |
Ctrl-b q (Показать номера панелей, наберите номер на клавиатуре, чтобы перейти к соответствующей панели) | |
Для разделения окна на два равных региона по вертикали использую ctrl+a+v, по горизонтали - ctrl+a+h, для циклического переключения по регионам - ctrl+a+o, смена расположения регионов - ctrl+a+Space | |
Ctrl+b PgUp — вход в «режим копирования», после чего: | |
PgUp, PgDown — скроллинг; | |
q — выход из «режима копирования». | |
После нажатия комбинации <C-b t> tmux выведет на экран большие часы, нарисованные псевдографикой. Они останутся на экране до нажатия любой клавиши. | |
--- | |
Работа с консольным мультиплексором tmux в FreeBSD | |
Работа с консольным мультиплексором tmux в FreeBSD | |
Описание и установка | |
tmux (the terminal multiplexer) - эта утилита предоставляет доступ сразу к нескольким терминалам в рамках одного окна (терминальный оконный менеджер или консольный мультиплексор). Изначально задумывалась как аналог/альтернатива утилиты screen под более свободной BSD-лицензией. | |
Установка из пакеджей: | |
# pkg_add -r tmux | |
Установка из портов: | |
// узнаем где находится порт tmux | |
$ whereis tmux | |
tmux: /usr/ports/sysutils/tmux | |
// переходим в директорию '/usr/ports/sysutils/tmux' | |
$ cd /usr/ports/sysutils/tmux | |
// компилируем и устанавливаем | |
# make install clean | |
Команды управления tmux | |
Работа с сессиями(session): | |
Ctrl-b d - Отключение от сессии, перевести tmux в фоновый режим. | |
Чтобы вернуть сессию после ее 'Ctrl-b d' отключения набираем в терминале: | |
$ tmux attach | |
Ctrl-b ? - Просмотр всех сочетаний клавиш и справка по командам. | |
Ctrl-b L - Перейти на предыдуще-открытую сессию. | |
Ctrl-b s - Выбрать сессию. | |
Ctrl-b D - Выбрать сессию(client) от которой отключиться (detach). | |
Ctrl-b f - Найти окно. | |
Ctrl-b $ - Переименовать текущую сессию. | |
Ctrl-b : - Командная строка. | |
Ctrl-b t - Часики :). | |
Ctrl-b ~ - Показать сообщения от tmux. | |
Ctrl-b r - Обновить клиент. | |
Ctrl-d - Закрытие текущей сессии. | |
Список сессий: | |
$ tmux ls | |
Подключение к конкретной сессии: | |
$ tmux attach -t 1 | |
Работа с окнами(window): | |
Ctrl-b c - Открытие нового окна. | |
Ctrl-b l - Вернутся на предыдущее выбранное окно. | |
Ctrl-b n - Переместится на следующее окно. | |
Ctrl-b p - Переместится на предыдущее окно. | |
Ctrl-b w - Выбрать окно из списка. | |
Ctrl-b ' - Задать индекс окна на которой перейти. | |
Ctrl-b 0 ... Ctrl-b 9 - Выбрать окно под соответствующим номером. | |
Ctrl-b . - Изменить номер окна. | |
Ctrl-b , - Переименовать текущее окно. | |
Ctrl-b & - Закрытие окна (или просто набрать 'exit' в терминале). | |
Ctrl-b i - Показать информацию о текущем окне. | |
Работа с фреймами, панелями (pane): | |
Ctrl-b % - Разделить окно на панели по вертикали. | |
Ctrl-b " - Разделить окно на панели по горизонтали. | |
Ctrl-b <пробел> - Листать «слои». | |
Ctrl-b ; - Перейти на предыдуще-активную панель. | |
Ctrl-b <стрелка_вверх>, Ctrl-b <стрелка_вниз>, Ctrl-b <стрелка_влево>, Ctrl-b <стрелка_вправо> - Перемещение между созданными фреймами. | |
Ctrl-b Ctrl-<стрелка_вверх>, Ctrl-b Ctrl-<стрелка_вниз>, Ctrl-b Ctrl-<стрелка_влево>, Ctrl-b Ctrl-<стрелка_вправо> - Изменить размеры фрейма (одно нажатие - 1 шаг). | |
Ctrl-b Meta-<стрелка_вверх>, Ctrl-b Meta-<стрелка_вниз>, Ctrl-b Meta-<стрелка_влево>, Ctrl-b Meta-<стрелка_вправо> - Изменить размеры фрейма (одно нажатие - 5 шагов). | |
Комментарии: // Meta = Alt = Esc | |
Ctrl-b Ctrl-o - Поменять содержимое в текущих панелях по кругу. | |
Ctrl-b { - Переместить фрейм вверх, вправо. | |
Ctrl-b } - Переместить фрейм вниз, влево. | |
Ctrl-b Meta-o - Вернуть предыдущее расположение панелей. | |
Ctrl-b Meta-1 ... Ctrl-b Meta-5 - Выстроить панели в один из указанных расположений: even-horizontal, even-vertical, main-horizontal, main-vertical, или tiled. | |
Ctrl-b x - Убрать панель (или можно просто набрать 'exit'). | |
Ctrl-b o - Переместится на следующую панель. | |
Ctrl-b { - Поменять панели справа-налево. | |
Ctrl-b } - Поменять панели слева-направо. | |
Ctrl-b q - Покажет номера панелей. | |
Буфера (buffer): | |
Ctrl-b [ - Перейти в режим копирования или перемещение по истории фрейма. | |
Ctrl-b PageUp - Перейти в режим копирования и подняться на 1 PageUp страницу. | |
Ctrl-b q - Выход из режима копирования, скроллинга. | |
Ctrl-b ] - Вставить содержимое буфера обмена. | |
Ctrl-b # - Список всех буферов обмена. | |
Для копирования: | |
Ctrl-[ | |
<стрелка_вверх, стрелка_вниз, стрелка_влево, стрелка_вправо> - перемещаемся к нужному фрагменту, | |
<пробел> - для пометки начала копирования, | |
<стрелка_вправо> - для выделения текста для копирования, | |
<Enter> - для пометки конца копирования. | |
Для вставки: | |
Ctrl-= - выбираем из буфера. | |
---- | |
http://robots.thoughtbot.com/post/19398560514/how-to-copy-and-paste-with-tmux-on-mac-os-x | |
How to Copy and Paste with Tmux on Mac OS X | |
Tmux is becoming pretty popular as of late, but as with any new technology, there are skeptics. I’m here to quell some rumors and outline how to start using Tmux effectively. | |
Out of all the questions I get, the most common is, “Does copying and pasting work in Tmux? I heard it wasn’t possible.” Forget that noise; copying and pasting works wonderfully with a couple of extra steps. | |
STEP 1: INSTALL REATTACH-TO-USER-NAMESPACE | |
If you’re using Homebrew, run: | |
brew install reattach-to-user-namespace | |
If you’re not, head to the repository and follow the instructions to compile yourself. Be sure to check out Chris Johnsen’s great writeup about what reattach-to-user-namespace is actually doing. | |
STEP 2: CONFIGURE TMUX | |
Open up your Tmux configuration (typically at ~/.tmux.conf) and throw this line at the top of the file: | |
set-option -g default-command "reattach-to-user-namespace -l zsh" | |
This assumes that you’ve installed reattach-to-user-namespace (and it’s in your $PATH) and that you’re using zsh. Every time you open a new window or pane, it’ll run reattach-to-user-namespace, which digs into some of Apple’s inner-workings to enable pbcopy and pbpaste support. | |
STEP 3: CONFIGURE OTHER APPLICATIONS | |
If you’re using Vim in a terminal, set your clipboard to the unnamed clipboard (make sure it’s not wrapped in a conditional has("gui_running")). | |
set clipboard=unnamed | |
If you want copying and pasting to work from your Tmux buffers, you may want to run something similar to this: | |
#!/bin/sh | |
while true; do | |
if test -n "`tmux showb 2> /dev/null`"; then | |
tmux saveb -|pbcopy && tmux deleteb | |
fi | |
sleep 0.5 | |
done | |
That’ll look to see if there are any buffers in tmux; if there are, it’ll copy it into the system clipboard and delete the buffer. This is really handy if you’re trying to grab a backtrace or the output from a command. | |
------- | |
From <http://www.instapaper.com/m?u=http%3A//jasonwryan.com/blog/2011/06/07/copy-and-paste-in-tmux/>: | |
I’ve posted a couple of times1 about [tmux](http://tmux.sourceforge.net/), the | |
brilliant terminal mutliplexer. One question I see raised a lot in #tmux is | |
how to copy and paste. | |
The documentation for tmux is excellent: the [man page](http://www.openbsd.org | |
/cgi-bin/man.cgi?query=tmux&sektion=1) one of the most clear and thorough I | |
have read. And while it is explained there, I thought I would share my | |
approach anyway. | |
First, I set tmux to use vi keys: | |
setw -g mode-keys vi | |
Then I change the default keybinds to suit my workflow. As explained in the | |
man page, the default keys to enter and exit copy mode are [ and ] | |
respectively. I reset those in my .tmux.conf to more intuitive and Vim-like | |
keys: | |
unbind [ | |
bind Escape copy-mode | |
unbind p | |
bind p paste-buffer | |
bind-key -t vi-copy 'v' begin-selection | |
bind-key -t vi-copy 'y' copy-selection | |
This seems a lot closer to all of the other Vim-like apps that I run - where | |
Escape changes the mode, v begins visual selection, y yanks text to the buffer | |
and p puts text copied from the buffer. | |
So, to string it all together, the command sequence necessary to copy some | |
text from tmux and paste it is now (I bind my prefix to t): | |
Ctrlt,Escape # enter copy mode | |
# move cursor to the start or end of the desired text string | |
v # to activate highlighting | |
# move cursor to cover the requisite string | |
y # to capture the string | |
q # exit copy mode | |
Ctrlt,p # put/paste the text in the desired location | |
Simple. | |
This means that you can scroll back through the output of _anything_ in your | |
terminal, and copy and paste it anywhere. Once you set it up, it is a very | |
powerful tool… | |
##### Notes | |
1.[tmux - Terminal-multiplexer](http://jasonwryan.com/blog/2010/01/07/tmux- | |
terminal-multiplexer/) & [Sessions in | |
tmux](http://jasonwryan.com/blog/2010/10/03/sessions-in-tmux/) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment