zsh vim tmux (Ubuntu)

908 查看

zsh

安装:

sudo apt-get install zsh

切换默认shell: (cat /etc/shells)

chsh -s /bin/zsh

安装oh my zsh
自动安装:

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

手动安装:

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

配置:

alias cls='clear'
alias ll='ls -l'
alias la='ls -a'
alias vi='vim'
alias df='df -h'
alias du='du -h'
alias dk='sudo docker'
alias dkp='sudo docker ps'
alias dka='sudo docker ps -a'
alias grep="grep --color=auto"

alias javac="javac -J-Dfile.encoding=utf8"
alias -s html=mate   # 在命令行直接输入后缀为 html 的文件名,会在 TextMate 中打开
alias -s rb=mate     # 在命令行直接输入 ruby 文件,会在 TextMate 中打开
alias -s py=vi       # 在命令行直接输入 python 文件,会用 vim 中打开,以下类似
alias -s js=vi
alias -s c=vi
alias -s java=vi
alias -s txt=vi
alias -s gz='tar -xzvf'
alias -s tgz='tar -xzvf'
alias -s zip='unzip'
alias -s bz2='tar -xjvf'

主题(默认robbyrussell):
.zshrc中,找到ZSH—THEME,就可以设置主题了。
oh my zsh提供数十种主题,相关文件在~/.oh-my-zsh/themes目录下,可以随意选择,也可以自己调整配置。
我对默认配置只做了一处修改,将相对路径(%c)改成了绝对路径(%d)。

插件
在.zshrc文件中找到plugins关键字,系统默认只加载git,你可以在后面增加你想要加载的插件,以空格分隔,我暂时启用了两个,如下:

plugins=(git autojump)
  • git:当你处于一个 git 受控的目录下时,Shell 会明确显示 「git」和 branch;另外对 git 很多命令进行了简化,例如 gco=’git checkout’、gd=’git diff’、gst=’git status’、gbr=’git branch’等等,命令内容可以参考~/.oh-my-zsh/plugins/git/git.plugin.zsh

  • autojump:安装autojump, sudo apt-get install autojump; j 目录(一部分) 就可以跳转到以前访问过后目录。 j --stat 可以列出所有系统记录过的目录访问历史。 jc 子目录 跳转到当前目录的子目录。 jo 文件名 就可以用 资源管理器 打开文件, jco 文件名 打开当前目录子目录下的文件。

tmux

# -- base -- #
unbind C-b
set -g prefix C-q
set -g status-keys vi
setw -g mode-keys vi
bind : command-prompt
bind r source-file ~/.tmux.conf \; display-message "Reloading..".
set -g default-terminal "screen-256color"
bind-key a send-prefix

# -- windown -- #
bind s split-window -h -c "#{pane_current_path}"
bind v split-window -v -c "#{pane_current_path}"
bind-key c  new-window -c "#{pane_current_path}"

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

bind ^k resizep -U 10
bind ^j resizep -D 10
bind ^h resizep -L 10
bind ^l resizep -R 10
bind ^u swapp -U
bind ^d swapp -D

bind u choose-session
bind o choose-window
bind \ last
bind q killp

bind-key -n C-S-Left swap-window -t -1
bind-key -n C-S-Right swap-window -t +1
set -g base-index 1
setw -g pane-base-index 1
set -g history-limit 5000

# pane border
set -g pane-border-fg black
set -g pane-border-bg white
set -g pane-active-border-fg black
set -g pane-active-border-bg '#afd787'

# -- command -- #
bind m command-prompt "splitw 'exec man %%'"
bind space copy-mode
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection
bind -t vi-copy C-v rectangle-toggle
bind ] paste-buffer

# -- statusbar --#
set -g status-justify centre
set -g status-right-attr bright
set -g status-right "%H:%M %a %m-%d"
set -g status-bg default
set -g status-fg '#afd787'
setw -g window-status-current-attr bright
setw -g window-status-current-fg black
setw -g window-status-current-bg '#afd787'
set -g status-utf8 on
set -g status-interval 1

# -- mouse --#
setw -g mouse-resize-pane on 
setw -g mouse-select-pane on 
setw -g mouse-select-window on 
setw -g mode-mouse on

相关命令:

Managing tmux server
tmux    #start tmux server
tmux at  #attach running sesseion to terminal
tmux ls  #list running tmux sessions
exit     #close tmux session

Sharing session between terminals
tmux new –s session_name  #make new named session
tmux at –t session_name    #attach to exists session(s)
tmux kil-session –t session_name #killnamed session

vim

见我以前的文章。