csh to bash : chdir

csh to bash : chdir

am 24.03.2005 22:02:53 von clinton__bill

Hi,
I am converting my csh stuff to bash and have a problem. In csh I
have an alias of cd command liek this,

alias cd='set old=$cwd; chdir \!*; set prompt=`hostname`":"`echo
$cwd|sed -e "s/^.*tmp_mnt//" -e "s/^.*users*/\/user/" -e
"s/^.*${USER}\/*//"`">"; ls'

This alias is convenient, it change the cd function so that when I
change the directory the path shows on the term title and ls command
runs.

Problem is I use some tool to convert this csh alias to bash format
like this,

cd () { command set old=$PWD; chdir "$@";set prompt=`hostname`":"`echo
$PWD|sed -e "s/^.*\///" -e "s/^.*${USER}\/*//"`">";/devl/tree/bin/xicon
${HOST}; /devl/tree/bin/xtitle ${USER}@${HOST}:${cwd}; ls ; }

But "chdir" is not a bash command. And I always get such error,

bash: chdir: command not found

ls: illegal option -- -
ls: illegal option -- =
ls: illegal option -- y
usage: ls -1RaAdCxmnlogrtucpFbqisfL [files]

Do you know how to fix this?

Re: csh to bash : chdir

am 24.03.2005 22:15:15 von cfajohnson

On Thu, 24 Mar 2005 at 21:02 GMT, clinton__bill@hotmail.com wrote:
> Hi,
> I am converting my csh stuff to bash and have a problem. In csh I
> have an alias of cd command liek this,
>
> alias cd='set old=$cwd; chdir \!*; set prompt=`hostname`":"`echo
> $cwd|sed -e "s/^.*tmp_mnt//" -e "s/^.*users*/\/user/" -e
> "s/^.*${USER}\/*//"`">"; ls'
>
> This alias is convenient, it change the cd function so that when I
> change the directory the path shows on the term title and ls command
> runs.
>
> Problem is I use some tool to convert this csh alias to bash format
> like this,
>
> cd () { command set old=$PWD; chdir "$@";set prompt=`hostname`":"`echo
> $PWD|sed -e "s/^.*\///" -e "s/^.*${USER}\/*//"`">";/devl/tree/bin/xicon
> ${HOST}; /devl/tree/bin/xtitle ${USER}@${HOST}:${cwd}; ls ; }

You are using constructions that do not work in bash; and the bash
prompt is in $PS1, not $prompt.

> But "chdir" is not a bash command. And I always get such error,
>
> bash: chdir: command not found

The obvious thing is to use a bash command, i.e., cd, and to
prevent the function being called recursively, call it as:

builtin cd ...

To set the xterm window title, I put this in the PROMPT_COMMAND
variable:

PROMPT_COMMAND='echo -ne "\033]0; $USER@$HOSTNAME \t $PWD \t `date +"%d-%b-%Y %I:%M %p"`\007"'


--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
============================================================ =======
My code (if any) in this post is copyright 2005, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License