Mac os 开发终端美化教程基础
一、设置代理
(如果你在🇨🇳的话,或者你可以使用github加速替换下代码里面的地址)
二、安装homebrew
查看官网教程
其实官方也就是一段脚本:
install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Uninstall
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
三、安装oh my zsh
github教程
curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fetch
sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
卸载oh-my-zsh
uninstall_oh_my_zsh
四、安装字体
nerd-fonts
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
设置完成记得在终端配置下字体,配置完成后重启即可 使用漂亮的NERD字体啦。
字体名字应该是 Hack Nerd Font Mono
powerline字体,另外一种选择
五、安装powerlevel10k
powerlevel10k 很漂亮的一个zsh主题
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
powerlevel10k 配置教程:
#配置 ~/.zshrc下
#使主题生效 然后可参考我的配置代码
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL10k_MODE='nerdfont-complete'
##
POWERLEVEL10k_PROMPT_ON_NEWLINE=true
POWERLEVEL10k_LEFT_SEGMENT_SEPARATOR=''
POWERLEVEL10k_LEFT_SUBSEGMENT_SEPARATOR=''
POWERLEVEL10k_LEFT_PROMPT_ELEMENTS=(root_indicator dir dir_writable_joined)
POWERLEVEL10k_MULTILINE_FIRST_PROMPT_PREFIX="%F{045}\u256D\u2500%F{white}"
# POWERLEVEL10k_MULTILINE_LAST_PROMPT_PREFIX="%F{045}\u2570\uf460%F{white} "
POWERLEVEL10k_MULTILINE_LAST_PROMPT_PREFIX="%F{045}\u2570%F{cyan}\uF460%F{073}\uF460%F{109}\uF460%f "
# dir
POWERLEVEL10k_SHORTEN_DELIMITER=''
POWERLEVEL10k_SHORTEN_DIR_LENGTH=7
POWERLEVEL10k_SHORTEN_STRATEGY='truncate_to_first_and_last'
# Home Root
POWERLEVEL10k_DIR_HOME_BACKGROUND='none'
POWERLEVEL10k_DIR_HOME_FOREGROUND='045'
# Root sub dir
POWERLEVEL10k_DIR_HOME_SUBFOLDER_BACKGROUND='none'
POWERLEVEL10k_DIR_HOME_SUBFOLDER_FOREGROUND='045'
# user dir
POWERLEVEL10k_DIR_DEFAULT_BACKGROUND='none'
POWERLEVEL10k_DIR_DEFAULT_FOREGROUND='005'
# ect dir
POWERLEVEL10k_DIR_ETC_BACKGROUND='none'
POWERLEVEL10k_DIR_ETC_FOREGROUND='005'
# 禁止编辑
POWERLEVEL10k_DIR_WRITABLE_FORBIDDEN_BACKGROUND="none"
POWERLEVEL10k_DIR_WRITABLE_FORBIDDEN_FOREGROUND="red"
# RIGHT_PROMP
# ===========================================================
POWERLEVEL10k_RIGHT_PROMPT_ELEMENTS=(status command_execution_time vcs background_jobs_joined battery time_joined)
POWERLEVEL10k_RIGHT_SEGMENT_SEPARATOR=''
POWERLEVEL10k_RIGHT_SUBSEGMENT_SEPARATOR=''
# change
POWERLEVEL10k_VCS_MODIFIED_BACKGROUND='none'
POWERLEVEL10k_VCS_MODIFIED_FOREGROUND='003'
POWERLEVEL10k_VCS_CLEAN_BACKGROUND='none'
POWERLEVEL10k_VCS_CLEAN_FOREGROUND='045'
POWERLEVEL10k_VCS_UNTRACKED_BACKGROUND='none'
POWERLEVEL10k_VCS_UNTRACKED_FOREGROUND='005'
# INDICATOR
POWERLEVEL10k_ROOT_INDICATOR_BACKGROUND="none"
POWERLEVEL10k_ROOT_INDICATOR_FOREGROUND="white"
POWERLEVEL10k_STATUS_OK_BACKGROUND="none"
POWERLEVEL10k_STATUS_OK_FOREGROUND="green"
POWERLEVEL10k_STATUS_ERROR_BACKGROUND="none"
POWERLEVEL10k_STATUS_ERROR_FOREGROUND="red"
# TIME
# POWERLEVEL10k_TIME_FORMAT="%D{%Y-%m-%d,%H:%M:%S}"
POWERLEVEL10k_TIME_ICON=''
POWERLEVEL10k_TIME_FORMAT="%D{%H:%M \uf017 %d.%m \uf073}"
POWERLEVEL10k_TIME_BACKGROUND="none"
POWERLEVEL10k_TIME_FOREGROUND="cyan"
# battery 电池
POWERLEVEL10k_BATTERY_LOW_BACKGROUND='none'
POWERLEVEL10k_BATTERY_LOW_FOREGROUND='001'
POWERLEVEL10k_BATTERY_CHARGING_BACKGROUND='none'
POWERLEVEL10k_BATTERY_CHARGING_FOREGROUND='076'
POWERLEVEL10k_BATTERY_CHARGED_BACKGROUND='none'
POWERLEVEL10k_BATTERY_CHARGED_FOREGROUND='076'
POWERLEVEL10k_BATTERY_DISCONNECTED_BACKGROUND='none'
POWERLEVEL10k_BATTERY_DISCONNECTED_FOREGROUND='003'
POWERLEVEL10k_BATTERY_LOW_THRESHOLD=15
POWERLEVEL10k_BATTERY_VERBOSE=false
# POWERLEVEL10k_BATTERY_STAGES=''
POWERLEVEL10k_COMMAND_EXECUTION_TIME_BACKGROUND='none'
POWERLEVEL10k_COMMAND_EXECUTION_TIME_FOREGROUND='magenta'
POWERLEVEL10k_BACKGROUND_JOBS_BACKGROUND='none'
POWERLEVEL10k_BACKGROUND_JOBS_FOREGROUND='green'
六、安装oh-my-zsh用插件
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
zsh-history-substring-search:这个是记住执行过的命令的,使用上下键可以方便的再次执行指定的命令
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
安装完插件后,编辑.zshrc文件,把插件都添加到文件中去:
具体
#需要配置下 ~/.zshrc文件里面放能使得以上插件生效
#代码地址
plugins=(git
zsh-syntax-highlighting
zsh-autosuggestions
zsh-history-substring-search)
#保存 退出,重开zsh 或者
source $ZSH/oh-my-zsh.sh
七、安装exa
可以让终端文字多彩,方便突出重点。
exa is a modern replacement for ls.
install
brew install exa
配置exa
#使用nano 编辑 当前用户下的.zshrc 添加exa支持
nano ~/.zshrc
alias l ='exa -l'
alias la ='exa -la'