On Sun, Oct 21, 2001 at 11:14:34AM -0700, Peter Jay Salzman wrote:
> cd()
> {
>       cd $1
>       xttitle `pwd`
> }
> 
> this is actually an infinite loop.   i'd much prefer to use "cd" rather than
> a homebrewed function to change directories

man bash
[snip]
       builtin shell-builtin [arguments]
              Execute the specified  shell  builtin,  passing  it
              arguments,  and  return  its  exit status.  This is
              useful when defining a function whose name  is  the
              same  as a shell builtin, retaining the functional�
              ity of the builtin within  the  function.   The  cd
              builtin is commonly redefined this way.  The return
              status is false if shell-builtin  is  not  a  shell
              builtin command.
[snip]

eg:
  cd () { builtin cd $1; test -n "$DISPLAY" && xttitle $PWD }

test -n will ensure you don't waste clock cycles when not running under X.

Using $PWD rather than `pwd` will run faster.  Useful during swapping when
you'd really rather have your root prompt come right back while you try to
regain control of an errant process.

hope that helps.

I've personally found that fancy prompts are usually a liability for a
sysadmin.  They are nice when not running as root though...

-- 
Ted Deppner
http://www.psyber.com/~ted/

Reply via email to