linux终端配备时钟oh-my-zsh主题
?
?
?
確保先弄好代理,否則別想順利安裝:
| 安裝任務 | 指令 |
| 安裝zsh | apt install zsh |
oh-my-zsh | curl -x socks5://127.0.0.1:10808 -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc |
安裝 Bullet Train for oh-my-zsh | 安裝字體: git clone https://gitee.com/fastsource/fonts cd fonts ./install.sh 安裝好字體后必須去xfce4-Terminal中選擇字體 monofur for Powerline bold,否則樣式會出現亂碼 ? ? ? ? 下載主題: git clone?https://gitee.com/fastsource/bullet-train.zsh cp ?bullet-train.zsh/bullet-train.zsh-theme ~/.oh-my-zsh/custom/themes ? ? 設置主題: subl ~/.zshrc ZSH_THEME="bullet-train" ? 另外新開一個終端,就能生效了。 ? |
| 支持conda顯示 | 參考附錄 |
| autojump | apt-get install autojump $ source /usr/share/autojump/autojump.sh on startup |
| The Fuck | pip install thefuck |
| zsh-autosuggestions | git clone https://gitee.com/fastsource/zsh-autosuggestions cp -r zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions ~/.zshrc中修改如下 plugins=(git zsh-autosuggestions) |
| zsh-syntax-highlighting | git clone https://gitee.com/fastsource/zsh-autosuggestions/zsh-syntax-highlighting ? cp -r zsh-syntax-highlighting?$ZSH_CUSTOM/plugins/zsh-syntax-highlighting ? plugins=(git zsh-autosuggestions zsh-syntax-highlighting) |
| 設置zsh為系統默認shell | 為root用戶修改默認shell為zsh
注意,上述操作在注銷系統后,再次打開終端依然是bash,修改為zshell以后需要重啟才能生效 |
確保:
export TERM=xterm-256color
apt install?autojump
?
?
?
#----------------------------------------------------附錄(支持conda)-----------------------------------------------------------------------
①add one line in the scope of BULLETTRAIN_PROMPT_ORDER.
# Define order and content of prompt if [ ! -n "${BULLETTRAIN_PROMPT_ORDER+1}" ]; thenBULLETTRAIN_PROMPT_ORDER=(timestatuscustomcontextdirscreenperlrubyvirtualenvconda # <-- ADD nvmawsgorustelixirgithgcmd_exec_time) fi?
②add the related promot function?prompt_conda()?under?prompt_virtualenv()
prompt_virtualenv()下方加入 prompt_conda() {#if [[ ! $(conda info | awk '{print $4}' | sed -n '2p') == 'None' ]]; thenprompt_segment $BULLETTRAIN_VIRTUALENV_BG $BULLETTRAIN_VIRTUALENV_FG $BULLETTRAIN_VIRTUALENV_PREFIX" $(python --version 2>&1 | awk '{print $2}')"#fi }③make the previous conda invisiable by adding?changeps1: false?in your?~/.condarc?file
最終效果如下:
PS:
下面的代碼可以修改上面Python的顏色
# VIRTUALENV
if [ ! -n "${BULLETTRAIN_VIRTUALENV_BG+1}" ]; then
? BULLETTRAIN_VIRTUALENV_BG=red
fi
if [ ! -n "${BULLETTRAIN_VIRTUALENV_FG+1}" ]; then
? BULLETTRAIN_VIRTUALENV_FG=green
fi
if [ ! -n "${BULLETTRAIN_VIRTUALENV_PREFIX+1}" ]; then
? BULLETTRAIN_VIRTUALENV_PREFIX=🐍
fi
修改效果如下:
?
#####################################################################################
~/.zshrc最后面加入:
TMOUT=1 TRAPALRM ()? { zle reset-prompt }這樣終端上的時鐘就會動起來了。
但是有個bug([3][4]中局均有提到),就是滾動條網上拖的時候,會自動跳刀最新的命令行,非常不方便,
解決方法如下:
把終端中的Scroll on output 撤銷(不要勾選)
即可解決(根據[3]的提示來操作,[4]雖然能解決,但是無法與主題合并,只好放棄)
#####################################################################################
想時鐘面前畫一個時鐘符號:
prompt_segment $BULLETTRAIN_TIME_BG $BULLETTRAIN_TIME_FG? ? ? ?%D{%r}
改成:
prompt_segment $BULLETTRAIN_TIME_BG $BULLETTRAIN_TIME_FG "🕤"%D{%r}
效果如下:
?
?
-------------------------------------------------------------
注釋掉主題文件中的git,因為在git clone下來的文件夾中,會自動滿屏換行。如下:
https://asciinema.org/a/DOq78og1q0ZCdZW0c6RlOEDDe
-------------------------------------------------------------
補充,我們會看到每次按下回車都有一個空行顯示conda的版本,非常難受,如下:
解決方案是:
NEWLINE=' '改成
NEWLINE=''效果如下:
------------------------------------------------------------------------------------------------------------------------------------------------------------
修改后最終文件如下:
~/.oh-my-zsh/custom/themes/bullet-train.zsh-theme
-------------------------------如果需要換回bash-------------------------------------------------------------------------
apt-get --purge remove zsh
同時編輯~/.condarc
changeps1: True
auto_update_conda: True
offline: True
如果不這么做的話,終端啟動后conda前面的版本號就沒了。
?
?
Reference:
[1]Ubuntu配置zsh+oh-my-zsh+漂亮主題bullet-train
[2]anaconda virtualenv doesn't display properly
[3]Avoid terminal scroll issue when using zle reset-prompt
[4]Constantly updated clock in zsh prompt?
總結
以上是生活随笔為你收集整理的linux终端配备时钟oh-my-zsh主题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 射杀老虎和苍蝇(射杀老虎和苍蝇的案例)
- 下一篇: mysql怎么查看字段的属性值