zsh-users
 help / color / mirror / code / Atom feed
* Re: How do *you* sync your zsh config files?
@ 1999-04-12 14:03 Jay Sekora
  0 siblings, 0 replies; 7+ messages in thread
From: Jay Sekora @ 1999-04-12 14:03 UTC (permalink / raw)
  To: zsh-users

For a while (well before I started using zsh) I was using a Makefile to
generate my dotfiles.  Mostly it just concatenated pieces from
subdirectories, based partly on hostname.  So I had a subdirectory with
files like aliases.work, aliases.home, aliases, aliases.aelfric (where
aelfric was a hostname) and so on, and the right ones would be picked
out and concatenated into my (ick!) .tcshrc in the right place, along
with all the other goodies.  (I also had stuff to generate menus for
several window managers with the same clients.)

Because the Makefile knew how to pick out the right pieces for the host
I was on (I had separate Makefiles for home and work, so they had that
part hardcoded in, and then the chose other stuff based on hostname.  I
also had a per-account preamble, if I remember correctly.) I could just
keep that directory synched across accounts and type "make" in my home
directory whenever I changed anything.

Nowadays, I might use wget or something like that to grab components
from a central machine over the Web, and ask the user (presenting a
diff) before updating files, but at the time I was just ftp'ing the
contents of that directory around.

Make is not just a programmer's tool. :-)

-j.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How do *you* sync your zsh config files?
  1999-04-15 19:22 ` Adam Spiers
@ 1999-04-16  4:45   ` Timothy J Luoma
  0 siblings, 0 replies; 7+ messages in thread
From: Timothy J Luoma @ 1999-04-16  4:45 UTC (permalink / raw)
  To: zsh-users

Replying to message of Thu, 15 Apr 1999 20:22:14 +0100
	from Adam Spiers <adam@thelonious.new.ox.ac.uk>
	regarding ``Re: How do *you* sync your zsh config files?''
	
> > I'm getting to the point of dumping everything in one big .zshenv
> > (global config files are empty in most of these cases) but that's
> > not really what I'd prefer... I like having my
> > aliases/bindkeys/completions/etc all in different files, in case of
> > an editing mistake in one file it is easier to locate and fix.
>
> Why's that?  zsh usually tells me a line number if I mess things up
> badly.


Unfortunately zsh can get confused, especially with missing end quotes (my  
favorite error to make)... it can tell me the line number that's really far  
from where the open quote goes.

I've got all my complex functions (those which span more than one 70-char  
line) in separate files in a folder $ZDOTDIR/Functions/Complex/ for this  
exact same thing.... any problem with one doesn't hurt the others.

It makes things much easier, especially when you do several different  
changes in a row (as I seem to tend to do).

TjL



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How do *you* sync your zsh config files?
  1999-04-10 23:57 Timothy J Luoma
  1999-04-11  1:32 ` Michael Barnes
@ 1999-04-15 19:22 ` Adam Spiers
  1999-04-16  4:45   ` Timothy J Luoma
  1 sibling, 1 reply; 7+ messages in thread
From: Adam Spiers @ 1999-04-15 19:22 UTC (permalink / raw)
  To: zsh-users

Timothy J Luoma (tjlists@bigfoot.com) wrote:
> Does anyone else have advice on trying to keep these 4 separate accounts  
> somewhat in sync, so I don't have to re-write every new function over and  
> over again?

Keep everything as portable as possible.  Error-check as much as
possible, and make as few assumptions as possible - for example, if a
function you use for a particular completion runs a program in order
to calculate possible completions, check that that program is actually
installed on the current system, and if not, try to write some
fall-back code.  Use ~ and $USER instead of the values they expand to.
Use that switch-on-zsh-version technique mentioned elsewhere in this
thread.

> I once tried a 'zlocal' file that I would keep all my local configurations,  
> and keep everything else current, but that didn't work.

Why not?  I have this at the end of ~/.zshenv:

if [[ -r $HOME/.zshenv.local ]]; then
    . $HOME/.zshenv.local
fi

if [[ -r $HOME/.zshenv.${HOST%%.*} ]]; then
	. $HOME/.zshenv.${HOST%%.*}
fi

and similarly for .zshrc.  Thus the main bulk of my setup is in
.zshrc, but any tweaks specific to a particular host can go in the
much smaller .zshrc.host, and any tweaks specific to a particular
group of hosts which NFS-share my home directory go in .zshrc.local. 

> I'm getting to the point of dumping everything in one big .zshenv
> (global config files are empty in most of these cases) but that's
> not really what I'd prefer... I like having my
> aliases/bindkeys/completions/etc all in different files, in case of
> an editing mistake in one file it is easier to locate and fix.

Why's that?  zsh usually tells me a line number if I mess things up
badly.

Here's how I've recently re-implemented my rc file syncing across
different hosts:

rc_home='adam@main.host.with.rcfiles:'

zsh_rcfiles=( ~/.zsh{rc,env}(N:s#$HOME/##) )

emacs_rcfiles=( \
                ~/.[e]macs(N:s#$HOME/##) \
                ~/lib/emacs/init/**/*.el(N:s#$HOME/##) \
              )

misc_rcfiles=( \
               ~/.{bash,complete,ex,lftp,lynx,shell,ytalk}rc(N:s#$HOME/##) \
             )

all_rcfiles=( $zsh_rcfiles $emacs_rcfiles $misc_rcfiles )

function sendhome {
    if [[ $#* -eq 0 ]]; then
        echo 'Usage: sendhome <files>'
        return 1
    fi

    if [[ "`which rsync`" != "rsync not found" ]]; then
        pushd ~ >/dev/null
        rsync -aHRuvz -e ssh $* $rc_home
        if [[ $OLDPWD != $PWD ]] popd >/dev/null
    else
        echo rsync not found and no other transfer method implemented yet
    fi
}

function gethome {
    if [[ $#* -eq 0 ]]; then
        echo 'Usage: gethome <files>'
        return 1
    fi

    if [[ "`which rsync`" != "rsync not found" ]]; then
        rsync -aHRuvz -e ssh $rc_home"$^^*" ~
    else
        echo rsync not found and no other transfer method implemented yet
    fi
}

Constructive criticism very welcome.

Of course, there are drawbacks to this system of having one central
repository.  I keep a `history' section in the comments at the top of
my bigger rc files, so that I can confirm which is the newer of two
versions; however an automated alternative to this would be great.  I
considered using cvs a while back and decided against it, although I
suspect that I rejected on the grounds that you had to use rsh which
is insecure (of course, I have since discovered that you can easily
tunnel cvs through ssh instead!)  At the end of the day, my main goal
was to produce as simple a design as possible, so that if I suddenly
found myself in an environment without cvs, ssh, or any other nice
tools, I could still pluck one magic .zshrc (or whatever) from my host
and get a workable environment quickly.

Incidentally, if anyone can explain why this works

zsh_rcfiles=( ~/.[z]sh{rc,env}(N:s#$HOME#\\\\\~#) )

but with any less backslashes it doesn't work, I'd be very interested
to hear, not to mention extremely impressed!  Also, I didn't think
$variable interpolation was even supposed to occur within s///
modifiers (from zshexpn: ``The left-hand side of substitutions are not
regular expressions, but character strings.'')  I guess this must be
something to do with the expansion order.

In the course of experimenting with globbing in conjuction with the
s/// modifier inside arrays, I experienced some strange things, which
got me so confused that I couldn't decide whether they were the
correct behaviour or not, even after careful reading of the man
pages... I would try to be more descriptive and helpful in case any
zsh-workers are listening, but I don't really have time right now.
Thought I'd mention it anyway.  Sorry -- maybe another time!

P.S. Is this excessive, or fairly standard amongst zsh hackers?

adam@omni ~ % wc .zsh{rc,env}*~(*~|*.flc)
   1345    5211   35741 .zshrc
      7       5      51 .zshrc.local
      7       9     109 .zshrc.prophet5
    117     319    2301 .zshenv
      9      11     156 .zshenv.local
   1485    5555   38358 total


-- 
Adam Spiers  -=-  music student @ RAM.ac.uk  -=-  Perl/Linux/security hacker
e-mail: adam@spiers.net            PGP & WWW: http://www.new.ox.ac.uk/~adam/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How do *you* sync your zsh config files?
  1999-04-11  1:32 ` Michael Barnes
  1999-04-11  5:06   ` Bart Schaefer
@ 1999-04-12  7:40   ` David Kågedal
  1 sibling, 0 replies; 7+ messages in thread
From: David Kågedal @ 1999-04-12  7:40 UTC (permalink / raw)
  To: zsh-users

"Michael Barnes" <mibarnes@vt.edu> writes:

> On Sat, Apr 10, 1999 at 07:57:14PM -0400, Timothy J Luoma wrote:
> > 
> > Anyone else in this situation:
> > 
> > I use zsh on 6 different accounts on 4 different machines (4 different  
> > versions of zsh, 3 different OSes)
> > 
> > I'm constantly finding that I've added an alias on one account and want to  
> > use it on the others, but the machines are not such that I could make them  
> > identical (at least two different $USERNAMEs, and on 2 of the machines I  
> > don't have root access.... one of them I don't even have access to 'cc' or  
> > 'gcc' to build a more recent version of zsh).
> > 
> > Does anyone else have advice on trying to keep these 4 separate accounts  
> > somewhat in sync, so I don't have to re-write every new function over and  
> > over again?
>
> Great question, as I am in a very similar situation as to the number of
> accounts and OSes (4 OSes, and numberous accounts).  I've been thinking
> for a long time about doing it over cvs since I do cvs for development,
> however, cvs is not installed on most of these systems (I guess I should do
> it being I admin these boxes :)  But I would like to hear about how other
> people do similar things.  This also pertains to other .files as well.

I have used CVS for a a couple of years with great success. I set up a
private repository on one of the systems and use remote CVS from the
other systems.  Not only do I manage my zsh files, I also manage Emacs
startup files, ssh config files, X11 resources, and my terminfo
database this way.

-- 
David Kågedal        <davidk@lysator.liu.se> http://www.lysator.liu.se/~davidk/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How do *you* sync your zsh config files?
  1999-04-11  1:32 ` Michael Barnes
@ 1999-04-11  5:06   ` Bart Schaefer
  1999-04-12  7:40   ` David Kågedal
  1 sibling, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 1999-04-11  5:06 UTC (permalink / raw)
  To: zsh-users

On Apr 10,  7:57pm, Timothy J Luoma wrote:
} Subject: How do *you* sync your zsh config files?
}
} Anyone else in this situation:
} 
} I use zsh on 6 different accounts on 4 different machines (4 different  
} versions of zsh, 3 different OSes)

I have been in that situation in the past, though the number of different
zsh versions is now down to 3 (only 2 if you don't count 3.1.5, which I
only use part of the time at home) and the number of different OSs has
effectively dwindled to 2 (I now use Linux nearly everywhere, though the
distribution and libc vary).

} Does anyone else have advice on trying to keep these 4 separate accounts  
} somewhat in sync, so I don't have to re-write every new function over and  
} over again?

The one-word answer is "ediff".  The three-word answer is "ediff and
ange-ftp".

The considerably more complicated answer is that I long ago added to the
top of my .zshenv the lines:

---
# Set variables sanely for assorted versions
: ${VERSION:="$ZSH_NAME $ZSH_VERSION"}
: ${MACHTYPE:+${HOSTTYPE::=$MACHTYPE-$OSTYPE}}
: ${MACHTYPE:=${HOSTTYPE%%-*}}
: ${OSTYPE:=${HOSTTYPE#*-}}

case "$VERSION" in
# A several-way switch for various flavors of zsh
esac
---

And then later on I have other case statements that switch on $HOSTTYPE
or whatever.  I also have several case statements on $VERSION in my
~/.zshrc file.  My init files probably produce approximately the same
interactive environment (modulo completely missing features in older
ones) in any zsh from 2.0 through 3.1.5, though it's been a long time
since I actually started up anything older than 2.3.

(The reason I assign VERSION from ZSH_NAME and ZSH_VERSION, rather than
the other way around, is because all my init scripts were first written
for the older versions of zsh that didn't have the ZSH_ parameters, and
I was too lazy to fix all the references.)

I also make a lot of use of autoloaded functions.  I haven't created a
new alias in years, except to prefix some function name with "noglob"
or some trick like that.  I've occasionally considered making $fpath be
operating-system-dependent, but I no longer use enough different OSs
to mess with it just now.

} I'm constantly finding that I've added an alias on one account and want to  
} use it on the others, but the machines are not such that I could make them  
} identical (at least two different $USERNAMEs, and on 2 of the machines I  
} don't have root access....

I presume that $USERNAME is interesting because you're using some kind of
remote shell?

Set up a lookup table of usernames for yourself.  In 3.1.5, you can use an
associative array; in earlier versions, you can fake it.  Suppose you have
accounts on the machines "marble" "granite" and "shale".

    typeset -A usernames 2>&/dev/null
    # Have to do this in two steps because bad typeset options cause
    # the whole command line to abort in some versions of zsh
    [[ $? -eq 0 ]] || {
	usernames=()
	marble=1
	granite=2
	shale=3
    }
    usernames[marble]=luomat
    usernames[granite]=timjl
    usernames[shale]=tjlists

Now you can do stuff like this:

    rsh() {
	local command=rsh
	if [[ $OSTYPE:l == hp* ]]
	then
	    command=remsh
	fi
	command $command -l ${usernames[$1]:-$USERNAME} "$@"
    }

Of course, you may have to do more complicated things if the command wants
the host name to precede the -l option or whatever ...

} I once tried a 'zlocal' file that I would keep all my local configurations,  
} and keep everything else current, but that didn't work.

I used to do that with csh.  I agree that it doesn't work very well.

On Apr 10,  9:32pm, Michael Barnes wrote:
} Subject: Re: How do *you* sync your zsh config files?
}
} Great question, as I am in a very similar situation as to the number of
} accounts and OSes (4 OSes, and numberous accounts).  I've been thinking
} for a long time about doing it over cvs since I do cvs for development

If you keep all your dot-files in a subdirectory (then either symlink to
them from your home dir or point ZDOTDIR at it), there's a package called
"remsync" that does a pretty good job of tracking changes to a directory
tree, allowing you to e-mail minimal changes back and forth.  But it's
not very good for merging -- for that you could pick a host where you do
have access to CVS, and use remsync to keep your other zdotdirs in sync
with with a sandbox (or possibly a couple of sandboxes) on that host.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How do *you* sync your zsh config files?
  1999-04-10 23:57 Timothy J Luoma
@ 1999-04-11  1:32 ` Michael Barnes
  1999-04-11  5:06   ` Bart Schaefer
  1999-04-12  7:40   ` David Kågedal
  1999-04-15 19:22 ` Adam Spiers
  1 sibling, 2 replies; 7+ messages in thread
From: Michael Barnes @ 1999-04-11  1:32 UTC (permalink / raw)
  To: zsh-users

On Sat, Apr 10, 1999 at 07:57:14PM -0400, Timothy J Luoma wrote:
> 
> Anyone else in this situation:
> 
> I use zsh on 6 different accounts on 4 different machines (4 different  
> versions of zsh, 3 different OSes)
> 
> I'm constantly finding that I've added an alias on one account and want to  
> use it on the others, but the machines are not such that I could make them  
> identical (at least two different $USERNAMEs, and on 2 of the machines I  
> don't have root access.... one of them I don't even have access to 'cc' or  
> 'gcc' to build a more recent version of zsh).
> 
> Does anyone else have advice on trying to keep these 4 separate accounts  
> somewhat in sync, so I don't have to re-write every new function over and  
> over again?
> 
> I once tried a 'zlocal' file that I would keep all my local configurations,  
> and keep everything else current, but that didn't work.
> 
> I'm getting to the point of dumping everything in one big .zshenv (global  
> config files are empty in most of these cases) but that's not really what I'd  
> prefer... I like having my aliases/bindkeys/completions/etc all in different  
> files, in case of an editing mistake in one file it is easier to locate and  
> fix.
> 
> TjL
> 

Great question, as I am in a very similar situation as to the number of
accounts and OSes (4 OSes, and numberous accounts).  I've been thinking
for a long time about doing it over cvs since I do cvs for development,
however, cvs is not installed on most of these systems (I guess I should do
it being I admin these boxes :)  But I would like to hear about how other
people do similar things.  This also pertains to other .files as well.

Mike


^ permalink raw reply	[flat|nested] 7+ messages in thread

* How do *you* sync your zsh config files?
@ 1999-04-10 23:57 Timothy J Luoma
  1999-04-11  1:32 ` Michael Barnes
  1999-04-15 19:22 ` Adam Spiers
  0 siblings, 2 replies; 7+ messages in thread
From: Timothy J Luoma @ 1999-04-10 23:57 UTC (permalink / raw)
  To: zsh-users


Anyone else in this situation:

I use zsh on 6 different accounts on 4 different machines (4 different  
versions of zsh, 3 different OSes)

I'm constantly finding that I've added an alias on one account and want to  
use it on the others, but the machines are not such that I could make them  
identical (at least two different $USERNAMEs, and on 2 of the machines I  
don't have root access.... one of them I don't even have access to 'cc' or  
'gcc' to build a more recent version of zsh).

Does anyone else have advice on trying to keep these 4 separate accounts  
somewhat in sync, so I don't have to re-write every new function over and  
over again?

I once tried a 'zlocal' file that I would keep all my local configurations,  
and keep everything else current, but that didn't work.

I'm getting to the point of dumping everything in one big .zshenv (global  
config files are empty in most of these cases) but that's not really what I'd  
prefer... I like having my aliases/bindkeys/completions/etc all in different  
files, in case of an editing mistake in one file it is easier to locate and  
fix.

TjL



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-04-16  4:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-12 14:03 How do *you* sync your zsh config files? Jay Sekora
  -- strict thread matches above, loose matches on Subject: below --
1999-04-10 23:57 Timothy J Luoma
1999-04-11  1:32 ` Michael Barnes
1999-04-11  5:06   ` Bart Schaefer
1999-04-12  7:40   ` David Kågedal
1999-04-15 19:22 ` Adam Spiers
1999-04-16  4:45   ` Timothy J Luoma

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).