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"
Related
How can I change the directories colors that appears as options for the autocomplete in zsh Powerlevel10k ?
As you can see in the image they don't really stand out very well with a dark background color.
I've tried to dig in the .oh-my-zsh/custom/themes/powerlevel10k/config but to no avail.
Thanks to Roman's answer, and after finding this post (so this question might be a duplicate) I have simply:
Created a ~/.dircolors (could be any path you'd like) file and copied the standard LS colors to it by doing
dircolors --print-database > ~/.dircolors
Found the line that deal with the directories' LS color and changed it (of course you can change to any color you'd like), i.e.
DIR 01;34
To this:
DIR 01;36
Sourced the new .dircolors file in my .zshrc by adding:
d=~/.dircolors
test -r $d && eval "$(dircolors $d)"
From their official docs, https://github.com/romkatv/powerlevel10k/blob/master/README.md#directory-is-difficult-to-see-in-prompt-when-using-rainbow-style.
for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done
Execute this in your terminal to see the color code as well.
I just added the Powerlevel10k theme to my zsh and i'm trying to configure certain parts.
It currently looks like this:
The ~/.p10k.zsh has a lot of configurations done and I've been trying to change certain things but i'm not there yet.
I don't want to print the whole path on the left prompt, just the directory. Also, not sure what those numbers indicate in the git section. And the right prompt is displaying my ruby version, although I haven't used Ruby in ages and want to change it to a different setting.
I've tried adding a PS1=... to .zshrc but it seems to be overriden by the P10K config file.
Any suggestions?
Display only the last directory segment
Open ~/.p10k.zsh.
Search for POWERLEVEL9K_SHORTEN_STRATEGY.
Change the value of this parameter to truncate_to_last.
Alternatively, change the value of POWERLEVEL9K_DIR_MAX_LENGTH to 1. This will maximally shorten current directory while keeping the transformation reversible. You can restore the original directory by copy-pasting the shortened directory to the command line and pressing TAB.
Ruby version
Powerlevel10k has several prompt segments that can display Ruby version. By default only those are enabled that display Ruby version when it has been manually overridden by some tool (e.g., rbenv or asdf).
To remove Ruby version from prompt:
Open ~/.p10k.zsh.
Search for POWERLEVEL9K_RIGHT_PROMPT_SEGMENTS.
Remove or comment out the following elements: rbenv, rvm and asdf.
Alternatively (and perhaps preferably), find out which tool is overriding Ruby version for you and remove the override if you no longer need it.
shorten dir segment to show only deepest directory
To show only last n significant path segments, you can set following in your config .zshrc, e.g n=1 means show only last folder in present working directory:
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
See https://stackoverflow.com/a/49027654
explain Git symbols
The question/exclamation mark in Git segment (vcs segment, next to path) means the number of files untracked (?) and unstaged (!). For detailed description see What do different symbols in Git status mean?
change version segment
You can change the version segment (on the right of prompt) to reflect another tool. For example to replace shown ruby version by python version replace the element within right promt elements in your config .zshrc:
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(rbenv)
by
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(pyenv)
I just switched from Sublime Text to Atom in order to turn completely open source.
I have trouble with something very very simple: I want Atom to use always (!) and under any circumstances tab width 2 and replace tab with spaces. This setting is so simple in gedit or Sublime Text, but no matter what I am trying: When I start a new file, tab size is 2 (good!). When I use an existing file, tab size is sometimes 4. I find that a bit annoying.
My current setting in Editor are seen in the screenshot:
There is more than one tab setting
Each package (such as python-language) has its own tab setting(s). Whether the language uses the global default or its own default is up to whoever created the package, but you can generally override it.
In your screenshot, you have set the "Tab Type" to "soft". That will take care of using spaces rather than tabs. You have left the default tab width of 2. That is your global setting.
Now, if you look under "Packages" and search for "python" you will find a package named "language-python". Click on its settings button and you will find a number of syntax-specific settings.
Python Grammar
Python Console Grammar
Python Traceback Grammar
Regular Expressions (Python) Grammar
Each of those grammars has its own Tab Length setting. You can set them explicitly to 2 here to override the package's default. (You probably mostly care about the first one, Python Grammar.)
Python is different
In the case of Python, the package is explicitly configured to default to 4 spaces, probably because Python is very opinionated about whitespace, and PEP 8 recommends 4-space indents. You can see the default package setting here in the package's source:
https://github.com/atom/language-python/blob/master/settings/language-python.cson
'autoIndentOnPaste': false
'softTabs': true
'tabLength': 4
This overrides the global default. That's why Python Grammar does not honor the global tab width, the way that most packages do.
Sometimes there are package overrides
Additionally, certain packages will override your settings for syntax reasons. For example, language-make will override and use real tabs instead of spaces, because that is required by make.
In the case of Python, there is an override to use spaces. The language-python settings page offers a spot for you to change the indentation level, but it does not offer a way to switch to using tab characters. (That's probably justifiable, as tab characters and mixed indentation in Python are a very common cause of difficult-to-debug syntax errors.)
You might need to reload
Lastly, sometimes settings don't take effect completely until you reload the Atom window. You can use the Window: Reload command to do so. Or using the keyboard:
Mac: CtrlOptCmdL
Windows/Linux: CtrlAltR
This is what worked for me.
Disable all non-default packages
Open ~/.atom/config.cson, and append this (same level than the "*" element)
:
".python.source":
editor:
autoIndent: true
tabLength: 2
Re-enable all packages.
I got this help from someone else. Not my own discovery. However, for confidentiality, I cannot cite the source.
Based on soham's answer, I found that setting all tabLength: fields in ~/.atom/config.cson (assuming osx) to your desired length solved the problem.
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'
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