Tmux 配置

Babun

  • 安装 pact install tmux(需管理员权限)

MAC OS X

  • 安装 brew install tmux

启动

  • tmux

  • 常用参数

    # 创建session
    tmux
    
    # 创建并指定session名字
    tmux new -s $session_name
    
    # 列出session
    tmux ls
    
    # 进入已存在的session
    tmux a -t $session_name
    
    # 删除指定session
    tmux kill-session -t $session_name
    
    # 删除所有session
    Ctrl+b :kill-server
    
    # 删除session
    Ctrl+b :kill-session
    
    # 临时退出session
    Ctrl+b d

复制/粘贴

  • brew install reattach-to-user-namespace
  • Add to ~/.tmux.conf
# getting tmux to copy a buffer to system clipboard
set-option -g default-command "reattach-to-user-namespace -l zsh" # or bash...
bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy" \; display-message "Copied tmux buffer to system clipboard"
bind C-v run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
  • Usage

    • copy/selection: prefix + y
    • paste: ctrl + v

配置Powerline-Shell

  • git clone https://github.com/erikw/tmux-powerline.git

  • edit your ~/.tmux.conf to use the scripts

    set-option -g status on
    set-option -g status-interval 2
    set-option -g status-utf8 on
    set-option -g status-justify "centre"
    set-option -g status-left-length 60
    set-option -g status-right-length 90
    set-option -g status-left "#(~/path/to/tmux-powerline/powerline.sh left)"
    set-option -g status-right "#(~/path/to/tmux-powerline/powerline.sh right)"

自定义配置

#-- bindkeys --#
# prefix key (Ctrl+a)
set -g prefix ^a
unbind ^b
bind a send-prefix

# refresh
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# mouse
setw -g mode-mouse on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on
set -s escape-time 1

# split window
unbind '"'
# vertical split (prefix -)
bind - splitw -v
unbind %
# horizontal split (prefix |)
bind | splitw -h

# panel
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# panel shortcuts
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

# panel resize
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# set default zsh shell
set-option -g default-shell /bin/zsh

Tmuxinator & Teamocil

  • Site https://github.com/tmuxinator/tmuxinator https://github.com/remiprev/teamocil

  • Install

    curl https://rubygems.org/downloads/thor-0.19.1.gem
    sudo gem install --local <path/to/thor-0.19.1.gem>
    
    curl https://rubygems.org/downloads/erubis-2.7.0.gem
    sudo gem install --local <path/to/erubis-2.7.0.gem>
    
    curl https://rubygems.org/downloads/tmuxinator-0.6.10.gem
    sudo gem install --local <path/to/tmuxinator-0.6.10.gem>
    
    curl https://rubygems.org/downloads/teamocil-1.2.gem
    sudo gem install --local <path/to/teamocil-1.2.gem>
  • Tmuxinator

    • Usage
    mux xxx
    • Config mkdir .tmuxinator && cd .tmuxinator
    name: simptab
    root: ~/
    windows:
      - project:
          root: ~/
          panes:
            - clear
            - cd ~/Work/11-Web/01-work/simptab
    
  • Teamocil

    • Usage
    tmux
    teamocil xxx
    • Config
      mkdir .teamocil && cd .teamocil

      windows:
      - name: simptab
      root: ~/Work/11-Web/01-work/simptab
      layout: even-horizontal
      panes:
        - cd ~
        - git status
      

参考

2015-05-09 17:28