OhMyZsh基础配置
1. 安装zsh
shell的终端是遭不住,还是决定换成oh-my-zsh。
1. 查看当前shell
echo $SHELL
/bin/bash
2. 安装zsh
apt install -y zsh // ubuntu或者是debain
yum install -y zsh // centos
brew install zsh // MACOSX,homebrew没有安装的去百度下咋装,这里就不展开说了 - -
3. 把zsh设置成默认shell
chsh -s /bin/zsh
4. 安装git
apt install -y git // ubuntu或者是debain
yum install -y git // centos
brew install git // MACOSX
5. 安装oh-my-zsh
1. 自动安装
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
2. 手动安装
1. 下载源码
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
2. 复制配置
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
6. 生效配置
source .zshrc
2. .zshrc配置
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="ys"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(zsh-autosuggestions zsh-syntax-highlighting git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline"
#git
alias gadd='git add'
alias gco='git checkout'
alias gm='git merge'
alias ts='tig status'
alias gb='git branch'
alias gpull='git pull --rebase'
alias gup='git pull --rebase'
alias gpush='git push origin master'
alias glo='git pull origin'
alias gso='git push origin'
alias grsh='git reset --soft HEAD\^'
alias gcm='git commit -m'
alias gs='git stash'
alias gsp='git stash pop'
alias gsas='git stash apply stash@'
alias gp='git push'
alias t='tig'
alias gsc='git stash clear'
alias mp='make push'
# go command
alias gtr='go test --run'
alias gt='go test'
alias gr='go run'
alias gg='go get -v -d -t'
#kubectl
alias k='kubectl'
alias kdp='k delete po'
alias kgp='k get po'
alias kdpa='k delete po --all'
alias kdesp='k describe po'
alias kgn='k get no'
alias klf='k logs -f'
alias ke='k exec -it'
alias kgns='k get ns'
alias kgpnd='k get po -n default'
alias kgpn='k get po -n'
alias kdp='k describe pod'
# docker
alias d='docker'
alias dpa='d ps -a'
alias di='d images'
alias dr='d rm'
alias dri='d rmi'
alias dlf='d logs -f'
alias de='d exec -it'
alias ds='d stop'
alias drm='d rm'
alias drmi='docker rmi'
这一份是我自己现在在使用的.zshrc配置,你们也可以拿去做参考,我手动安装了两个插件,用于补全的,比较好用,给大家推荐一下。
1. 安装zsh-autosuggestions
1. 下载
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
2. 在.zshrc配置
plugins=(zsh-autosuggestions) 上面给出的.zshrc已经添加
3. 带有颜色
在.zshrc中添加
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline"
2. 安装zsh-syntax-highlighting
cd ~/.oh-my-zsh/plugins && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
2. 在.zshrc配置
plugins=(zsh-syntax-highlighting)上面给出的.zshrc已经添加
stay hungry,stay foolish