My .zshrc file

I have started recreating my .bashrc file for usage with ZSH. So for your referencing enjoyment I present my wholly-copied-from-other-sources .zshrc file!

My command prompt looks like this..

jrobbins@myServer[/etc/init.d]
[10:15]:cat ~/.zshrc

#Color table from: http://www.understudy.net/custom.html
fg_black=%{$'\e[0;30m'%}
fg_red=%{$'\e[0;31m'%}
fg_green=%{$'\e[0;32m'%}
fg_brown=%{$'\e[0;33m'%}
fg_blue=%{$'\e[0;34m'%}
fg_purple=%{$'\e[0;35m'%}
fg_cyan=%{$'\e[0;36m'%}
fg_lgray=%{$'\e[0;37m'%}
fg_dgray=%{$'\e[1;30m'%}
fg_lred=%{$'\e[1;31m'%}
fg_lgreen=%{$'\e[1;32m'%}
fg_yellow=%{$'\e[1;33m'%}
fg_lblue=%{$'\e[1;34m'%}
fg_pink=%{$'\e[1;35m'%}
fg_lcyan=%{$'\e[1;36m'%}
fg_white=%{$'\e[1;37m'%}
#Text Background Colors
bg_red=%{$'\e[0;41m'%}
bg_green=%{$'\e[0;42m'%}
bg_brown=%{$'\e[0;43m'%}
bg_blue=%{$'\e[0;44m'%}
bg_purple=%{$'\e[0;45m'%}
bg_cyan=%{$'\e[0;46m'%}
bg_gray=%{$'\e[0;47m'%}
#Attributes
at_normal=%{$'\e[0m'%}
at_bold=%{$'\e[1m'%}
at_italics=%{$'\e[3m'%}
at_underl=%{$'\e[4m'%}
at_blink=%{$'\e[5m'%}
at_outline=%{$'\e[6m'%}
at_reverse=%{$'\e[7m'%}
at_nondisp=%{$'\e[8m'%}
at_strike=%{$'\e[9m'%}
at_boldoff=%{$'\e[22m'%}
at_italicsoff=%{$'\e[23m'%}
at_underloff=%{$'\e[24m'%}
at_blinkoff=%{$'\e[25m'%}
at_reverseoff=%{$'\e[27m'%}
at_strikeoff=%{$'\e[29m'%}
 
# PROMPT PIMPIN'
## Leave the initial line break or else your commands won't have space between them
PROMPT="
${fg_lgreen}%n@${at_underl}%m${at_underloff}${fg_white}[${fg_cyan}%~${fg_white}]
[${fg_green}%T${fg_white}]:${at_normal}"
 
## MAKE DER ZSH SING FOR ITS SUPPER
autoload -U compinit
compinit
 
## Lets set some options
setopt correctall
setopt autocd
setopt auto_resume
setopt extendedglob
setopt completeinword
unsetopt caseglob
 
## Set some ZSH auto complete options
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
zstyle ':completion:*:killall:*' command 'ps -u $USER -o cmd'
 
## History stuffs
HISTFILE=~/.zsh-histfile
HISTSIZE=5000
SAVEHIST=5000
setopt incappendhistory
setopt sharehistory
setopt extendedhistory
 
#ALIASES
##ls, the common ones I use a lot shortened for rapid fire usage
alias ls='ls --color' #I like color
alias l='ls -lFh'     #size,show type,human readable
alias la='ls -lAFh'   #long list,show almost all,show type,human readable
alias lr='ls -tRFh'   #sorted by date,recursive,show type,human readable
alias lt='ls -ltFh'   #long list,sorted by date,show type,human readable
 
## cd, because typing the backslash is A LOT of work!!
### not needed due to ZSH autocd opt
#alias .='cd ../'
#alias ..='cd ../../'
#alias ...='cd ../../../'
#alias ....='cd ../../../../'
 
#SSH ALIASES
## alias -g shost='ssh -p 9999 user@host.com'
 
# SCREEN ALIASES
## add a new screen , or entire session, name it, then ssh to the host
## Replace HOST with what you want the screen session named, surround with double quotes if there is a space
#alias sshost='screen -t HOST shost'
  1. #1 by Brie on April 21, 2010 - 4:48 am

    I’m always cruising for new prompts. I love this one. I’ve added a few more aliases (like alias p=’ping’).


    Brie

  2. #2 by jeffro on April 21, 2010 - 9:38 am

    @ Brie

    I am glad you liked it! I added a few new aliases at the bottom. I use screen A LOT any more. The screen aliases have come to be very helpful..

  3. #3 by Brie on April 23, 2010 - 2:33 pm

    Yeah, screen is one of those things I flat out *need* to just do. Everyone raves about it but I haven’t gotten around to it. I will soon. :)!

    Anyway, I’m adding you to my RSS reader and looking forward to reading more, Jeff! :)!


    Brie

  4. #4 by Goner Leone on November 5, 2010 - 12:11 pm

    I just switched from bash to zsh and I noticed a bit of weirdness that I managed to fix, but might be causing trouble for others.

    The color definitions are parsed incorrectly when using argument completion so you will see a strange gap between what you are trying to complete. For example:

    $ ls –h –help

    To fix this I had to wrap the color definitions with “%{…%}”. Now they look like this: fg_red=%{$’\e[0;31m’%}

    This change makes sure they are non-printing characters. Now I can adopt zsh as my new shell!

  5. #5 by jeffro on November 5, 2010 - 1:23 pm

    @Goner Leone
    Wow! Goner, you are my new favorite Linux geek. Thanks for posting that, it fixed that spacing issue I have been having for years! I could never figure out why. I have updated the posting with your recommendation.

  6. #6 by loot on December 7, 2010 - 6:18 pm

    why not use %F{color} instead of all your aliases?

  7. #7 by Aaron on December 20, 2010 - 7:22 am

    zsh/screen/vim are 3 must haves for me, actually i should say my “need only” group. As its all I need to get the job done =), loot that would imply they autoload colors (which I do so Ill try that).

  8. #8 by jeffro on December 20, 2010 - 11:03 am

    @loot

    Thanks for the alternate approach loot. I use the colors in that way for two reasons. 1) Because that is how I learned to do it so that is the way I default to when I want to apply a color; and 2) I use the colors in some functions that are also part of my .zshrc file, it keeps me from having to redefine colors throughout the whole file if I feel like a change. I can see benefits and downfalls to both approaches .

(will not be published)