Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does spectrum_ls() work? #3964

Closed
apjanke opened this issue Jun 8, 2015 · 1 comment · Fixed by #3966
Closed

Does spectrum_ls() work? #3964

apjanke opened this issue Jun 8, 2015 · 1 comment · Fixed by #3966

Comments

@apjanke
Copy link
Contributor

apjanke commented Jun 8, 2015

I've been looking at lib/spectrum.zsh since I've been working on prompt color stuff lately.

Does the spectrum_ls() function work? It says it displays all 256 colors, but when I run it, only the first 8 or so lines are colored, and the rest are in the default color. This happens on OS X 10.9, Windows 7, and Debian 7.

screen shot 2015-06-08 at 6 38 56 am

Here's the implementation.

# Show all 256 colors with color number
function spectrum_ls() {
  for code in {000..255}; do
    print -P -- "$code: %F{$code}$ZSH_SPECTRUM_TEXT%f"
  done
}

Instead of using the ${FG[n]} control sequences it defined itself, it's using zsh's %F...%f prompt color controls. I don't think those support 256-color numeric codes; only the basic ANSI colors.

If I rewrite it using the control sequences instead of prompt color controls, then all 256 colors are shown as being colored.

# Show all 256 colors with color number
function spectrum_ls2() {
  for code in {000..255}; do
    print -P "$code: ${FG[$code]}$ZSH_SPECTRUM_TEXT${FX[reset]}"
  done
}

screen shot 2015-06-08 at 6 46 04 am

Am I missing something here?

@apjanke
Copy link
Contributor Author

apjanke commented Jun 8, 2015

Turns out this was due to user error. I had my terminal misconfigured. $TERM was set to xterm instead of xterm-256color. Switching it to xterm-256color made the current implementation of spectrum_ls work.

I couldn't find anywhere in the Zsh reference manual that discusses 256 color support, and the doco for %F/%f talks about following it with a single ASCII digit. But maybe the documentation is just out of date.

@apjanke apjanke closed this as completed Jun 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant