Subject: Re: aliases in kde
To: Hume Smith <hclsmith@glinx.com>
From: Rob Windsor <windsor@warthog.com>
List: netbsd-users
Date: 03/06/2000 11:14:42
Verily did Hume Smith write:

> >> Where do you define your aliases?
> 
> >> ~/.cshrc or ~/.login or ~/.xsession (don't know if that works)?

> I'll just chuck in my random comments here.  Folx, please jump on any
> serious misconceptions i put in.  Forgive me if the asker already knows it
> well :)

Well, I'll add opinionated stuff, for sure...

> .login is "startup" stuff for, how should I call them, "dumb terminal
> sessions"?  The things you get from login, via a serial terminal, the
> console, telnet, rlogin, etc.

.login files are largely useless.  They're really only good for checking to 
see if you have $TERM set and if not, to query you for it.  I don't even 
bother with that, most .login files of the accounts at work have one line; a 
comment stating to put stuff in the .cshrc instead.

> .xession is startup stuff for X sessions.  It's thus analogous to .login,
> except by the nature of X it tends to start a lot of programs.  One big
> difference is that your session terminates when .xsession completes (.login
> just falls off the end and goes to a prompt), so the last thing run by
> .xsession has to hang around for awhile. =20

What I like to do with my .xsession is:

    : nimh; cat .xsession
    #!/bin/sh
    #
    . ${HOME}/.xinitrc

I've found on various systems that your .xsession is generally a superset of 
what you run in your .xinitrc, so this is better than a symlink.

Putting shell things like aliases in your .xsession isn't a good way of doing 
it.  You should only toss X-specific things in here.

> .login and .xsession are only run once per session, in your "topmost" shell.
>  Thus they should be used for the per-session things, like background tasks
> and environment variables.

Well, `session' can be confusing.  Firing up an xterm may be a `session' to 
one guy but not to another (and in your example, it isn't).  Another reason 
why .login files are somewhat useless.  :>

> .cshrc is run by every invocation of csh and tcsh (usually - seems to me
> there's a switch to tell the (t)csh not to).  It should thus be used to
> initialise things *internal* to (t)csh, ie which are not inherited from the
> caller... that's *shell* variables (made by set instead of setenv in (t)csh)
> and aliases.

The switch to tell (t)csh not to is "-f", e.g. in a script:

    #!/bin/csh -f
    setenv PATH /bin:/usr/bin:/foo
    do something

Your .cshrc file is where you need to do just about everything.  Now that I've 
said that, I'll add an au-contraire -- put your aliases in ~/.aliases and add 
the following in your .cshrc:

    if ( -f ~/.aliases ) then
        source ~/.aliases
    endif

This will clean up your .cshrc a *lot*

I also prefer to see people use
    "setenv PATH /foo:/bar:/baz"
instead of
    "set path = (/foo /bar /baz)"
but I that's just a personal preference.

Also, one last tidbit about your .cshrc -- you generally want a distinction in 
your .cshrc file between interactive shells and non-interactive shells.  The 
latter is when you "ssh machine /usr/local/bin/some_command".  There may be 
some settings that you don't want/need for non-interactive shells, such as 
"set history=30" (sets the shell history length -- see manpage for details).

For such items, you add to your .cshrc:

    if ($?prompt == 0) exit
    # Everything below this line is for interactive shells only.

Not that I actually use csh for anything, but here's my simple, complete 
.cshrc:

        # -*-text-*- because emacs likes it this way!
        setenv PATH /bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbi
n
        setenv LD_LIBRARY_PATH /usr/lib:/usr/local/lib

        setenv TMPDIR /tmp

        if ( -f ~/.aliases ) then
            source ~/.aliases
        endif

        if ($?prompt == 0) exit
        # Everything below this line is for interactive shells only.

        set history=20
        set ignoreeof=5


Enjoy.

-- Rob
----------------------------------------
Internet: windsor@warthog.com                             __o
Life: Rob@Carrollton.Texas.USA.Earth                    _`\<,_
                                                       (_)/ (_)
The weather is here, wish you were beautiful.