zsh-users
 help / color / mirror / code / Atom feed
* .zshrc help...
@ 2002-06-17  5:28 Will Yardley
  2002-06-17  5:55 ` Dan Nelson
  0 siblings, 1 reply; 4+ messages in thread
From: Will Yardley @ 2002-06-17  5:28 UTC (permalink / raw)
  To: zsh-users

FreeBSD's most recent release has changed the format for the LSCOLORS
variable.

with that in mind, i need some help adjusting my generic .zshrc. 

i currently use something like this (stolen from someone else) to adjust
stuff based on my ZSH_VERSION:

if [[ $ZSH_VERSION == 3.1.<5->* || $ZSH_VERSION == 3.<2->* ||
      $ZSH_VERSION == <4->* ]]; then

i'd like to do something similar to this (in concept; obviously it has
to be something more complex than this).  a good (but simple)
discsussion of the syntax above would also be helpful....

                if [ $(uname -r) <= 4.5 ]; then
                LSCOLORS="3x5x2x3x1x464301060203"
                elif [ $(uname -r) >= 4.6 ]; then
                LSCOLORS="dxfxBxcxbxegedabagacad"
                fi

note that uname -n reports a string like:

4.6-STABLE

do i need to strip out the '-STABLE' part (using sed or whatever) before
doing an arithmetic comparison?

-- 
Will Yardley
input: william < @ hq . newdream . net . >


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

* Re: .zshrc help...
  2002-06-17  5:28 .zshrc help Will Yardley
@ 2002-06-17  5:55 ` Dan Nelson
  2002-06-17  6:12   ` Will Yardley
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Nelson @ 2002-06-17  5:55 UTC (permalink / raw)
  To: zsh-users

In the last episode (Jun 16), Will Yardley said:
> FreeBSD's most recent release has changed the format for the LSCOLORS
> variable.
> 
> with that in mind, i need some help adjusting my generic .zshrc. 
> 
> i currently use something like this (stolen from someone else) to adjust
> stuff based on my ZSH_VERSION:
> 
> if [[ $ZSH_VERSION == 3.1.<5->* || $ZSH_VERSION == 3.<2->* ||
>       $ZSH_VERSION == <4->* ]]; then
> 
> i'd like to do something similar to this (in concept; obviously it has
> to be something more complex than this).  a good (but simple)
> discsussion of the syntax above would also be helpful....
> 
>                 if [ $(uname -r) <= 4.5 ]; then
>                 LSCOLORS="3x5x2x3x1x464301060203"
>                 elif [ $(uname -r) >= 4.6 ]; then
>                 LSCOLORS="dxfxBxcxbxegedabagacad"
>                 fi

You could use the is-at-least function (included with zsh 3.1.6 and
newer):

  autoload -U is-at-least
  if is-at-least 4.6 $OSTYPE ; then
    # new style
    LSCOLORS="dxfxBxcxbxegedabagacad"
  else
    # Old Style
    LSCOLORS="3x5x2x3x1x464301060203"
  fi

The syntax in the ZSH_VERSION test you pasted uses numeric range globs. 
<-> matches any number, <3-> matches the number 3 and higher, etc. 
That test could have been written more simply:

  if is-at-least 3.1.5 ; then

When passed one argument, is-at-least compares against $ZSH_VERSION.

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

* Re: .zshrc help...
  2002-06-17  5:55 ` Dan Nelson
@ 2002-06-17  6:12   ` Will Yardley
  2002-06-17 15:25     ` Dan Nelson
  0 siblings, 1 reply; 4+ messages in thread
From: Will Yardley @ 2002-06-17  6:12 UTC (permalink / raw)
  To: zsh-users

Dan Nelson wrote:
> In the last episode (Jun 16), Will Yardley said:

> > FreeBSD's most recent release has changed the format for the LSCOLORS
> > variable.
> > 
> > with that in mind, i need some help adjusting my generic .zshrc. 
> > 
> > i currently use something like this (stolen from someone else) to adjust
> > stuff based on my ZSH_VERSION:
> > 
> > if [[ $ZSH_VERSION == 3.1.<5->* || $ZSH_VERSION == 3.<2->* ||
> >       $ZSH_VERSION == <4->* ]]; then
> > 
> > i'd like to do something similar to this (in concept; obviously it has
> > to be something more complex than this).  a good (but simple)
> > discsussion of the syntax above would also be helpful....
> > 
> >                 if [ $(uname -r) <= 4.5 ]; then
> >                 LSCOLORS="3x5x2x3x1x464301060203"
> >                 elif [ $(uname -r) >= 4.6 ]; then
> >                 LSCOLORS="dxfxBxcxbxegedabagacad"
> >                 fi
> 
> You could use the is-at-least function (included with zsh 3.1.6 and
> newer):

just in case, i would like to avoid using something that's
version-dependent if possible... that seems to work though.

anyone see a problem with this (assuming that version numbers will
always be x.x)?

case $(uname) in
[...]
        FreeBSD)
        MY_REV=$(uname -r | sed "s/-.*//")
                if [[ $MY_REV == 4.<6-> ]]; then        
                LSCOLORS="dxfxBxcxbxegedabagacad"
                else
                LSCOLORS="3x5x2x3x1x464301060203"
                fi
        alias ls='ls -GF'
        export LSCOLORS
        ;;

-- 
Will Yardley
input: william < @ hq . newdream . net . >


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

* Re: .zshrc help...
  2002-06-17  6:12   ` Will Yardley
@ 2002-06-17 15:25     ` Dan Nelson
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Nelson @ 2002-06-17 15:25 UTC (permalink / raw)
  To: zsh-users

In the last episode (Jun 16), Will Yardley said:
> just in case, i would like to avoid using something that's
> version-dependent if possible... that seems to work though.

It is portable back to 3.0.7 (the oldest zsh I have).  It was just not
included in distributions until 3.1.6.  The function is small; you can
just stick it at the top of your script.
 
> anyone see a problem with this (assuming that version numbers will
> always be x.x)?
> 
> case $(uname) in
> [...]
>         FreeBSD)
>         MY_REV=$(uname -r | sed "s/-.*//")
>                 if [[ $MY_REV == 4.<6-> ]]; then        
>                 LSCOLORS="dxfxBxcxbxegedabagacad"
>                 else
>                 LSCOLORS="3x5x2x3x1x464301060203"
>                 fi
>         alias ls='ls -GF'
>         export LSCOLORS
>         ;;

You probably want [[ $MY_REV == 4.<6-> || $MY_REV == <5->* ]] to match
-current systems.  Your code also has the side-effect of setting
LSCOLORS on machines that do not cupport colors at all (like FreeBSD
3.5).


-- 
	Dan Nelson
	dnelson@allantgroup.com


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

end of thread, other threads:[~2002-06-17 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-17  5:28 .zshrc help Will Yardley
2002-06-17  5:55 ` Dan Nelson
2002-06-17  6:12   ` Will Yardley
2002-06-17 15:25     ` Dan Nelson

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).