tech_memo
tmuxセッション内でsshした先でtmuxのコマンドをssh元に送信する †
- 下記のようなことがやりたい
- [LOCAL]:$ tmux
- [LOCAL]:$ ssh REMOTE
- [REMOTE]:$ tmux select-pane -D
コマンドオプション †
TPM (Tmux Plugin Manager) †
- github
- インストール
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
- tmux.conf設定
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
- リロード
$ tmux source ~/.tmux.conf
RHEL6.3でtmuxのビルド †
- tmuxのソース
- 依存PKG1 : libevent 2.x
- RHEL6の標準は1.4なので、下記からソースを取ってきてビルドする
- http://libevent.org/
- ビルド後やること
- libeven-2.x.so.xのlibディレクトリをLD_LIBRARY_PATHに通すなどして、参照できるようにする(もしくは参照できる場所にmake installする。libevent1.4との衝突に注意)
- /usr/lib64/pkgconfig配下に、<make install先DIR>/lib/pkgconfig/libevent.pcを配備(リンクでもOK)
- 依存PKG2 : ncurses
- 標準DVDからインストール可能
- ncurses-develも必要
tmux.conf †
#=======================================================
# Basic Configurations
#=======================================================
set-window-option -g utf8 on
# keybind
set-window-option -g mode-keys vi
bind-key ` suspend-client
#------------------
# mouse
#------------------
# Until version 2.0
#bind m \
# set -g mode-mouse on \;\
# set -g mouse-resize-pane on \;\
# set -g mouse-select-pane on \;\
# set -g mouse-select-window on \;\
# display 'Mouse: ON'
# bind M \
# set -g mode-mouse off \;\
# set -g mouse-resize-pane off \;\
# set -g mouse-select-pane off \;\
# set -g mouse-select-window off \;\
# display 'Mouse: OFF'
# From version 2.1
bind m set-option -g mouse on
bind M set-option -g mouse off
# Dont need from version 2.3(?)
#bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
set-option -g base-index 0
# Scroll History
set -g history-limit 10000
# Prefix
set-option -g prefix C-z
#set-option -g prefix C-q
unbind-key C-b
bind C-z send-prefix
bind a send-prefix
# Timer
set -s escape-time 0
#=======================================================
# View
#=======================================================
#-------------------------------
# Status line
#-------------------------------
set -g status-interval 5
set -g status-left-length 100
set -g status-right-length 50
set-option -g set-titles on
set-option -g set-titles-string "@#(hostname | sed 's/\\\\..*//')"
#-------------------------------
# bottom status bar
#-------------------------------
# Status bar has a dim gray background
set -g status-bg white
set -g status-fg cyan
set -g status-attr dim
# left :whoami@hostname
#set -g status-left '#[fg=blue,bold][#20(whoami)@#H(#I:#P)]#[defaujt]'
set -g status-left '#[fg=black,bg=white]#H#[fg=black]:#[fg=black,bg=green][#S#[fg=balack]]##[default]'
set -g status-left-length 30
# right :[2011/03/06(Sun)20:21]
#set -g status-right '#[fg=blue,bold][%Y/%m/%d(%a)%H:%M]#[default]'
set -g status-right '#[fg=black,bg=white] [%Y-%m-%d(%a) %H:%M:%S]#[default]'
set -g status-interval 1
set -g message-attr bold
set -g message-fg white
set -g message-bg red
#-------------------------------
# Pane
#-------------------------------
set -g pane-border-fg cyan
set -g pane-border-bg black
set -g pane-active-border-fg cyan
set -g pane-active-border-bg black
#-------------------------------
# Window
#-------------------------------
set-window-option -g mode-bg white
set-window-option -g mode-fg black
set-window-option -g window-status-bg black
set-window-option -g window-status-bg white
set-window-option -g window-status-fg white
set-window-option -g window-status-fg black
setw -g window-status-current-fg white
setw -g window-status-current-bg cyan
setw -g window-status-current-attr bold#,underscore # pane-active-border
#-------------------------------
# Window
#-------------------------------
bind 8 switchc -p
bind 9 switchc -n
#=======================================================
# KeyBindings
#=======================================================
# reload config
bind r source-file ~/.tmux.conf\; display-message "Reload Config!!"
#-------------------------------
# Window
#-------------------------------
bind Space choose-window
bind c new-window
bind -r n next-window
bind -r p previous-window
bind -n C-M-l next-window
bind -n C-M-h previous-window
bind -n M-Right next-window
bind -n M-Left previous-window
unbind right
unbind left
bind -r right next-window
bind -r left previous-window
# windows ^W w
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows
# kill K k
unbind K
bind K confirm-before "kill-window"
unbind x
bind x confirm-before "kill-window"
#-------------------------------
# Pane
#-------------------------------
# split window
unbind %
bind \ split-window -h
bind - split-window -v
# move pane
bind-key k select-pane -U
bind-key j select-pane -D
bind-key h select-pane -L
bind-key l select-pane -R
bind-key -n M-k select-pane -U
bind-key -n M-j select-pane -D
bind-key -n M-h select-pane -L
bind-key -n M-l select-pane -R
# select pane
unbind Tab
bind Tab select-pane -t :.+
unbind BTab
bind BTab select-pane -t :.-
# display pane number
# ex) C-a i 1
bind i display-panes
# resize pane
bind -r C-h resize-pane -L 1
bind -r C-l resize-pane -R 1
bind -r C-j resize-pane -D 1
bind -r C-k resize-pane -U 1
bind -r C-n resize-pane -D 6
bind -r C-p resize-pane -U 6
bind -n C-M-k resize-pane -U 1
bind -n C-M-j resize-pane -D 1
# select-layout
bind-key | select-layout even-horizontal
bind-key = select-layout even-vertical
bind-key ` select-layout tiled
# synchronize-pane
bind-key s set-window-option synchronize-panes on
bind-key u set-window-option synchronize-panes off
#-------------------------------
# Other
#-------------------------------
# Esc = copy-mode
#unbind [
bind Escape copy-mode
# v and y like vi in copy-mode
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
# copy-mode ^[
unbind ^"["
bind -r ^"[" copy-mode
unbind ^]
bind -r ^] paste-buffer
最新の20件
2023-01-26
2022-11-11
2022-03-02
2022-02-03
2021-11-18
2021-11-11
2021-10-27
2021-10-04
2021-09-30
2021-08-24
2021-04-01
2021-02-25
2020-08-13
2020-05-22
2020-04-16
2020-04-15
2020-03-23
2020-03-12
2020-02-27
今日の20件
- counter: 532
- today: 2
- yesterday: 1
- online: 2