资讯专栏INFORMATION COLUMN

CentOS 7 安装配置 ohmyzsh

Tecode / 2266人阅读

摘要:如果有网络代理可以直接直接使用以下命令安装。安装命令行字体,解决命令行乱码问题。在执行完上面命令之后需要注销用户重新登录或者重启电脑。终端重启之后会自动加载的配置文件。

ohmyzsh

Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes, and a few things that make you shout...

安装 ohmyzsh

# 安装必要软件
yum install -y wget curl rh-git zsh vim 

# 克隆 ohmyzsh 仓库
git clone --depth=1 https://hub.fastgit.org/ohmyzsh/ohmyzsh.git /usr/share/oh-my-zsh

# 安装 zsh 插件
git clone --depth=1 https://hub.fastgit.org/zsh-users/zsh-syntax-highlighting.git /usr/share/zsh/plugins/zsh-syntax-highlighting
git clone --depth=1 https://hub.fastgit.org/zsh-users/zsh-completions.git /usr/share/zsh/plugins/zsh-completions
git clone --depth=1 https://hub.fastgit.org/zsh-users/zsh-autosuggestions.git /usr/share/zsh/plugins/zsh-autosuggestions
git clone --depth=1 https://hub.fastgit.org/zsh-users/zsh-history-substring-search.git /usr/share/zsh/plugins/zsh-history-substring-search

# 备份 zsh 配置文件(.zshrc)
cp ~/.zshrc ~/.zshrc.bak

# 生成 zsh 配置文件(.zshrc)
cp /usr/share/oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

# 更换默认 shell
# chsh -s $(which zsh)
# echo "exec zsh" >> .bashrc
chsh -s /bin/zsh

# 解决命令行乱码问题
git clone --depth=1 https://hub.fastgit.org/powerline/fonts.git
cd fonts && bash install.sh
cd ..
rm -rf fonts

# 注销用户重新登录或者重启电脑
  1. 因为国内网络原因,导致在安装过程中访问下载 Github 资源的速度不是很理想,所以在这里选择了手动安装。如果有网络代理可以直接直接使用以下命令安装。

    MethodCommand
    curlsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    wgetsh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    fetchsh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  2. 安装命令行字体,解决命令行乱码问题。

    使用 agnoster 等主题时会出现乱码,所以需要安装命令行字体。

    推荐字体:Powerline fonts Cascadia Code 。 其中 Cascadia (Code|Mono) PL 包含 Powerline fonts

    powerline

    cascadia-code

  3. 在执行完上面命令之后需要注销用户重新登录或者重启电脑。终端重启之后会自动加载 zsh 的配置文件。

配置 ohmyzsh

下面是 我的 zsh 配置文件(.zshrc)。

# Path to your oh-my-zsh installation.
export ZSH="/usr/share/oh-my-zsh"

# Case-sensitive completion.
CASE_SENSITIVE="true"

# Disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Disable auto-setting terminal title.
DISABLE_AUTO_TITLE="true"

# Disable marking untracked files under VCS as dirty.
DISABLE_UNTRACKED_FILES_DIRTY="true"

# History.
HIST_STAMPS="yyyy-mm-dd"

# Themes
# See https://github.com/ohmyzsh/ohmyzsh/wiki
ZSH_THEME="agnoster"

# Would you like to use another custom folder than $ZSH/custom?
ZSH_CUSTOM=/usr/share/zsh
## Plugins section: Enable fish style features
# Use Auto suggestions
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# Use completions
source /usr/share/zsh/plugins/zsh-completions/zsh-completions.plugin.zsh
# Use syntax highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Use history substring search
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
# bind UP and DOWN arrow keys to history substring search
zmodload zsh/terminfo
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey ^[[A history-substring-search-up            
bindkey ^[[B history-substring-search-down

# Plugins
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
plugins=(extract git docker-compose git-flow git-hubflow git-prompt gitignore zsh-syntax-highlighting zsh-completions zsh-autosuggestions zsh-history-substring-search) 
 
source $ZSH/oh-my-zsh.sh

# Aliases.
source ~/.aliases

# Environment variables.
source ~/.exports

# Functions.
source ~/.functions

# dircolors.
if [ -x "$(command -v dircolors)" ]; then
    eval "$(dircolors -b ~/.dircolors)"
fi

# You may need to manually set your language environment
# export LANG=zh_CN.UTF-8

## Options section
setopt correct                                                  # Auto correct mistakes
setopt extendedglob                                             # Extended globbing. Allows using regular expressions with *
setopt nocaseglob                                               # Case insensitive globbing
setopt rcexpandparam                                            # Array expension with parameters
setopt nocheckjobs                                              # Dont warn about running processes when exiting
setopt numericglobsort                                          # Sort filenames numerically when it makes sense
setopt nobeep                                                   # No beep
setopt appendhistory                                            # Immediately append history instead of overwriting
setopt histignorealldups                                        # If a new command is a duplicate, remove the older one
setopt autocd  
# enable substitution for prompt
setopt prompt_subst                                                 # if only directory path is entered, cd there.

zstyle :completion:* matcher-list m:{a-zA-Z}={A-Za-z}       # Case insensitive tab completion
zstyle :completion:* list-colors "${(s.:.)LS_COLORS}"         # Colored completion (different colors for dirs/files/etc)
zstyle :completion:* rehash true                              # automatically find new executables in path 
# Speed up completions
zstyle :completion:* accept-exact *(N)
zstyle :completion:* use-cache on
zstyle :completion:* cache-path ~/.zsh/cache
HISTFILE=~/.zhistory
HISTSIZE=1000
SAVEHIST=500
#export EDITOR=/usr/bin/nano
#export VISUAL=/usr/bin/nano
WORDCHARS=${WORDCHARS///[&.;]}                                 # Dont consider certain characters part of the word

## Keybindings section
bindkey -e
bindkey ^[[7~ beginning-of-line                               # Home key
bindkey ^[[H beginning-of-line                                # Home key
if [[ "${terminfo[khome]}" != "" ]]; then
  bindkey "${terminfo[khome]}" beginning-of-line                # [Home] - Go to beginning of line
fi
bindkey ^[8~ end-of-line                                     # End key
bindkey ^[[F end-of-line                                     # End key
if [[ "${terminfo[kend]}" != "" ]]; then
  bindkey "${terminfo[kend]}" end-of-line                       # [End] - Go to end of line
fi
bindkey ^[[2~ overwrite-mode                                  # Insert key
bindkey ^[[3~ delete-char                                     # Delete key
bindkey ^[[C  forward-char                                    # Right key
bindkey ^[[D  backward-char                                   # Left key
bindkey ^[[5~ history-beginning-search-backward               # Page up key
bindkey ^[[6~ history-beginning-search-forward                # Page down key

# Navigate words with ctrl+arrow keys
bindkey ^[Oc forward-word                                     #
bindkey ^[Od backward-word                                    #
bindkey ^[[1;5D backward-word                                 #
bindkey ^[[1;5C forward-word                                  #
bindkey ^H backward-kill-word                                 # delete previous word with ctrl+backspace
bindkey ^[[Z undo     

# Theming section  
autoload -U compinit colors zcalc
compinit -d
colors

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/125974.html

相关文章

  • 打造Win10下完美Linux体验(WSL2+WindowsTerminal+oh-my-zsh),

    摘要:以管理员身份打开分别输入输入完成后重启电脑,以完成安装并更新到。将设置为默认版本在微软商店内下载分发版,这里我下载的是。且被视为管理员,能够运行管理命令。 目录 ...

    孙淑建 评论0 收藏0
  • IPFS安装与概览

    摘要:安装与概览由于我使用的实现为,所以首先要安装配置环境。六安装辅助工具和,前者是一个桌面客户端,后者是一个浏览器插件,可以在及等浏览器上安装。你可以新开一个终端使用下等功能好了,本次对的安装配置到此结束,后续会更新更多内容。 IPFS安装与概览 由于我使用的IPFS实现为go-ipfs,所以首先要安装配置Golang环境。 我使用的系统为Ubuntu18.04,后面所有操作均在此系统下完...

    leanxi 评论0 收藏0
  • Centos 7 安装Nginx-yum方式

    摘要:前言是一个高性能的和反向代理服务器,也是一个服务器。。可以发现已经安装到本机了。步骤反向代理是一个很方便的反向代理,配置反向代理可以参考。需要指出的是的,使用反向代理需要打开网络访问权限。结论本文演示了下安装,配置服务等。 前言 Nginx (engine x) 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 服务器。。 本例演示 CentOS 7 ...

    objc94 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<