我正在使用WSL(传统(默认),实际上是Ubuntu 16.04),并在终端中使用Z shell(没有框架或插件管理器)作为我的shell。我当前的主题是Geometry,其中包含一个.zsh
文件及其.zsh-theme
。我在.zshrc
文件中这样使用它:
# Geometry Theme
# from https://github.com/geometry-zsh/geometry
if [[ ! -a $HOME/.zsh-plugins/geometry/geometry.zsh ]] then
git clone https://github.com/geometry-zsh/geometry $HOME/.zsh-plugins/geometry
fi
source ~/.zsh-plugins/geometry/geometry.zsh
我使用了一段时间,我想更改它。与我当前的主题不同,我选择尝试的新主题(例如iGeek,asciigit等)只有一个.zsh-theme
文件。我按照此处的说明进行操作,但是对于我尝试过的每个主题,我都会遇到此错误:
/path/to/zsh/theme.zsh-theme:8: parse error near `\n'
例如,我把iGeek的前10行:
# igeek zsh-theme
# System load
g_load=`top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk 5 '{printf "☉ System load : %.1f%", 100-$1 }'`
# Memory Usage
g_memory=`free -m | awk 'NR==2{printf "☉ Memory Usage: %.2f%", $3*100/$2 }'`
# Disk Usage
g_disk=`df -h | awk '$NF=="/"{printf "☉ Disk Usage: %.1f%", $5}'`
和asciigit:
setopt prompt_subst
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE=''
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE='<'
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE='>'
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="%{$fg[red]%}<>%{%F{14}%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED='%%'
ZSH_THEME_GIT_PROMPT_ADDED='+'
值得一提的是,我已经.zsh-theme
使用curl
WSL终端上的命令下载了文件,但没有进行任何更改。例如:
curl https://github.com/cemsbr/asciigit/blob/master/asciigit.zsh-theme --create-dirs -o ~/.zsh-plugins/asciigit/asciigit.zsh-theme
就我而言,奇怪的是,尽管不同文件中的第8行有不同之处,但它仅在第8行出错。
有什么方法可以使用此类主题而无需使用插件管理器?
@kemotep给了我提示,我找到了问题的原因。
我在curl命令中使用了错误的链接(GitHub的文件查看器页面的链接)。相反,我应该使用原始文件的链接。例如:
curl https://raw.githubusercontent.com/cemsbr/asciigit/master/asciigit.zsh-theme --create-dirs -o ~/.zsh-plugins/asciigit/asciigit.zsh-theme
然后将其添加source ~/.zsh-plugins/asciigit/asciigit.zsh-theme
到~/.zshrc
文件并执行source ~/.zshrc
将应用主题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句