zsh原创
# install
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
国内无法安装这个的。使用
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
然后给 install.sh
添加权限:
chmod +x install.sh
然后执行 install.sh :
./install.sh
如果发现很慢,可以修改为 gitee
:
vim install.sh
进入编辑状态:
找到以下部分:
# Default settings
ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}
然后将中间两行改为:
REPO=${REPO:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
# 修改配置
vim ~/.zshrc
# 插件
先进插件目录
cd ~/.oh-my-zsh/custom/plugins/
# zsh-syntax-highlighting
高亮提示。
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# zsh-autosuggestions
会给出建议的命令(灰色部分)按键盘 → 补全。
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 字体
某些主题需要 Powerline fonts
字体依赖
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
./uninstall.sh
rm -rf fonts
# alias
git (opens new window)
常用 alias
:
alias | command | effect |
---|---|---|
g | git | |
grv | git remote -v | |
gra | git remote add | |
gst | git status | 查看状态 |
gl | git pull | 拉取 |
gp | git push | 推送 |
gpf! | git push --force | 强制推送 |
gm | git merge | 先切换master分支,然后把xxx分支导入到master分支。 |
gcmsg | git commit -m | |
ga | git add | |
gaa | git add --all | |
gb | git branch | 不加后续名称时查看分支情况;后续名称时,创建分支 |
gco | git checkout | 切换分支 |
git checkout -b | 创建分支并进行切换 | |
gbd | git branch -d | 删除分支 |
glg | git log --stat | 查看提交日志 |
git revert | 取消 commit ,传入 HEAD,log中还能看到信息 | |
git reset | 删除commit ,传入 HEAD,log中不能看到信息 |
# 主题
Oh My Zsh
默认自带了一些默认主题,存放在 ~/.oh-my-zsh/themes
目录中。
我们可以命令 cd ~/.oh-my-zsh/themes && ls
查看这些主题。
推荐使用 powerlevel10k
主题。
powerlevel10k
安装:
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
配置powerlevel10k
p10k configure
必须下载对应的字体 (opens new window),使用 brew
安装!!!
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
同时需要设置 terminal
-> 文本 -> 字体,为 Hack Nerd Font
# 卸载
cd .oh-my-zsh/tools
chmod +x uninstall.sh
./uninstall.sh
rm -rif .zshrc
# 显示系统配置
archey (opens new window)
黑果小兵 archey (opens new window),我用的是这个。
$ git clone https://github.com/athlonreg/archey-osx
$ sudo mv archey-osx/ /usr/local/
$ sudo ln -s /usr/local/archey-osx/bin/archey /usr/local/bin/archey #中文版 软连接
$ sudo ln -s /usr/local/archey-osx/bin/archey-en /usr/local/bin/archey-en #英文版 软连接
# 设置打开终端自启动
$ echo archey >> ~/.bashrc #中文版
$ echo archey-en >> ~/.bashrc #英文版
$ echo "[[ -s ~/.bashrc ]] && source ~/.bashrc" >> ~/.bash_profile
$ source ~/.bashrc && source ~/.bash_profile
# oh-my-zsh
$ echo archey >> ~/.zshrc #中文版
$ echo archey-en >> ~/.zshrc #英文版
$ source ~/.zshrc
# Update/更新
cd /usr/local/archey-osx/ && git pull
# 报错
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x 3 carveybunt admin 96 8 15 00:18 /usr/local/share/zsh
drwxrwxr-x 4 carveybunt admin 128 8 15 00:31 /usr/local/share/zsh/site-functions
[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.
[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh] compaudit | xargs chmod g-w,o-w
[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.
修改 ~/.zshrc 添加:
ZSH_DISABLE_COMPFIX="true"
上次更新: 2022/08/23, 18:12:45