Solved Yak Shaving Shell Hell

I have just been reading this thread and am wondering if any of you use multiple shells and have a nice way to share their configurations?

I found this approach but I'm thinking about trying a single a .personal config file sourced at the bottom of .profile and .bashrc and .zshrc and the others, and make that single included file deal with all of the issues that come up:
  • syntax differences
  • multiple-entry idempotency
  • interactive vs. non-interactive
  • login vs non-login
  • what else?
 
For me it's simply easier to have separate config files, one for each shell.
Otherwise your single file has a bunch of lines that are similar.
But how do you know which section to source?
You need if/else if/else clauses, but you need a shell agnostic if construct.
 
I only use sh and bash. I have sh config files and libraries that are sourced by bash. If it's bash then it sources additional bash-only files.

The same trick doesn't work with zsh.
 
wondering if any of you use multiple shells and have a nice way to share their configurations?
 
You need if/else if/else clauses, but you need a shell agnostic if construct.
Could you clarify this a little more for me? I found that the original Bourne shell didn't have elif, but Almquist does, and test condition syntax is different in different shells, of course, but if i stick to POSIX behavior, what other problems might I run into with if constructs?
 
test condition syntax is different in different shells
That's basically what I was talking about.
If you try and have a single file to be sourced by all your different shells, you pretty much have to have different sections, selected by if's or tests.
csh/tcsh setenv wont' work in sh or bash
the way you define aliases in them are different
Back up to #3 by cracauer@ that works because bash can use sh syntax as a least common denominator.

If all the shells you are considering share lineage, you may be able to come close. If you are trying to do it across csh and sh, very hard to do. csh and tcsh, sure because of lineage.
 
Back
Top