HP3000-L Archives

January 1997, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Chris Breemer <[log in to unmask]>
Reply To:
Chris Breemer <[log in to unmask]>
Date:
Fri, 24 Jan 1997 10:58:29 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (92 lines)
Further to the hints given by Mike hensly for the /etc/profile, I'll offer some
more handy stuff people might like to use:

1) Have the prompt always display your current directory.

This can be implemented with 2 lines in the profile:

        mycd () { 'cd' $1; export PS1="[`pwd`] "; }
        alias -x cd=mycd

Of course when you're in very deeply nested paths this gets irritating as it
eats up most of your command line. In that case, simply put in a newline character.

2) Use shell functions for management of the PATH variable :

        p       Display PATH components on line-by-line format rather than
                in one long line with semicolons

        apa     Add a path component (if it's not already in there)

        npa     Normalize path (remove any duplicate paths; you may be adding stuff
                in your local profile that's already done by /etc/profile

Here's the source for these functions, feel free to use them.

        p()                     # Display PATH line-by-line
        {
                SAVEIFS=$IFS
                IFS=":"
                set $PATH
                while [ $# -gt 0 ]
                do
                        echo $1
                        shift
                done
                IFS=$SAVEIFS
        }



        apa()                   # Add PATH component
        {
                dir=$1
                if [ ! -d $dir ]
                then
                        echo "Unavailable PATH component: $dir"
                        return
                fi

                found=N
                for path in `p`
                do
                        [ "$dir" = "$path" ] && found=Y
                done

                [ $found = "N" ] && PATH=${PATH}:$dir
                export PATH
        }


        npa()                   # Normalize path
        {
                NEWPATH=""
                for path in `p`
                do
                        NEWPATH="${NEWPATH}:"
                        NEWPATH=${NEWPATH}$path
                done
                export PATH=$NEWPATH
        }


So now in your .profile simply use e.g.

        apa /bin
        apa /usr/bin
        apa /etc
        apa .                           # Ok, you can argue this one ...
        apa /UTOOLS/PUB/etc
        apa /UTOOLS/PUB/bin

        npa                             # remove possible duplicates

and use apa interactively to amend the path. I also had a dpa to drop path entries but
I never used that, so it got deleted.

Have fun,


        Chris Breemer
        Compuware Europe B.V.

ATOM RSS1 RSS2