zoukankan      html  css  js  c++  java
  • Tmux安装和使用

    1、What's tmux

    tmux 是一个终端复用器: 可以激活多个终端或窗口, 在每个终端都可以单独访问,每一个终端都可以访问,运行和控制各自的程序.tmux类似于screen,可以关闭窗口将程序放在后台运行,需要的时候再重新连接。

    2、How to install tmux

    如果你创建的是workspace,那么已经安装好了tmux,如果你想全新安装tmux,只需要执行:

    sudo apt-get install -y tmux
    

    3、配置tmux

    3.1、编辑 ~/.tmux.conf 文件,添加下面代码

    set -sg escape-time 0
    set-option -g history-limit 30000
    # set-option -g default-shell /bin/zsh  # 使用 zsh 为默认 shell
    set-window-option -g mode-keys vi # vi key
    set-option -g status-keys vi
    set -g default-terminal "tmux-256color"
      
    # vim-like pane selection
    bind l select-pane -R
    bind j select-pane -D
    bind k select-pane -U
    bind h select-pane -L
      
    bind -r c-h resize-pane -L 5
    bind -r c-j resize-pane -D 1
    bind -r c-k resize-pane -U 1
    bind -r c-l resize-pane -R 5
      
    # 在当前目录创建新窗口
    unbind-key c
    bind c new-window -c "#{pane_current_path}"
    unbind-key '"'
    unbind-key '%'
    bind '"' split-window -c '#{pane_current_path}'
    bind '%' split-window -h -c '#{pane_current_path}'
    # end
      
    set -g base-index 1 # start windows numbering at 1
    setw -g pane-base-index 1 # make pane numbering consistent with windows
    set-option -g update-environment "DBUS_SESSION_BUS_ADDRESS DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
      
    # 显示工作区标题
    set -g pane-border-status top
    set -g pane-border-format "#{pane_index} #T"
    

    3.2、重新导入tmux配置环境

    tmux source ~/.tmux.conf
    

    4、如何让zsh标题为目录名?

    编辑 ~/.zshrc 加入如下代码段:

    function set_tmux_title () {
        printf '33]2;'"$1"'33\'
    }
      
    function auto_tmux_title() {
        emulate -L zsh
        printf '33]2;'"${PWD:t}"'33\'
    }
      
    auto_tmux_title
    chpwd_functions=(${chpwd_functions[@]} "auto_tmux_title")
    
    

    tmux cheat sheet
    https://gist.github.com/ryerh/14b7c24dfd623ef8edc7

  • 相关阅读:
    Best Time to Buy and Sell Stock III
    Valid Palindrome
    Longest Substring Without Repeating Characters
    Copy List with Random Pointer
    Add Two Numbers
    Recover Binary Search Tree
    Anagrams
    ZigZag Conversion
    Merge k Sorted Lists
    Distinct Subsequences
  • 原文地址:https://www.cnblogs.com/michaelcjl/p/12436284.html
Copyright © 2011-2022 走看看