brew 无法安装iterm2_Mac系统iTerm2+oh-my-zsh配置及常用插件
iTerm2,是目前Mac平臺(tái)最好用,功能最強(qiáng)大的終端軟件,可以說是Mac系統(tǒng)下終端利器。Mac系統(tǒng)默認(rèn)使用的終端為bash(MacOS Catalina開始,默認(rèn)終端已經(jīng)變成zsh);zsh被喻為“終極Shell”,讓其發(fā)揮強(qiáng)大功能設(shè)置過于復(fù)雜,而 oh-my-zsh 正是解決這一問題。本文將整理iTerm2+oh-my-zsh的配置和常用插件。
安裝iTerm2
前往官網(wǎng)下載最新版iTerm2,https://www.iterm2.com/downloads.html ,當(dāng)前版本為3.2.9,下載后是一個(gè)zip壓縮包,解壓后放到 /Applications 目錄。雙擊運(yùn)行即可。貼一段官網(wǎng)簡介:
What is iTerm2?
iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.12 or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.
安裝 oh-my-zsh
我使用wget方式安裝,在終端執(zhí)行如下代碼:
sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
注意:安裝前請(qǐng)先確認(rèn)一些必要條件。
1.zsh
Mac系統(tǒng)應(yīng)該是默認(rèn)安裝了zsh ,如果不確定,在命令執(zhí)行:cat /etc/shells 會(huì)列出系統(tǒng)中預(yù)裝的shell。出現(xiàn)如圖信息說明系統(tǒng)已經(jīng)預(yù)裝zsh,如果沒有需要安裝zsh,可以使用brew 方式(brew install zsh),或參考:https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH
安裝好zsh后,需要將系統(tǒng)默認(rèn)shell切換為zsh:
chsh -s /bin/zsh
可以通過echo $SHELL 查看當(dāng)前默認(rèn)的shell,如果默認(rèn)shell不是zsh,需要重啟iTerm2。
2.curl 或 wget
我使用curl方式安裝,在終端輸入curl --version 檢查是否安裝,如顯示“command not found”,可使用brew安裝(brew install curl)。使用wget方式同理。更多方式參考:https://github.com/robbyrussell/oh-my-zsh#basic-installation
3.git
git,用于后期 oh-my-zsh 的擴(kuò)展功能安裝,如主題或插件。在終端輸入git --version 檢查是否安裝,方法與curl相同,可以通過brew安裝(brew install git)。
oh-my-zsh 主題配置
oh-my-zsh 主題在 ~/.oh-my-zsh/themes 目錄。可通過 ls ~/.oh-my-zsh/themes 查看所有主題。每個(gè)主題具體樣式可參考:https://github.com/robbyrussell/oh-my-zsh/wiki/Themes ;主題很多,總有一款適合自己。
如果更換主題?
編輯 ~/.zshrc 文件,將 ZSH_THEME=“candy” 的 candy 換成對(duì)應(yīng)主題名字即可。
這是我自己編輯并使用的主題文件,供大家參考:
local ret_status="%(?:%{$fg_bold[green]%}? :%{$fg_bold[red]%}? )"
PROMPT='${ret_status} %{$fg[cyan]%}%~%{$reset_color%} $(git_prompt_info)# '
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
如果增加擴(kuò)展插件?
我不是終端重度用戶,所以只使用了兩個(gè)插件:
zsh-autosuggestions
zsh-syntax-highlighting
zsh-autosuggestions 安裝
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
編輯 ~/.zshrc 文件,找到 plugins=(git) ,在git后增加 zsh-autosuggestions 即可(注意git和zsh-autosuggestions之間使用空格分隔)
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相同。
總結(jié)
以上是生活随笔為你收集整理的brew 无法安装iterm2_Mac系统iTerm2+oh-my-zsh配置及常用插件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 加油1150元,跑了900公里,还剩40
- 下一篇: 大缸烤肉多少时间能熟?