Mac下OH MY ZSH的安裝及配置

1.下載oh my zsh:

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

2.下載iTerm2:

https://www.iterm2.com

3.安裝powerline字體:

# clone

git clone https://github.com/powerline/fonts.git --depth=1

# install

cd fonts

./install.sh

# clean-up a bit

cd ..

rm -rf fonts

在iterm2里面修改字體和背景色:



4.改bas為zsh:

chsh -s /bin/zsh

5.安裝插件:

a.zsh-autosuggestions:

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

b.zsh-syntax-highlighting:

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

c.powerlevel9k

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

修改.zshrc:

ZSH_THEME="powerlevel9k/powerlevel9k"


6.修改.zshrc文件:



7.source ~/.zshrc


8.powerlevel9k主題的設(shè)置:


上面的字體選擇有三種:

1.nerdfont-complete

2.awesome-fontconfig

3.awesome-patched

配置:

# 左側(cè)欄目顯示的要素(指定的關(guān)鍵字參考官網(wǎng))

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon context dir vcs)

# 顯示python虛擬壞境

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history virtualenv custom_wifi_signal disk_usage)

# 自定義wifi

POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"

POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="white"

POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="black"

zsh_wifi_signal(){

? ? ? ? local output=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I)

? ? ? ? local airport=$(echo $output | grep 'AirPort' | awk -F': ' '{print $2}')

? ? ? ? if [ "$airport" = "Off" ]; then

? ? ? ? ? ? ? ? local color='%F{black}'

? ? ? ? ? ? ? ? echo -n "%{$color%}Wifi Off"

? ? ? ? else

? ? ? ? ? ? ? ? local ssid=$(echo $output | grep ' SSID' | awk -F': ' '{print $2}')

? ? ? ? ? ? ? ? local speed=$(echo $output | grep 'lastTxRate' | awk -F': ' '{print $2}')

? ? ? ? ? ? ? ? local color='%F{black}'

? ? ? ? ? ? ? ? [[ $speed -gt 100 ]] && color='%F{black}'

? ? ? ? ? ? ? ? [[ $speed -lt 50 ]] && color='%F{red}'

? ? ? ? ? ? ? ? echo -n "%{$color%}$speed Mbps \uf1eb%{%f%}" # removed char not in my PowerLine font

? ? ? ? fi

}

#添加連接上下連接箭頭更方便查看

POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{014}╭%F{cyan}"

POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{014}\u2570%F{cyan}\uF460%F{073}\uF460%F{109}\uF460%f"

#新起一行顯示命令 (推薦!極其方便)

POWERLEVEL9K_PROMPT_ON_NEWLINE=true

#右側(cè)狀態(tài)欄與命令在同一行

POWERLEVEL9K_RPROMPT_ON_NEWLINE=true

#字體設(shè)定 (注意,字體設(shè)定必須放在主題之前)

POWERLEVEL9K_MODE='nerdfont-complete'

ZSH_THEME="powerlevel9k/powerlevel9k"

DEFAULT_USER='rey'

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容