Centos 开发环境依赖安装。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# install git
yum install git

# zsh config
yum -y install zsh
chsh -s /bin/zsh
echo $SHELL
yum install autojump-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# install tmux
yum install tmux

# install nodejs(use nvm)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
nvm -v
nvm install 8
node -v
npm -v

详细配置

zsh 配置

配置 autojump

  • .zshrcplugin 配置增加 plugins=(git autojump)

nvm 安装

.zshrc 追加 [[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh # This loads NVM
source .zshrc 使配置生效

Git

  • 高亮显示: git config --global color.ui true
  • 解决 Git log 乱码,设置 Git 全局配置

    1
    2
    git config --global i18n.commitEncoding ISO-8859 #设置提交的编码
    git config --global i18n.logOutputEncoding ISO-8859 #设置日志的编码

    设置环境变量

    1
    export LESSCHARSET=utf-8 #设置 Shell 临时环境变量

Vim 配置

  • 安装 Vundle git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  • 配置 ~/.vimrc
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    " 显示行号
    set number
    " 显示标尺
    set ruler
    " 历史纪录
    set history=1000
    " 输入的命令显示出来,看的清楚些
    set showcmd
    " 状态行显示的内容
    set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
    " 启动显示状态行1,总是显示状态行2
    set laststatus=2
    " 语法高亮显示
    syntax on
    set fileencodings=utf-8,gb2312,gbk,cp936,latin-1
    set fileencoding=utf-8
    set termencoding=utf-8
    set fileformat=unix
    set encoding=utf-8

    " 配色方案
    colorscheme gruvbox
    set background=dark

    " 指定配色方案是256色
    set t_Co=256

    set wildmenu

    " 去掉有关vi一致性模式,避免以前版本的一些bug和局限,解决backspace不能使用的问题
    set nocompatible
    set backspace=indent,eol,start
    set backspace=2

    " 启用自动对齐功能,把上一行的对齐格式应用到下一行
    set autoindent

    " 依据上面的格式,智能的选择对齐方式,对于类似C语言编写很有用处
    set smartindent

    " vim禁用自动备份
    set nobackup
    set nowritebackup
    set noswapfile

    " 用空格代替tab
    set expandtab

    " 设置显示制表符的空格字符个数,改进tab缩进值,默认为8,现改为4
    set tabstop=4

    " 统一缩进为4,方便在开启了et后使用退格(backspace)键,每次退格将删除X个空格
    set softtabstop=4

    " 设定自动缩进为4个字符,程序中自动缩进所使用的空白长度
    set shiftwidth=4

    " 设置帮助文件为中文(需要安装vimcdoc文档)
    set helplang=cn

    " 显示匹配的括号
    set showmatch

    " 文件缩进及tab个数
    au FileType html,python,vim,javascript setl shiftwidth=4
    au FileType html,python,vim,javascript setl tabstop=4
    au FileType java,php setl shiftwidth=4
    au FileType java,php setl tabstop=4
    " 高亮搜索的字符串
    set hlsearch

    " 检测文件的类型
    filetype on
    filetype plugin on
    filetype indent on

    " 配置插件
    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    Plugin 'VundleVim/Vundle.vim'
    Plugin 'morhetz/gruvbox'
    call vundle#end()
    filetype plugin indent on

    " C风格缩进
    set cindent
    set completeopt=longest,menu

    " 功能设置

    " 去掉输入错误提示声音
    set noeb
    " 自动保存
    set autowrite
    " 突出显示当前行
    set cursorline
    " 突出显示当前列
    set cursorcolumn
    "设置光标样式为竖线vertical bar
    " Change cursor shape between insert and normal mode in iTerm2.app
    "if $TERM_PROGRAM =~ "iTerm"
    let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
    let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
    "endif
    " 共享剪贴板
    set clipboard+=unnamed
    " 文件被改动时自动载入
    set autoread
    " 顶部底部保持3行距离
    set scrolloff=3

    ### 中文显示
    set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
    set termencoding=utf-8
    set encoding=utf-8

问题

Q: manpath: can’t set the locale; make sure $LC_* and $LANG are correct

A:

1
2
3
# .zshrc 中设置,记得 source
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Q:Cannot find color scheme ‘gruvbox’

A:same thing happened to me and the above suggestion made no difference. I was able to fix my situation by creating a colors directory in my .vim directory
mkdir ~/.vim/colors
and then copying the gruvbox colors file to that directory
cp ~/.vim/bundle/gruvbox/colors/gruvbox.vim ~/.vim/colors/