[CLUE-Tech] Changing view of ls command

Kevin Cullis kevincu at orci.com
Wed Dec 6 16:42:10 MST 2000


"Michael J. Hammel" wrote:
> 
> Thus spoke Kevin Cullis
> > However, I'd like to limit my search to just my home directory and not
> > the .files to show up, don't need them.  Based on Grants comment, I
> > would guess that I'm going to have to use sort to limit it to that.  I
> > was wondering if I could modify something to display the kilobytes in
> > the ls command, but alas, I can't.
> 
> You can write a bash (or ksh) function that does what you want, then alias
> "ls" to that function.  This is what I do with vi and cd in order to get the
> name of the file being edited or the directory to which I've changed into
> the title bar of my xterms.  Here is how it's set up:
> 
> if [ "$TERM" = "xterm" ] && [ "$0" = "bash" -o "$0" = "-bash" -o "$0" = "/bin/bash" ]
> then
>         ilabel () { echo -n "]1;$*"; }
>         label () { echo -n "]2;$*"; }
>    alias stripe='label $HOSTNAME - ${PWD#$HOME/}'
>         alias stripe2='label $HOSTNAME - vi $*'
>         cds () { "cd" $*; eval stripe; }
>         vis () { eval stripe2; "vi" $*; eval stripe;}
>         alias cd=cds
>         alias vi=vis
>         eval stripe
>         # eval ilabel "$USER@$HOSTNAME"
>         eval ilabel "$HOSTNAME"
> fi
> 
> This is placed in my .bashrc file.  You can do something similar in order
> to get ls to do what you're asking (even using command line args, which I
> do with another alias for cscope).

Cool.  First, I didn't know this could be done above.  Second, I'm gonna
hafta devote some serious brain cells in learning the above, more than
I'd like to devote at the moment.  But now that I know the capability of
what bash can do and what I can do with it, I'll keep it in mind for
future reference (I'm learning to be a propellar-head, but I gots a ways
to go like you ;-) ).

Thanks for the tip, Michael.

Kevin



More information about the clue-tech mailing list