当前使用的vim与tmux配置文件

VIM

.vimrc
set nu
set hlsearch
syntax on

set noeb
set vb t_vb=
inoremap jj <Esc>`^

let mapleader=","
inoremap <leader>w <Esc>:w<cr>
noremap <leader>w :w<cr>

"切换buffer
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> [b :bnext<CR>

" user ctrl+h/j/k/l switch window
noremap <C-h> <C-w>h
noremap <C-h> <C-w>j
noremap <C-h> <C-w>k
noremap <C-h> <C-w>l

"插件设置 vim-plug
call plug#begin('~/.vim/plugged')
Plug 'itchyny/lightline.vim'
Plug 'mhinz/vim-startify'
Plug 'scrooloose/nerdtree'
call plug#end()

" 插件相关配置
" 禁止 startify 自动切换目录
let g:startify_change_to_dir=0

" nerdtree
nmap ,v :NERDTreeFind<cr>
nmap ,g :NERDTreeToggle<cr>

操作步骤
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim
vim :PlugInstall

tmux

tmux.sh

#!/bin/bash
echo "#for tmux:">> ~/.bashrc
echo "alias tmux='TERM=xterm-256color tmux'" >> ~/.bashrc
echo "tmux config done"

.tmux.conf

# add tmux='TERM=xterm-256color tmux' in bashrc 
# to support 256 colour in tmux
#0 is too far from ` ;)
set -g base-index 1
 
#change prefix key
set -g prefix ^a
unbind ^b

# Automatically set window title
set-window-option -g automatic-rename off
set-option -g set-titles on
 
set -g default-terminal "screen-256color"
set -g status-keys vi
set -g history-limit 10000
 
setw -g mode-keys vi
setw -g monitor-activity on
 
bind-key c new-window -c "#{pane_current_path}"
bind-key h split-window -h -c "#{pane_current_path}"
bind-key v split-window -v -c "#{pane_current_path}"
bind-key k confirm kill-window
bind-key -n M-Left swap-window -t -1
bind-key -n M-Right swap-window -t +1
bind -n F9 resizep -U 1
bind -n F10 resizep -D 1
bind -n F11 resizep -L 1
bind -n F12 resizep -R 1
 
# Use Alt-hjkl keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D 
bind -n M-k select-pane -U
bind -n M-l select-pane -R
 
# Use Alt-Number to select window
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8 
bind -n M-9 select-window -t 9 

# Use Ctrl-a to switch between current and last window
bind-key C-a select-window -l

#setw -g mode-mouse off
#set -g mouse-resize-pane off
#set -g mouse-select-pane off
#set -g mouse-select-window off

# No delay for escape key press
set -sg escape-time 0
 
# THEME
# colour24 colour191 colour103 colour166 colour232
set -g status-bg colour24
set -g status-fg white
set -g status-justify centre
set -g window-status-current-bg colour234
set -g window-status-current-fg colour191
set -g window-status-current-attr bright
set -g window-status-format '[ #I:#W ]'
set -g window-status-current-format '[  #I:#W  ]'
set -g pane-border-style bg=colour232,fg=colour232
set -g pane-active-border-bg colour232
set -g pane-active-border-fg colour166
set -g status-interval 1
set -g status-left-length 10
#set -g status-left '#[bg=colour148]#[fg=colour22][#T)]'
set -g status-left ''
set-option -g status-position bottom
set -g status-right '#[fg=colour181]%H:%M        '
set -g message-bg colour24
set -g message-fg colour191

使用说明

tmuxconfig

tmux config file and shell

tmux的其他操作和快捷键

tmux a -t name 连接到Session
tmux new -s name 创建新的Session
tmux ls 查看Session列表

tmux的使用主要依赖prefix-key和快捷键的组合。
这里的快捷键,我在tmux的默认基础上做了修改,目标是少按键更符合用户本能操作。
我个人的tmux配置文件已经放在了文末的附件里,解压缩后重命名为.tmux.conf,放到/home/[user]/目录下,重启tmux生效。按键方式是先输入prefix-key,然后放开再输入快捷键。这里的prefix-key是Ctrl + a, 常用的如下:

创建新窗口 C-a + c
关闭当前窗口 C-a + k 或者直接输入exit
为当前窗口改名 C-a + ,
创建水平窗格 C-a + h
创建纵向窗格 C-a + v
关闭当前窗格 输入exit

在窗口之间切换选择 Alt + 123456789
当前窗口向左移动 Alt + 左方向键
当前窗口向右移动 Alt + 右方向键
在窗格之间上下左右移动 Alt + hjkl 参考vi方式
重新调整当前窗格上下左右的大小 F9,F10,F11,F12

退出tmux C-a d

浏览窗口的历史记录 C-a + [
这个命令可以让当前窗口进入Vi模式,可以使用vi的操作方式对当前窗口的输入进行搜索移动。一般在编译出错的时候,进入这种模式可以非常方便的找到错误的地方
而不用像以往那样拖动进度条一点点靠肉眼往回找。

主要的快捷操作就这么多,其余的操作和命令网上也很多,.tmux.conf文件也很容易看懂,可以自行往里面添加,记住重启tmux生效。
或者更简单的方法是C-a + :打开tmux的命令栏,输入 source ~/.tmuc.conf 来重新加载tmux配置文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值