2022-01-10 Oh My Zsh插件和配置:

1. Oh My Zsh是什么

Oh My Zsh是一个开源的、社区驱动的框架,用于管理zsh 配置。让天下没有难用的终端(Terminal), 终端terminal神器.

适用于Mac Linux平台.

2. Oh My Zsh安装, Oh My Zsh官网

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

3. Oh My Zsh插件, Git zsh-autosuggestions fasd zsh-syntax-highlighting 让终端起飞.

3.1 Git插件, Oh My Zsh自带, 把所有的git命令做了别名, 更快使用git命令.

在~/.zshrc中启用

plugins=(git)

# 终端内
# gb 等于 git branch
# st 等价git status
# gcmsg 等于 git commit -m
# gm 等于git merge
# gco 等于git checkout

全部别名地址

3.2 zsh-autosuggestions 显示之前运行的命令, 按即可补全.

3.2.1 安装zsh-autosuggestions

zsh-autosuggestions安装官网

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

3.2.2 在~/.zshrc中启用

plugins=(git zsh-autosuggestions)

3.2.3 重新生效

sourch ~/.zshrc

3.2.4 效果展示, Control + e即可补全

效果

3.3 fasd时空机, 可以跳到任何之前去过的目录, 再也不必cd来cd去了, 可以和更多的命令连用.

fasd可以记录访问目录的权重, 常访问目录权重高, 匹配放在前面.

3.3.1 安装fasd

brew install fasd

3.3.2 初始化到~/.zshrc中, j用作fasd的别名

# 插件增加fasd
plugins=(git zsh-autosuggestions fasd)
eval "$(fasd --init auto)"
alias j='fasd_cd -d'

3.3.3 重新生效~/.zshrc

source ~/.zshrc

3.3.4 使用效果, 直接回车就可跳转, 也可使用tab依权重选择

fasd

目录关键词也能识别出来

fasd-folder

3.3.5 和其他命令连用,和vim连用,vim可以在任何目录打开之前编辑过的文件

alias v='jf -e vim'
alias py3f="jf -e python3"
# 写入.zshrc中
# source ~/.zshrc生效

vim fasd

3.3.6 更多别名, 存入.zshrc中

alias jan='fasd -a'        # any
alias js='fasd -si'       # show / search / select
alias jd='fasd -d'        # directory
alias jf='fasd -f'        # file
alias jsd='fasd -sid'     # interactive directory selection
alias jsf='fasd -sif'     # interactive file selection
alias j='fasd_cd -d'     # cd, same functionality as j in autojump
alias jz='fasd_cd -d -i' # cd with interactive selection
alias jdd='fasd -D' # 删除一个路径

alias v='jf -e vim'
alias nv='jf -e nvim'
alias batf='jf -e bat'
alias catf='jf -e cat'
alias py3f="jf -e python3"
alias lsf="jd -e ls"
alias shf='jf -e sh'
alias commandf='jf -e command'

3.4 zsh-syntax-highlighting高亮显示正确的命令.

3.4.1 安装zsh-syntax-highlighting

zsh-syntax-highlighting官网地址

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

3.4.2 在~/.zshrc中启用

plugins=(git fasd zsh-autosuggestions  zsh-syntax-highlighting)

3.4.3 source ~/.zshrc 生效

source ~/.zshrc

3.4.4 使用效果, 演示

zsh-syntax-highlighting

4. Oh My Zsh 主题

主题截图演示地址

# 主题都存放在这个目录下
ls ~/.oh-my-zsh/themes/

# 在.zshrc中, 选择喜欢的主题就行.
ZSH_THEME="robbyrussell"

# 重新生效, 就能看到效果了
source ~/.zshrc

你可能感兴趣的:(2022-01-10 Oh My Zsh插件和配置:)