1

I'm using WSL (Legacy (Default) which actually is Ubuntu 16.04) and I use Z shell (with no framework or plugin manager) as my shell in the terminal. My current theme is Geometry which contains a .zsh file alongside with its .zsh-theme. I use it like this in my .zshrc file:

# 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

I'm using it for a while and I want to change it. New themes I selected to try (e.g. iGeek, asciigit, etc.), unlike my current theme, only have a .zsh-theme file. I followed instructions on here, but for every theme I tried, I face this error:

/path/to/zsh/theme.zsh-theme:8: parse error near `\n'

For example, I put the first 10 lines of iGeek:

# 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}'`

and 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='+'

Worth noting that I've downloaded .zsh-theme files using curl command from WSL's terminal and did no change to them. For example:

curl https://github.com/cemsbr/asciigit/blob/master/asciigit.zsh-theme --create-dirs -o ~/.zsh-plugins/asciigit/asciigit.zsh-theme

The odd thing is, as far as I tried, it only errors on line 8 though there are different things on line 8 in different files.

Is there any way to use such themes without the need to use a plugin manager?

  • Welcome to the Unix and Linux stack exchange site! Please review the [Help Center](https:unix.stackexchange.com/help) for more information on how to best post to this site. To get to your question. Could you please edit your post to include more information. What does /path/to/zsh/theme.zsh-theme line 8 look like? A quick search into zsh errors I found that you could get this type of error if a function is not closed properly. Line 8 is your clue. – kemotep Aug 8 '19 at 13:53
  • @kemotep I've put a link to iGeek and asciigit for this purpose. In the iGeek like 8 is empty and in the asciigit it's an environment variable being assigned. I'll update the question with their code snippet. – TheSETJ Aug 8 '19 at 15:19
  • We prefer if people put all relevant details in the post and avoid only linking to 3rd party sites or posting screenshots as the information is harder to work with and sites can change or go dark. If that were to happen your post would have a mismatch of information and be harder to work with if people were to come across it years later. – kemotep Aug 8 '19 at 21:17
  • 1
    You need that Windows 10 version 1903 to even install WSL 2. If you do not have 1903, then you have the first version of WSL. I suspect based on your comment that you have WSL 1. From what I have found you should be able to change themes as simply as following this advice The line ending error means that you need to make sure that all your linux files have linux file endings. Try to use dos2unix or some other program to convert them. – kemotep Aug 9 '19 at 21:49
  • 1
    Thank you for coming back and posting the solution! – kemotep Aug 10 '19 at 18:20
1

I found the cause of the issue thanks to the hint @kemotep gave me.

I was using the wrong link with the curl command (link of the GitHub's file viewer page). Instead, I should use the link of the raw file. For example:

curl https://raw.githubusercontent.com/cemsbr/asciigit/master/asciigit.zsh-theme --create-dirs -o ~/.zsh-plugins/asciigit/asciigit.zsh-theme

And then adding source ~/.zsh-plugins/asciigit/asciigit.zsh-theme to the ~/.zshrc file and doing a source ~/.zshrc will apply the theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.