Zsh 配置

Zsh

macOS 环境变量

系统

  • /etc/profile

  • /etc/bashrc

  • /etc/paths

用户

  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile
  • ~/.bashrc

加载顺序:/etc/profile-> /etc/paths-> /etc/paths.d/*-> ~/.bash_profile-> ~/.bash_login-> ~/.profile-> ~/.bashrc

  • 如果~/.bash_profile文件存在,则后面的几个文件就会被忽略不读了,如果~/.bash_profile文件不存在,才会以此类推读取后面的文件。

  • ~/.bashrc是bash shell打开的时候载入的,不受上面的规则影响。

MacOS设置环境变量path/paths的完全总结-foxwho(神秘狐)的领地

MAC之常用操作、mac上环境变量的加载顺序、_网络_代码解释生活-CSDN博客

安装Oh My Zsh

macOS

1
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

CentOS

1
yum -y install zsh && chsh -s /bin/zsh
1
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

主题

目前使用的是 ys

插件

插件管理工具

安装 zinit

1
sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma/zinit/master/doc/install.sh)"

Ignore insecure directories and continue [y] or abort compinit [n]?: https://my.oschina.net/u/215547/blog/824106

antigen、zgen、prezto、zplug

1
2
3
4
5
6
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done

zsh-syntax-highlighting

语法高亮显示

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

zsh-autosuggestions

历史命令自动补全

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

zsh-completions

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

历史命令搜索

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

zsh-apple-touchbar

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

autojump

1
brew install autojump

powerline-status

1
2
pip install powerline-status
pip show powerline-status

powerline-fonts

1
2
3
git clone https://github.com/powerline/fonts.git
./fonts/install.sh
rm -rf fonts

配置

~/.zshrc 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 插件
plugins=(
zsh-syntax-highlighting
zsh-autosuggestions
zsh-completions
zsh-history-substring-search
autojump
zsh-apple-touchbar
docker
docker-compose
)

# powerline
. /usr/local/lib/python3.6/site-packages/powerline/bindings/zsh/powerline.zsh

文件类型快捷方式

1
2
3
4
5
alias -s html='vim'

# #设置 md 文件都使用 Typora 打开
alias typora='open -a /Applications/Typora.app'
alias -s md=typora

powerline vim配置 .vimrc

1
2
3
set rtp+=/usr/local/lib/python3.6/dist-packages/powerline/bindings/vim
set laststatus=2
set t_Co=256

powerline安装参考

网站
https://github.com/wting/autojump

powerline-status

pip3 install powerline-status

pip3 show powerline-status

安装字体
git clone https://github.com/powerline/fonts.git
./fonts/install.sh
rm -rf fonts

应用配置

.zshrc

. /usr/local/lib/python3.6/site-packages/powerline/bindings/zsh/powerline.zsh

.vimrc

set rtp+=/usr/local/lib/python3.6/dist-packages/powerline/bindings/vim
set laststatus=2
set t_Co=256

Bash配置

1
2
3
4
5
vim /.bash_profile
. /usr/local/lib/python3.6/dist-packages/site-packages/powerline/bindings/bash/powerline.sh

立即生效
source ~/.bash_profile

参考

在 Mac 上将 zsh 用作默认 Shell - Apple 支持

https://github.com/powerline/powerline
https://github.com/powerline/fonts

玩oh my zsh - 山夕为岁

Cheatsheet · ohmyzsh/ohmyzsh Wiki

Coding style guide · ohmyzsh/ohmyzsh Wiki

zsh环境下如何补全docker命令 | Blog Persona

oh-my-zsh,让你的终端从未这么爽过

我就感觉到快 —— zsh 和 oh my zsh 冷启动速度优化 | Sukka’s Blog

oh-my-zsh中文乱码问题

zInit插件安装配置 - hongdada - 博客园

ZSH 插件 - 超赞合集 awesome list chinese

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. Zsh
    1. 1.1. macOS 环境变量
    2. 1.2. 安装Oh My Zsh
      1. 1.2.1. macOS
      2. 1.2.2. CentOS
    3. 1.3. 主题
    4. 1.4. 插件
      1. 1.4.1. zsh-syntax-highlighting
      2. 1.4.2. zsh-autosuggestions
      3. 1.4.3. zsh-completions
      4. 1.4.4. zsh-history-substring-search
      5. 1.4.5. zsh-apple-touchbar
      6. 1.4.6. autojump
      7. 1.4.7. powerline-status
      8. 1.4.8. powerline-fonts
    5. 1.5. 配置
      1. 1.5.1. ~/.zshrc 文件
      2. 1.5.2. 文件类型快捷方式
      3. 1.5.3. powerline vim配置 .vimrc
        1. 1.5.3.1. powerline-status
    6. 1.6. 参考
,