256 colors in zsh-syntax-highlighting? - zsh

OK, so I'm using this little fancy cutting edge technology called zsh-syntax-highlighting and although I'm overall happy with the result I don't know how to set styles to anything but 8 basic colors (black, red, green, yellow, blue, magenta, cyan, white), e.g.
#works
ZSH_HIGHLIGHT_STYLES[path]='fg=red'
ZSH_HIGHLIGHT_STYLES[path]='fg=1'
#doesn't work
ZSH_HIGHLIGHT_STYLES[path]='fg=31m'
ZSH_HIGHLIGHT_STYLES[path]='fg=\e[31m'
ZSH_HIGHLIGHT_STYLES[path]='fg=%{\e[31m%}'
ZSH_HIGHLIGHT_STYLES[path]='31m'
ZSH_HIGHLIGHT_STYLES[path]='\e[31m'
ZSH_HIGHLIGHT_STYLES[path]='%{\e[31m%}'
ZSH_HIGHLIGHT_STYLES[path]='%{\e[1;38;5;118m%}'
So, how do I set more fancy colors for this zshzle plugin?

As you pointed out in the comment to chepner answer terminator is a fork of gnome-terminal and it still uses a lot of functions from gnome. In fact it seems that the whole terminator VTE widget comes from gnome and gnome-terminal by defaults "supports" only 8 basic colors. You can check that with echotc Co command. It will return 8 for both of them and for xterm too (although in xterm case this is true and only 8 colors), so basically all 3 terminal emulators you tried so far.
Now, you noted that teminator (and gnome-terminal) can in fact display more colors, but this is only because it more or less processes all those special color codes without paying attention to TERM settings what does not obey standards but well, this is gnome. Anyway to make long story short you need to set TERM environment variable to something like xterm-256color and check again with echotc Co - you should now see 256, and your ZSH_HIGHLIGHT_STYLES[path]='fg=217' should work as well.
To always start with 256 colors you can put into you .zshrc
[[ "$TERM" == "xterm" ]] && export TERM=xterm-256color
and if you have any gnome shortcuts with terminator then change them as follows
terminator -e "TERM=xterm-256color pine"

http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting suggests that the value for fg be a single integer from 0 to 255:
ZSH_HIGHLIGHT_STYLES[path]='fg=167' # Whatever color 167 is in the 256-color palette.

I Notice you are using [path], it could be that a custom path with it's own color setting is interfering with your highlight setting. Try testing with a different item such as [command]:
ZSH_HIGHLIGHT_STYLES[command]='fg=222'
I tried the above line and it works for me. I tried using the same value for path already knowing my custom prompt has its own colors and my prompts custom colors won out over the highlight.
I use a ZSH helper called Oh-My-ZSH so the following may be a bit different or not apply to you:
Make sure you are changing the color definition after the highlight plugin is loaded. On my setup it will actually generate an error but since I only tested on my syetem (OSX10,9, ZSH 5.0.7, Oh-My-ZSH, iTerm v2) your experience may be different.
Doesn't work:
ZSH_HIGHLIGHT_STYLES[command]='fg=222'
...
plugins=(git osx jim colorize zsh-syntax-highlighting)
Does work:
plugins=(git osx jim colorize zsh-syntax-highlighting)
...
ZSH_HIGHLIGHT_STYLES[command]='fg=222'

Related

Testkitchen / KitchenCI - How to change console output colors?

In the present case Ansible is used with KitchenCI/Testkitchen.
Question: How can I control the color of the kitchen output?
I tried different coloroptions in ansible but for kitchen I didn't find any options, but this bugs me, especially if the color of the kitchenoutput turns darkblue suddenly.
Problem:
The color of the kitchen-output changes, depending on ...I don't know...
(It doesn't change every run, but at some time, something initiates the colorchange and then it will keep the color for a while)
Sometimes it's an ugly pink:
Sometimes it's yellow, green or cyan:
... But most annoyingly, if it's darkblue, suddenly, and I can't read stuff:
Setup: i3, xfce4-terminal, zsh, sometimes in tmux, with echo $TERM # -> screen-256color
I think, if something in the folderstructure change, or something in the current ansible environment (the shell-options are always the same), e.g. if I clone the whole directory (at least thats where I recognized it last time). It can even be a different color if I change the directory in the "roles" directory. But all in all I can't point my finger at it and I would be glad for help.
If more Information is needed, I would gladly provide it.
Update:
Maybe it's something in ~/.rvm/gems/ruby-2.5.1/gems/...
Theres a lot of code regarding "tty"
This does not answer the question (that's still interesting! because I don't want the color to change), but targets the underlying problem, meaning the non-readablitity of the blue color.
The reason was the configuration of "xfce4-terminal".
In xfce4-terminal one can define the representation for colors in the right-click: 'preferences' > 'colors' > 'Palette'
If a background-color is set, that would conflict with the color "blue" (dark blue), the representation for the color "blue" can be change (e.g. to grey, or light blue, or everything else).
See the screenshot:

How to change command-palette scroll key bindings in atom

I'm a new Atom user and I want to override the Atom command palette (shift-ctrl-p) scrolling key bindings to something more vi friendly like
ctrl-n and ctrl-p instead of the annoying arrow keys (which force me to take my hands off the home row).
Just to be clear, I don't want to change the key binding that brings up the command palette, but the key bindings you use to scroll through the list once it's up:
I can only find a binding to override the command palette toggle:
As you can see in the following config file, I was able to override the autocomplete scrolling, and I hope to do the same with the command palette. I've tried 'command-palette:up' ,'command-palette:down' and 'command-palette:move-up' etc. to no avail.
Here's is my keymap.cson.
# Atom Flight Manual:
# https://atom.io/docs/latest/using-atom-basic-customization#cson
#vt add
'body atom-text-editor.autocomplete-active':
'ctrl-p': 'autocomplete-plus:move-up'
'ctrl-n': 'autocomplete-plus:move-down'
'alt-p': 'autocomplete-plus:page-up'
'alt-n': 'autocomplete-plus:page-down'
'home': 'autocomplete-plus:move-to-top'
'end': 'autocomplete-plus:move-to-bottom'
# vim-plus ex mode 2016-04-18
'atom-text-editor.vim-mode-plus.normal-mode':
':': 'vim-mode-plus-ex-mode:open'
'!': 'vim-mode-plus-ex-mode:toggle-setting'
# add cmd palette key bindings --> These do not work.
'body .native-key-bindings':
'ctrl-p': 'command-palette:up'
'ctrl-n': 'command-palette:down'
#vt end
I've been really impressed with the key binding support in Atom thus far. I'd be really surprised if it couldn't handle this but, alas, I think this might be the case.
Does anyone know of a way to do this?
Atom 1.7.2, linux
I was able to get single line scroll to work, but not page scroll to work with the following in my keymap.cson:
'atom-workspace':
# these work
'ctrl-p' : 'core:move-up'
'ctrl-n' : 'core:move-down'
# these don't work
'alt-p' : 'core:page-up'
'alt-n' : 'core:page-down'
It would be nice to have page scroll as well, but I should be able to narrow down the list down by typing in text, so I don't foresee needing page-up, page-down all that often.
Now I'm happy.
To target keybindings for just the command palette, you can find an appropriate selector by looking in the command-palette repo keymaps: https://github.com/atom/command-palette/blob/v0.43.5/keymaps/command-palette.cson
This suggests the use of the .command-palette selector, which seems more appropriate then atom-workspace.
'.command-palette':
'ctrl-n': 'core:move-down'
'ctrl-p': 'core:move-up'
I was not able to find a mapping to scroll a page at a time within the command palette, though I'm sure someone else can figure it out. The keyboard page up/down keys have no effect so mapping to core:page-down etc. is not going to work.

Changing directory color with zsh + Prezto

I am using Prezto + zsh as my shell. I would like to change the color of
directories when I ls my directory. For instance, here is what I currently
have:
Obviously, this is no fun, as I’m hardly able to read my directories because the
blue is so dark. I’d like to change it to white or orange or something lighter.
This dark blue is specific only to directories. Files show up in a nice white
text. Where and what settings must I find to change this?
Update
I've seen this answer still getting attention, so here's an update. Instead of messing with individual colours as below, simply adjust the Minimum Contrast within Preferences ... -> Profiles -> Colors. I set mine to 60.
Original answer
The easier way to do this is to change the colour scheme of your terminal. For example if you are using iTerm2 on a Mac then:
Launch iTerm2
type CMD+i
In the "Colors" tab, change the setting for "Blue" (and potentially the "Bright" equivalient)
In the "General" tab, click "Copy Current Settings to Selected Profile"
If you want to revert back to the defaults you can always select a value from the "Color presets..." dropdown in the "Colors" tab.
Do the equivalent in your favourite terminal if you don't use iTerm2 on a Mac.
The answer depends on your ls. BSD ls uses the environment variable LSCOLORS; coreutils ls uses LS_COLORS instead. See your man page.
The utility module of Prezto uses dircolors (if available) to customize the colors of coreutils ls, which also comes with coreutils. So if you have coreutils, then you can use dircolors to provide actually human-readable color definitions. Read the man page of dircolors for details. Prezto reads from $HOME/.dir_colors by default, otherwise it just use the default colors defined by dircolors. You can of course specify other locations by editing on top of Prezto.
For BSD ls, there's probably no utility comparable to dircolors, so one has to manually define LSCOLORS. See the ENVIRONMENT section of the man page on its format, which should be pretty clear. An example is LSCOLORS='exfxcxdxbxGxDxabagacad', used by Prezto by default. To have it take effect, put it in runcoms, after loading Prezto's utility module.
I may be late to the party but I found the answer here: https://github.com/sorin-ionescu/prezto/issues/1539
Run in the Terminal or add to your .zshrc file
export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"

What is %K %F in oh my zsh theme?

I wanna custom my zsh theme ,but i don't known what does the %F and %K mean
such like
RPROMPT="$POWERLINE_GIT_INFO_RIGHT%F{white}"$'\ue0b2'"%k%F{black}%K{white} $POWERLINE_RIGHT_B %f%F{240}"$'\ue0b2'"%f%k%K{240}%F{255} $POWERLINE_RIGHT_A %f%k"
And i don't understand what is the %f%k 。。
Do you have any documentiions about how to custom oh my zsh theme ?
The ZSH documentation is very good. Learn to use the man pages: specifically, man zshmisc. You want the section on SIMPLE PROMPT ESCAPES:
%F (%f)
Start (stop) using a different foreground colour, if supported
by the terminal. The colour may be specified two ways: either
as a numeric argument, as normal, or by a sequence in braces
following the %F, for example %F{red}. In the latter case the
values allowed are as described for the fg zle_highlight
attribute; see Character Highlighting in zshzle(1). This means
that numeric colours are allowed in the second format also.
%K (%k)
Start (stop) using a different bacKground colour. The syntax is
identical to that for %F and %f.
You've asked:
Do you have any documentation about how to custom oh my zsh theme ?
There are lots of example themes bundled with oh-my-zsh. Look in the themes directory. Look at the forks on github. Read related zsh questions, or this one, or this one.
For my prompt, I borrowed a lot from this.
And, as always, read the man pages, or the zsh users guide.

vim syntax highlighting

How can I change the syntax highlighting in vim for C/C++/PHP in particular?
Can I also change the background color so it won't be the same as the shell's?
Before you start installing various plugins, check out pre-installed color schemes that ships with your Vim. In my case I have many of them:
# rpm -ql vim vim-common | grep color
/usr/share/vim/vim72/colors
/usr/share/vim/vim72/colors/README.txt
/usr/share/vim/vim72/colors/blue.vim
/usr/share/vim/vim72/colors/darkblue.vim
/usr/share/vim/vim72/colors/default.vim
/usr/share/vim/vim72/colors/delek.vim
/usr/share/vim/vim72/colors/desert.vim
/usr/share/vim/vim72/colors/elflord.vim
/usr/share/vim/vim72/colors/evening.vim
/usr/share/vim/vim72/colors/koehler.vim
/usr/share/vim/vim72/colors/morning.vim
/usr/share/vim/vim72/colors/murphy.vim
/usr/share/vim/vim72/colors/pablo.vim
/usr/share/vim/vim72/colors/peachpuff.vim
/usr/share/vim/vim72/colors/ron.vim
/usr/share/vim/vim72/colors/shine.vim
/usr/share/vim/vim72/colors/slate.vim
/usr/share/vim/vim72/colors/torte.vim
/usr/share/vim/vim72/colors/zellner.vim
/usr/share/vim/vim72/ftplugin/dircolors.vim
/usr/share/vim/vim72/syntax/colortest.vim
/usr/share/vim/vim72/syntax/dircolors.vim
/usr/share/vim/vim72/syntax/syncolor.vim
/usr/share/vim/vimfiles/after/colors
/usr/share/vim/vimfiles/colors
To change it just use this:
colorscheme darkblue
Also you can download color schemes and just drop them into your VIMRC subdirectory "colors" and load them the same way. I like this one for example: http://ethanschoonover.com/solarized
And of course, you can modify those color schemes. Just copy the "default.vim" (or the one you like) to your VIMRC/colors and edit it to change colors you want.
You have to give it a syntax file to load and play around with it:
http://www.vim.org/scripts/script.php?script_id=1571
To enable it (in case you don't know) its :set syntax
For info on changing vim's background check here:
Setting the VIM background colors

Resources