Zsh shell prompt customisation. And a useful config file.

zsh Configurations.

My .zshrc file, this is the example prompt this file will give you.

Fortune not found.
On since Wed Feb 22 21:07 (EST) on tty1,  idle 2:44
On since Wed Feb 22 02:55 (EST) on tty2,  idle 22:28
On since Wed Feb 22 22:48 (EST) on pts/0, idle 1:30, from :0.0
[Thu 06/02/23 01:23 EST][pts/2][i686-suse-linux/linux/2.6.14-Bejiitas_Wrath][4.2.5]
<saruman@bejiitaswrath:~>
zsh/4 58 %

And the .zshrc file itself. This is based on the .zshrc file example that
came with the Debian package of the z shell. With BASH functions from http://www.die.
net/doc/linux/abs-guide/sample-bashrc.html
. And:
/usr/share/doc/zsh-beta/examples/zshrc.gz. This example enables many useful
aliases and is faster to initialise than my ~/.bashrc example. Although that is
quite comprehensive. zsh has more features for programmers and the
autocompletion features present in the BASH shell, but working better in zsh.
You can get the source code for this shell here: ftp://ftp.zsh.org/pub/zsh/.

# /etc/zsh-beta/zshrc: system-wide .zshrc file for zsh-beta(1).
export MAIL=/var/spool/mail/$USERNAME
export LESS=-cex3M
export EDITOR=vim
export HELPDIR=/usr/local/lib/zsh/help  # directory for run-help function to find docs
manpath=($X11HOME/man /usr/man /usr/lang/man /usr/local/man)
export WINDOWMANAGER=/usr/bin/wmaker
manpath=($X11HOME/man /usr/man /usr/lang/man /usr/local/man:/usr/share/man)
# Adding /usr/share/man to the search path for Mepis GNU/Linux.
export MANPATH
# Misc colors.
export NORMAL=" \e[0m"
export GREEN=" \e[1;32m"
export YELLOW=" \e[1;33m"
export WHITE=" \e[1;37m"
export CYAN=" \e[1;36m"
MAILCHECK=300
HISTSIZE=200
DIRSTACKSIZE=20
eval `dircolors -b`
# Use hard limits, except for a smaller stack and no core dumps
unlimit
limit stack 8192
limit core 0
limit -s
umask 022
# Set up aliases
alias mv='nocorrect mv'       # no spelling correction on mv
alias cp='nocorrect cp'       # no spelling correction on cp
alias mkdir='nocorrect mkdir' # no spelling correction on mkdir
alias j=jobs
alias pu=pushd
alias po=popd
alias d='dirs -v'
alias h=history
alias grep=egrep
alias ll='ls -l'
alias la='ls -a'
alias cls='clear'
alias lu='ls -hula'
# More useful Aliases.
alias tarunpack='tar -zxvf'
alias bz2unpack='tar -jxvf'
# List only directories and symbolic
# links that point to directories
alias lsd='ls -ld *(-/DN)'
# List only file beginning with "."
alias lsa='ls -ld .*'
# This code courtesy of Emacs ;).
# Not everyone has finger(1).
if [ -x /usr/bin/finger ] ; then
	INFO=$(finger -lmps $LOGNAME | fgrep On )
	alias userlist='finger -lmps'
else
	INFO=$(uname -msov)
	alias userlist='users'
fi
# Shell functions
setenv()
{
	typeset -x "${1}${1:+=}${(@)argv[2,$#]}"
}  # csh compatibility
freload()
{
	while (( $# )); do; unfunction $1; autoload -U $1; shift; done
}
# These following functions from http://www.die.net/doc/linux/abs-guide/sample-bashrc.html
function my_ip() # get IP adresses. Bracket on next line C style...
{
    MY_IP=$(/sbin/ifconfig ppp0 | awk '/inet/ { print $2 } ' | sed -e s/addr://)
    MY_ISP=$(/sbin/ifconfig ppp0 | awk '/P-t-P/ { print $3 } ' | sed -e s/P-t-P://)
}
function lowercase()  # move filenames to lowercase.
{
    for file ; do
        filename=${file##*/}
        case "$filename" in
        */*) dirname==${file%/*} ;;
        *) dirname=.;;
        esac
        nf=$(echo $filename | tr A-Z a-z)
        newname="${dirname}/${nf}"
        if [ "$nf" != "$filename" ]; then
            mv "$file" "$newname"
            echo "lowercase: $file --> $newname"
        else
            echo "lowercase: $file not changed."
        fi
    done
}
# Where to look for autoloaded function definitions
fpath=($fpath ~/.zfunc)
READNULLCMD=${PAGER:-/usr/bin/pager}
echo -e "${CYAN}"
if [ -x /usr/games/fortune ] ; then
	echo
	fortune -l
	echo
	else
	echo -e "Fortune not found."
fi
echo -e "${NORMAL}"
echo -e "${YELLOW}"
echo -e "${INFO}"
echo -e "$NORMAL"
autoload -U compinit
compinit
autoload -U promptinit; promptinit
prompt clint white cyan red yellow

1 thought on “Zsh shell prompt customisation. And a useful config file.”

Leave a Reply to sheripatten Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.