1:介紹vim
vim是用于Linux下編譯代碼的工具,具有一定的補全功能,但是與我們配置的相比就要差商許多了。在這里、我首先介紹如何配置vimplus(是一款非常好用的vim配置)。之后我再介紹zsh的配置,zsh是一種shell腳本,是我們和Linux交互的工具。
vimplus的安裝只需要執(zhí)行幾個命令就可以,非常簡單。
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配置了,我們可以在自己的家目錄下進行配置,首先我們創(chuàng)建一個.zshrc這個文件,此文件是我們這個用戶登陸的時候zsh讀取的配置文件。
最后一點,我將zsh配置連接放到這里,直接使用下述命令安裝即可。
git clone https://github.com/spicycode/ze-best-zsh-config.git 目錄
如果下載下來的是壓縮包,請解壓,然后將其中的隱藏文件拷貝到家目錄下,也就是~目錄下。
最后我將我改過的.zshrc文件貼到這里,我改的文件是根據(jù)這個下載內容進行更改整合的,因為下載的東西不能夠完全使用。
之后在家目錄創(chuàng)建.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
}
# 別名部分,這部分根據(jù)自己的喜好進行甚至
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
}