Linux好用的vim超级配置+zsh配置完整版。

822 阅读3分钟

1:介绍vim

	vim是用于Linux下编译代码的工具,具有一定的补全功能,但是与我们配置的相比就要差商许多了。在这里、我首先介绍如何配置vimplus(是一款非常好用的vim配置)。之后我再介绍zsh的配置,zsh是一种shell脚本,是我们和Linux交互的工具。
	vimplus的安装只需要执行几个命令就可以,非常简单。
	cd  ~。
	sudo git clone https://github.com/chxuan/vimplus.git ~/.vimplus.
	cd ~/.vimplus
	./install.sh
	这样,强大的vim配置就安装完成了。在这里需要注意的是,如果你没有git这个工具,可以使用sudo apt install git 命令进行安装。如果你的apt源配置错误,也就是在保证你可以正常连接网络的情况下不能够下载这个工具,请打开这个链接[https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11vU4mtw]()  
	这是一个阿里源的地址,点击就可以下载。好了关于vim的配置我这里就介绍这么多。
	
	
	

2:介绍zsh的相关配置。

	在这里介绍我的zsh配置,之前说过了,zsh是我们和Linux交互的命令工具。
	首先、第一点需要确定的是你有没有zsh这个工具,如果你没有zsh这个工具请使用sudo apt install zsh进行安装。
	第二点就是我们的zsh配置了,我们可以在自己的家目录下进行配置,首先我们创建一个.zshrc这个文件,此文件是我们这个用户登陆的时候zsh读取的配置文件。
	最后一点,我将zsh配置连接放到这里,直接使用下述命令安装即可。
	git clone https://github.com/spicycode/ze-best-zsh-config.git 目录
	如果下载下来的是压缩包,请解压,然后将其中的隐藏文件拷贝到家目录下,也就是~目录下。
	最后我将我改过的.zshrc文件贴到这里,我改的文件是根据这个下载内容进行更改整合的,因为下载的东西不能够完全使用。
	之后在家目录创建.zshrc文件,将下述内容添加到.zshrc文件中,之后使用命令sourc .zshrc就可以生效了,如果还没有生效的话,请退出Linux重新登录。

						if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
				export PATH=bin:script:.bin:$PATH

				precmd() {
					if [[ -n "$TMUX" ]]; then
						tmux setenv "$(tmux display -p 'TMUX_PWD_#D')" "$PWD"
					fi
				}
				# 别名部分,这部分根据自己的喜好进行甚至

				alias la='ls -a'
				alias lc='ls *.c'
				alias sl='ls'
				alias ll='ls -l'
				alias grepn='grep -nrE ./'
				alias findn='find ./ -name'
				alias rm='rm -i'
				alias cpr='cp -r'
				alias rmd='rm -r'
				alias v.z='vim ~/.zshrc'
				alias s.z='source ~/.zshrc'


				# color 部分内容
				autoload colors; colors

				# The variables are wrapped in %{%}. This should be the case for every
				# variable that does not contain space.
				for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
					eval PR_$COLOR='%{$fg_no_bold[${(L)COLOR}]%}'
					eval PR_BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
				done

				eval RESET='$reset_color'
				export PR_RED PR_GREEN PR_YELLOW PR_BLUE PR_WHITE PR_BLACK
				export PR_BOLD_RED PR_BOLD_GREEN PR_BOLD_YELLOW PR_BOLD_BLUE 
				export PR_BOLD_WHITE PR_BOLD_BLACK

				# Clear LSCOLORS
				unset LSCOLORS
				export CLICOLOR=1
				export LS_COLORS=exfxcxdxbxegedabagacad


				# 绑定某些按键

				# To see the key combo you want to use just do:
				# cat > /dev/null
				# And press it

				bindkey "^K"      kill-whole-line                      # ctrl-k
				bindkey "^R"      history-incremental-search-backward  # ctrl-r
				bindkey "^A"      beginning-of-line                    # ctrl-a  
				bindkey "^E"      end-of-line                          # ctrl-e
				bindkey "[B"      history-search-forward               # down arrow
				bindkey "[A"      history-search-backward              # up arrow
				bindkey "^D"      delete-char                          # ctrl-d
				bindkey "^F"      forward-char                         # ctrl-f
				bindkey "^B"      backward-char                        # ctrl-b
				bindkey -e   # Default to standard emacs bindings, regardless of editor string


				# 定义某些全局变量
				# Currently this path is appendend to dynamically when picking a ruby version
				export PATH=node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/local/share/npm/bin:~/.cabal/bin:~/.local/bin:$PATH
				export PATH=$PATH:/opt/boxen/homebrew/opt/go/libexec/bin

				# Setup terminal, and turn on colors
				export TERM=xterm-256color
				export CLICOLOR=1
				export LSCOLORS=Gxfxcxdxbxegedabagacad

				# Enable color in grep
				export GREP_OPTIONS='--color=auto'
				export GREP_COLOR='3;33'

				# This resolves issues install the mysql, postgres, and other gems with native non universal binary extensions
				export ARCHFLAGS='-arch x86_64'

				export LESS='--ignore-case --raw-control-chars'
				export PAGER='most'
				export EDITOR='vim'
				export PYTHONPATH=/usr/local/lib/python2.6/site-packages
				# CTAGS Sorting in VIM/Emacs is better behaved with this in place
				export LC_COLLATE=C

				# GitHub token with no scope, used to get around API limits
				#xport HOMEBREW_GITHUB_API_TOKEN=$(cat ~/.gh_api_token)

				# setopt 某些选项设置
				# ===== Basics

				# If you type foo, and it isn't a command, and it is a directory in your cdpath, go there
				setopt AUTO_CD

				# Allow comments even in interactive shells (especially for Muness)
				# setopt INTERACTIVE_COMMENTS

				# ===== History

				# Allow multiple terminal sessions to all append to one zsh command history
				setopt APPEND_HISTORY 

				# Add comamnds as they are typed, don't wait until shell exit
				setopt INC_APPEND_HISTORY 

				# Do not write events to history that are duplicates of previous events
				setopt HIST_IGNORE_DUPS

				# When searching history don't display results already cycled through twice
				setopt HIST_FIND_NO_DUPS

				# Remove extra blanks from each command line being added to history
				setopt HIST_REDUCE_BLANKS

				# Include more information about when the command was executed, etc
				setopt EXTENDED_HISTORY

				# ===== Completion 

				# Allow completion from within a word/phrase
				setopt COMPLETE_IN_WORD 

				# When completing from the middle of a word, move the cursor to the end of the word
				setopt ALWAYS_TO_END            

				# ===== Prompt

				# Enable parameter expansion, command substitution, and arithmetic expansion in the prompt
				setopt PROMPT_SUBST

				unsetopt MENU_COMPLETE
				setopt AUTO_MENU

				# 历史设置
				HISTSIZE=10000
				SAVEHIST=10000
				HISTFILE=~/.zsh_history

				bindkey '^R' zaw-history


				function git_prompt_info {
					local ref=$(=git symbolic-ref HEAD 2> /dev/null)
					local gitst="$(=git status 2> /dev/null)"

					if [[ -f .git/MERGE_HEAD ]]; then
						if [[ ${gitst} =~ "unmerged" ]]; then
							gitstatus=" %{$fg[red]%}unmerged%{$reset_color%}"
						else
							gitstatus=" %{$fg[green]%}merged%{$reset_color%}"
						fi
					elif [[ ${gitst} =~ "Changes to be committed" ]]; then
						gitstatus=" %{$fg[blue]%}!%{$reset_color%}"
					elif [[ ${gitst} =~ "use \"git add" ]]; then
						gitstatus=" %{$fg[red]%}!%{$reset_color%}"
					elif [[ -n `git checkout HEAD 2> /dev/null | grep ahead` ]]; then
						gitstatus=" %{$fg[yellow]%}*%{$reset_color%}"
					else
						gitstatus=''
					fi

					if [[ -n $ref ]]; then
						echo "%{$fg_bold[green]%}/${ref#refs/heads/}%{$reset_color%}$gitstatus"
					fi
				}

				PROMPT='%~%<< $(git_prompt_info)${PR_BOLD_WHITE}>%{${reset_color}%} '

				precmd() {
					if [[ -n "$TMUX" ]]; then
						tmux setenv "$(tmux display -p 'TMUX_PWD_#D')" "$PWD"
					fi
				}

本文由博客群发一文多发等运营工具平台 OpenWrite 发布