Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Zsh configuration files



On Sun, 23 Nov 2008, MaurÃÂcio wrote:

I've just started using zsh in two computers. I
configured zsh in one of them and copied .zshrc
and .zcompdump to the other. However, the prompt
in the second is different from the first. Are
there other configuration files I forgot to
copy?

Define different. If one has bold colors where the
other has light colors, it's a implementation detail
of the terminal emulator.

Most notably at the moment, Konsole 1.x (KDE 3)
employs lighter colors while Konsole 2.x (KDE 4)
uses bold. Bold is correct, but many terminals
don't adhere to that.


Nothing important, just the prompt in the second
computer shows no information (current directory
etc.).

What matters to me is that, since I keep my
configuration under version control, I would like
to be sure everything in my user configuration is
there. If something remains wrong, I'll try to fix.

Thanks,
MaurÃcio

Hi MaurÃcio --

Nice to see you here.

Long ago, I set some things up for easily sharing my Zsh startup scripts between various computers I use. I did most of this when I was still fairly new to Zsh, so some things might have easier/better ways to do them, but this is how I set mine up. Some features:

1. Automatically runs any files matching .zsh_* in my home dir, excluding vim swap files

2. For running as root, I can just link my normal-user .zshrc and .zshenv files, and it'll detect that they're linked, and use the .zsh_* files from my normal-user directory

3. To override things in the .zsh_* files, I also have .zsh_*- files.
(e.g. .zsh_prompt, for general prompt setup, and .zsh_prompt- for system-specific)

4. On some systems, I don't have 'list' access to my actual home dir until I get my AFS tokens, so I read the list of .zsh_* files from ~/.ZSHFILES



Here's the section from my .zshrc that handles all this:

##### at the end of my .zshrc #####
# three dirs to check by default
dirs=(~/.zsh-scripts ~ ~/.zsh-scripts-)

# if this .zshrc is a symlink, use its directory, too
SCRIPT=${(%)${:-%N}}
if [ -L $SCRIPT ] ; then
        SCRIPT=$(readlink $SCRIPT)
        dirs+=($SCRIPT:h)
fi
for dir in $dirs ; do
        [ ! -d $dir ] && continue
        setopt nullglob
        pushd $dir
        files=(.zshrc-)
        if [ -f .ZSHFILES ] ; then
                files=($files `cat .ZSHFILES`)
        else
                files=($files *zsh_*~*.swp~*.zsh_history)
        fi
        for file in $files ; [ -r $file ] && source $file
        popd
        setopt nonullglob
done
##### .zshrc #####


So, in my Mercurial repository, I have the following files:

.zsh_aliases
.zsh_aliases-
.zsh_bluetooth-
.zsh_colors
.zsh_completion-
.zsh_functions
.zsh_functions-
.zsh_gpg-
.zsh_history_setup
.zsh_locale
.zsh_make_backups-
.zsh_math
.zsh_prompt
.zsh_prompt-
.zsh_screen
.zsh_ssh
.zsh_svn_backup
.zshenv
.zshenv-
.zshrc
.zshreminder

But, I only really keep these versioned for my 'main' computer. For any other computers I use, I have a script that packages up the ones that aren't machine-specific and dumps it onto my web server. So, when I start using Zsh on a new computer I can do:

wget -O - http://benizi.com/zsh.tbz2 | tar -jxvf -
# (Nothing sensitive -- that's the actual URL.)

.screenrc
.vimrc
.zsh_aliases
.zsh_colors
.zsh_functions
.zsh_history_setup
.zsh_locale
.zsh_math
.zsh_prompt
.zsh_screen
.zsh_ssh
.zshenv
.zshrc

Usually the only thing I immediately add is:

echo 'PSCOLOR=$BLUE' > ~/.zsh_prompt-
(I find it helpful to have different machines' prompts colored differently. PSCOLOR is something used in .zsh_prompt)

(MaurÃcio -- The functions I mentioned on the mlterm list are spread across .zsh_prompt and .zsh_colors )

Best,
Ben


Messages sorted by: Reverse Date, Date, Thread, Author