美化後
作爲一個程序猿可以沒車,沒房,沒老婆。
但是,一定要騷。
1.首先打開終端下載 zsh
sudo apt-get install zsh
2.然後把默認的Shell改成zsh
chsh -s /bin/zsh
3.配置密碼文件,解決chsh: PAM認證失敗的問題
sudo vim /etc/passwd
4.安裝Git
sudo apt-get install git
5.安裝 oh-my-zsh
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
注意如果此卷軸不可用,可以去http://ohmyz.sh/官網
6.重啓電腦
顯示亂碼,缺少字庫
$ sudo apt-get install fonts-powerline
修改主題
配置文件是~/.zshrc
,打開編輯
命令不能識別
解決安裝完成終端 zsh: command not found
vim ~/.bash_profile
在後面添加下面一行
export PATH=/bin:/usr/bin:/usr/local/bin:"${PATH}"
終端輸入
vim ~/.zshrc
最後一行加入
source ~/.bash_profile
以後所有環境變量配置寫在這個文件
# node 環境變量
export NODE_HOME=/opt/node # Node所在路徑
export PATH=$NODE_HOME/bin:$PATH
# flutter 環境變量
export PATH=/opt/flutter/bin:$PATH
export ANDROID_HOME="/home/wukuy/android_sdk"
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
# java環境變量配置
export JAVA_HOME=/usr/opt/jdk
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=/bin:/usr/bin:/usr/local/bin:"${PATH}"
# zsh 插件
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
Linux下配置vscode終端字體:
在Ubuntu 18.04.1LTS
下的解決方案(親測可用),其他版本linux
做參考。
下載安裝字體
$cd /usr/share/fonts/truetype/
$sudo git clone https://github.com/abertsch/Menlo-for-Powerline.git
刷新字體
$sudo fc-cache -f -v
回到 Vs Code
的用戶設置.json 中加入以下代碼
"terminal.integrated.fontFamily": "Menlo for Powerline",
隱藏用戶名
1、oh_my_zsh
的主題和設置會被複制到主目錄下,只要在終端輸入
cd ~/.oh-my-zsh/themes
然後輸入
echo $ZSH_THEME
3、由於oh_my_zsh
時常會有版本更新,爲了避免我們修改的跟更新的版本有衝突,建議不要修改agnoster.zsh-theme
,而是將其拷貝出來,命名爲自己的主題文件,比如叫做myagnoster.zsh-theme
,然後只對myagnoster.zsh-theme
進行修改。
3、修改後將~/.zshrc
中的
ZSH_THEME="agnoster"
改爲
ZSH_THEME="myagnoster"
這樣就能避免衝突了。
查看自己主題,我的是agnoster
,然後輸入
vim agnoster.zsh-theme
可以看到最下面對build_prompt
的定義爲
## Main prompt
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
prompt_context
prompt_dir
prompt_git
prompt_hg
prompt_end
}
可以看出這個就是定義用戶名和域名的地方,只要把build_prompt
的定義修改爲如下:
## Main prompt
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
#prompt_context
prompt_dir
prompt_git
prompt_hg
prompt_end
}
zsh插件安裝
- zsh-autosuggestions安裝
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
編輯bash_profile
, 最後一行加入
vim ~/.bash_profile
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
- zsh-syntax-highlighting安裝
官網:https://github.com/zsh-users/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting
編輯bash_profile
, 最後一行加入
vim ~/.bash_profile
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
效果
紅色是語法高亮效果,灰色文字是提示插件效果