You are not logged in.
Pages: 1
I have a lot of questions about coloring zsh. I've read a LOT about coloring zsh and simply can't grasp some of the concepts. Here is my current ~/.zshrc:
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd
unsetopt extendedglob
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/clarence/.zshrc'
autoload -U colors && colors
autoload -U promptinit
autoload -Uz compinit
compinit
# End of lines added by compinstall
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
PROMPT="%{$fg[white]%}[%{$fg[blue]%}%n%{$fg[white]%}@%{$fg[white]%}%m %{$fg[white]%}%1~]$ "Here is my goal: To be able to look at my ~/.zshrc and know exactly what all of it means and be able to manipulate it into using the 256-colors that I want.
I would like to be able to use a brighter blue for my name and some light/darker greys for some of the other parts but it seems I'm limited to simple colors and not 256-colors. From what I understand the "autoload -U colors && colors" section of my ~/.zshrc has something to do with the colors I am able to use. I would like to know how to be able to use colors like light blue and grey.
Another issue is that when I use nano on zsh the text is black and that doesn't work out very well since I have a black background :S I have the same problem with reading man pages. I would like to know how to change the colors for that text too.
If anyone can translate my ~/.zshrc and walk me through the steps of complete customization, I would be very thankful. Oh, I'm using urxvt too if that is of any count. Thanks in advance!
Edit: Removed the big picture.
Last edited by Clarence.e.a (2012-04-28 20:58:27)
Offline
The actual colors that you view on these screenshots are not configured by zsh, but by your terminal emulator. The shell only sends keycodes for a special color (e.g. 'blue') to the terminal emulator, which renders it to a 'real' color, e.g. '#0000AA'.
I don't think that there is direct support for 256 colors in zsh. If you just want a brighter version of a color, use the bold attribute (%B/%b in prompt expansion).
If you really need 256 colors, you'll have to use escape codes that only work for xterm (and any application that emulates it), which I don't advise you to use in case you have to work on the linux console sometime.
The problems with nano and man should not be the fault of zsh. It seems to be a problem with your terminal emulator. Which one do you use?
EDIT: Oh, didn't see the urxvt comment at the end.
Urxvt manages colors in .Xresources, you can specify the default foreground and background colors as well as the usual 16 colors.
See the wiki page for more information
BTW, some mod is probably going to remove your screenshot because it is to big (https://bbs.archlinux.org/viewtopic.php?id=61754).
Last edited by guelfi (2012-04-28 19:48:16)
Offline
The script is one of many that just prints combinations of colors... I've no idea who the original author is, but I've simplified it significantly since I found it.
#!/bin/bash
t='gYw'
printf ' '
printf '%8s' {40..47}m
printf '\n'
fg_colors=({,1}m)
for n in {30..37}m; do
fg_colors+=({,1\;}"$n")
done
for fgc in "${fg_colors[@]}"; do
printf " %5s \033[%s $t " "$fgc" "$fgc"
for bgc in {40..47}m; do
printf " \033[%s\033[%s $t \033[0m" "$fgc" "$bgc"
done
printf '\n'
doneOffline
Okay, I've read the wiki for urxvt and here is my ~/.Xresources file with colors added:
!~/.Xresources
!
!{{{ URXVT
!
! General
urxvt*termName: rxvt-unicode-256color
!urxvt*loginShell: true
urxvt*scrollBar: false
!urxvt*secondaryScroll: true
!urxvt*saveLines: 65535
urxvt*cursorBlink: true
!urxvt*cursorUnderline: true
!urxvt*urgentOnBell: true
!urxvt*override-redirect:false
!urxvt*borderLess: false
!urxvt*internalBorder: 0
!urxvt*externalBorder: 0
!
! Extensions
!urxvt*perl-lib: /usr/lib/urxvt/perl/
!urxvt*perl-ext-common: default,matcher,searchable-scrollback
!urxvt*urlLauncher: /usr/local/bin/firefox
!urxvt*matcher.button: 1
! Catch ugly URLs
!urxvt*cutchars: '"'()*<>[]{|}
!
! Appearance
!urxvt*font: -xos4-terminus-medium-*-*-*-12-*-*-*-*-*-iso8859-2
!urxvt*boldFont: -xos4-terminus-bold-*-*-*-12-*-*-*-*-*-iso8859-2
!
! Cursor
urxvt*cursorColor: White
! URLs
!urxvt*.colorUL: Blue
!
! Pseudo Transparency
!urxvt*shading: 50
!urxvt*transparent:true
!
!Real Transparency
URxvt.depth: 32
URxvt.background: rgba:1111/1111/1111/dddd
!
!Colors
color0 (black) = Black
color1 (red) = Red3
color2 (green) = Green3
color3 (yellow) = Yellow3
color4 (blue) = Blue3
color5 (magenta) = Magenta3
color6 (cyan) = Cyan3
color7 (white) = AntiqueWhite
color8 (bright black) = Grey25
color9 (bright red) = Red
color10 (bright green) = Green
color11 (bright yellow) = Yellow
color12 (bright blue) = Blue
color13 (bright magenta)= Magenta
color14 (bright cyan) = Cyan
color15 (bright white) = White
foreground = Black
background = White
!
!}}}So if I want bright blue as my name on the terminal I would use this in my ~/.zshrc:
alias ls='ls --color=auto'
PROMPT="%{$fg[white]%}[%{$fg[bright blue]%}%n%{$fg[white]%}@%{$fg[white]%}%m %{$fg[white]%}%1~]$ "And if I wanted normal blue I would use this in my ~/.zshrc:
alias ls='ls --color=auto'
PROMPT="%{$fg[white]%}[%{$fg[blue]%}%n%{$fg[white]%}@%{$fg[white]%}%m %{$fg[white]%}%1~]$ "How do I specify the foreground/background colors for nano and man pages in the ~/.Xresources file?
And I just copied the image from another post as an example, theirs didn't get removed so I suppose mine shouldn't either.
Offline
And I just copied the image from another post as an example, theirs didn't get removed so I suppose mine shouldn't either.
You are mistaken. Please read the Forum Etiquette.
It wouldn't hurt if you also spent some time reading the rest of the wiki either...
Offline
I tried the new ~/.Xresources and it kept giving me an error that said something about colons, so here is my new ~/.Xresources file with colons in the Colors section:
!~/.Xresources
!
!{{{ URXVT
!
! General
urxvt*termName: rxvt-unicode-256color
!urxvt*loginShell: true
urxvt*scrollBar: false
!urxvt*secondaryScroll: true
!urxvt*saveLines: 65535
urxvt*cursorBlink: true
!urxvt*cursorUnderline: true
!urxvt*urgentOnBell: true
!urxvt*override-redirect:false
!urxvt*borderLess: false
!urxvt*internalBorder: 0
!urxvt*externalBorder: 0
!
! Extensions
!urxvt*perl-lib: /usr/lib/urxvt/perl/
!urxvt*perl-ext-common: default,matcher,searchable-scrollback
!urxvt*urlLauncher: /usr/local/bin/firefox
!urxvt*matcher.button: 1
! Catch ugly URLs
!urxvt*cutchars: '"'()*<>[]{|}
!
! Appearance
!urxvt*font: -xos4-terminus-medium-*-*-*-12-*-*-*-*-*-iso8859-2
!urxvt*boldFont: -xos4-terminus-bold-*-*-*-12-*-*-*-*-*-iso8859-2
!
! Cursor
urxvt*cursorColor: White
! URLs
!urxvt*.colorUL: Blue
!
! Pseudo Transparency
!urxvt*shading: 50
!urxvt*transparent:true
!
!Real Transparency
URxvt.depth: 32
URxvt.background: rgba:1111/1111/1111/dddd
!
!Colors
color0: (black) = Black
color1: (red) = Red3
color2: (green) = Green3
color3: (yellow) = Yellow3
color4: (blue) = Blue3
color5: (magenta) = Magenta3
color6: (cyan) = Cyan3
color7: (white) = AntiqueWhite
color8: (bright black) = Grey25
color9: (bright red) = Red
color10: (bright green) = Green
color11: (bright yellow) = Yellow
color12: (bright blue) = Blue
color13: (bright magenta)= Magenta
color14: (bright cyan) = Cyan
color15: (bright white) = White
!foreground = Black
!background = White
!
!}}}But ~/.zshrc still isn't recognizing any of the defined colors in ~/.Xresources.
Offline
I read the rest of the urxvt wiki and I don't see anything about setting foreground and background colors for nano or man pages. I have to be missing something.
Offline
@Clarence.e.a,
Slow down! We know you're anxious to get pretty colors, but you're defeating yourself here in the forums by not searching the web and the wiki more thoroughly before posting questions. Arch users generously reward those who show they try to help themselves. Otherwise you get brutally treated as a 'help vampire'.
Have you searched the web? A search in the Arch wiki is sometimes unrewarding if you don't know what terms to use. So try Google or another web search engine. These two searches will surely bring up something: 'color man page' and 'linux nano color'.
Once you've narrowed down your search terms, perhaps then the wiki and forum searches may be friendly to you—other forum members certainly will be friendlier if you show you've done your research.
Offline
As I said in my first post, I have read a LOT. I only resort to the forums when I simply cannot figure something out (I'm still reading a lot
). I can give you a few links as to what I've read.
I was reading about changing the colors through zsh, but after guelfi's post I started researching changing the colors through urxvt. From what I've read I think colors are defined in the ~/.Xresources file for urxvt and then applied in the ~/.zshrc file, but none of the colors I'm defining in ~/.Xresources are corresponding with what I'm applying in ~/.zshrc if that makes any sense. I've read this during my research in figuring urxvt out and I noticed that none of my colors had the URxvt* prefix, so I added that to all of my colors, but to no avail. I also noticed that he was using a #XXXXXX format for some of his colors (the X's being numbers indicating colors I assume). I'm researching that now.
Any help in speeding up the process is still greatly appreciated. I just feel like I'm reading the wrong things or that I'm on the wrong track.
Offline
I suggested a web search because the forum usually only deals with particular, limited problems, not general how-tos. But looking at example .Xdefaults or .Xresources can help.
You configure urxvt's available colors using your .Xdefaults or .Xresources file. Nano, zsh, and the PAGER for man pages (usually less) are applications that run in a terminal. They will have their own configuration files.
If you have xorg-docs installed, you can run 'man X'. There is a section titled 'COLOR NAMES' that gives a technical explanation of specifying colors in your .Xresources. Arch doesn't include the file 'usr/share/X11/rgb.txt', so specifying colors by common name won't work. You will have to use one of the alternate methods. RGB is usually easiest and most users will opt for the six-digit hexadecimal format with the hash symbol. Try Googling 'rgb hex color chart'.
To apply any changes you've made to your .Xresources file, you have to restart X or run
xrdb -merge ~/.XresourcesIf you have chosen not to restart X, the changes won't be apparent in the current terminal; you need to start a new instance of urxvt.
To see some examples of terminal color schemes and the resource files, try this in Google to search these forums:
site:bbs.archlinux.org terminal color schemeSide bar: The 'site:bbs.archlinux.org' limits the Google search to the Archlinux forums. To search just the Arch wiki, use 'site:wiki.archlinux.org', or to search all of the official Arch sites, use 'site:archlinux.org'.
Offline
First off: Thank you for pointing me in the right direction thisoldman, I've made a lot of progress thanks to your guidance.
I've made a lot of progress, but I've still ran into a few kinks. Here's the progress I've made:
1. I know what color schemes are in ~/.Xdefaults are now and how they affect zsh
2. I found out how to change man page colors through the "most" package, thanks to thisoldman's search suggestion
3. I found out that you configure nano through ~/.nanorc
Here are the problems:
1. I can't find the "most" package system-wide configuration file (the wiki seems to be incorrect/out of date)
2. I can't adjust ~/.nanorc's color section without getting a "cannot add a color command without a syntax command" error.
3. I'm trying to get alsamixer to be transparent (it looks weird with my new color scheme) and I don't know how to add the required lines to the alsa-util package. I've been reading this thread. I can't find the file to edit to apply the "patch".
I have done my research trying to find solutions to these problems (Arch Wiki, Arch Forums, Man Pages, Google, and the respective programs dedicated forums).
Any help would be appreciated, I'm stumped.
Edit: Added problem #3
Last edited by Clarence.e.a (2012-04-30 01:17:28)
Offline
1. One way of finding 'most.rc' is to check http://www.archlinux.org/packages/. Find the package description page and click on "View the file list for most." An easier way is to use the 'locate' command.
$ locate most.rcMost is one of the few programs that doesn't install a configuration file by default. As root, copy the file to the '/etc' directory and then edit it.
2. Color in text editors is based on the syntax of the script or computer language you are editing. The various default syntax-highlighting color schemes for nano are located in '/usr/share/nano/'. To add syntax highlighting for shell scripts you could copy the contents of '/usr/share/nano/sh.nanorc' to your own '~/.nanorc'. A simpler way is to add this line to '~/.nanorc'
include /usr/share/nano/sh.nanorcNano won't color many configuration files such as '/etc/rc.conf' because it can't recognize the language being used. It certainly doesn't have the syntax highlighting capability of vim, gvim, or emacs.
3. The alsamixer patch that you linked is to be applied to the source files before the program is compiled. Patching source code and compiling programs are skills you may want to acquire later, not now. There is also a very great probability of a two-year-old patch failing with the current source code of alsamixer. As alternatives, several gui mixers are listed in the extra and community repos, and even more are listed in the AUR.
# pacman -Ss mixerOffline
I read on the wiki that most doesn't have a user-specific configuration file by default, and I did create that, I just copied the one from /usr/share/doc/most/most.rc to ~/, but the thing is that when I didn't have a ~/.mostrc I could see the effects, some orange/green/cyan text so I knew it was working and reading off of a system-wide config file, and it had a transparent background. Since I added the ~/.mostrc file it doesn't have a transparent background and it's kind of annoying. I wanted to look at the system-wide config file so I could see what they did to give it a transparent background. By the way, thanks for the tip about looking at the package database, that will definitely come in handy later, but this time it still didn't point me to a system-wide config file.
Since I included that path file in ~/.nanorc I can see similar effects of most, syntax being colored green and orange, but the normal text is still black and pretty hard to read. Here is the specific section I want to change in ~/.nanorc to get an overall white foreground and transparent background, but every time I change it I get the "cannot add a color command without a syntax command" error, even though I included the syntax line in ~/.nanorc.
## Color setup
##
## Format:
##
## syntax "short description" ["filename regex" ...]
##
## The "none" syntax is reserved; specifying it on the command line is
## the same as not having a syntax at all. The "default" syntax is
## special: it takes no filename regexes, and applies to files that
## don't match any other syntax's filename regexes.
##
## color foreground,background "regex" ["regex"...]
## or
## icolor foreground,background "regex" ["regex"...]
##
## "color" will do case sensitive matches, while "icolor" will do case
## insensitive matches.
##
## Valid colors: white, black, red, blue, green, yellow, magenta, cyan.
## For foreground colors, you may use the prefix "bright" to get a
## stronger highlight.
##
## To use multi-line regexes, use the start="regex" end="regex"
## [start="regex" end="regex"...] format.
##
## If your system supports transparency, not specifying a background
## color will use a transparent color. If you don't want this, be sure
## to set the background color to black or white.
##
## If you wish, you may put your syntaxes in separate files. You can
## make use of such files (which can only include "syntax", "color", and
## "icolor" commands) as follows:
##
include "/usr/share/nano/sh.nanorc"
##
## Unless otherwise noted, the name of the syntax file (without the
## ".nanorc" extension) should be the same as the "short description"
## name inside that file. These names are kept fairly short to make
## them easier to remember and faster to type using nano's -Y option.
##
## All regexes should be extended regular expressions.About the alsamixer thing, I didn't think it would be TOO hard, but if you say so I should probably put that off until later.
Thanks for the help,
Clarence
Offline
I will suggest you start reading more of the basic linux tutorials. My patience is exhausted.
I can see you don't know how options for a command are presented in a man page nor what a regex is. Here's a small bit of help: http://linuxcommand.org/reading_man_pages.php.
I don't want to either discourage or encourage you, but you do have a lot to learn. You are learning to swim by jumping into the deep end with Arch. I will suggest you use a GUI editor while you try to figure out nano.
Offline
Pages: 1