[TriLUG] scripting question

paul ppeeler at gmail.com
Thu Mar 17 17:03:16 EST 2005


On Thu, 17 Mar 2005 13:39:13 -0800 (PST), Chris Bullock
<cgbullock at yahoo.com> wrote:
> sorry using kshell not c shell and when i run the script I get "logout" is
> my scripts name.
> coping history to myhistory
> ./logout[3]: fc: no history (yet)
> 
> --- Chris Bullock <cgbullock at yahoo.com> wrote:
> > I am trying to learn BSD and I really hate that it does not save my
> > history after I log out.  So I have tried to write a script that saves
> > my
> > history and puts the file in my home dir. This is the script, I am using
> > the c shell.
> > ----begin script---
> > #!/bin/csh
> > echo "coping history to myhistory"
> > history >> shhistory
> > exit
> > ----end script---


In csh you set it with:
set history=100
as an option in .cshrc would save the last 100 commands.

set savehist=100 
as an option in .cshrc would save the last 100 for when you log in the next time

(or in .login as it is read after .cshrc)

This isn't all, but is a large chunk of a default .cshrc file.

<snip>

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin
/usr/local/bin /usr/X11R6/bin $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER   more
setenv  BLOCKSIZE       K

if ($?prompt) then
        # An interactive shell -- set some stuff up
        set prompt = "`/bin/hostname -s`# "
        set filec
        set history = 100
        set savehist = 100
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
        endif
endif

</snip>

Hope this helps.

Paul



More information about the TriLUG mailing list