Variables and keybinding in bash

sdougiama at cc.curtin.edu.au sdougiama at cc.curtin.edu.au
Fri May 31 13:44:54 AEST 1991


Thanks to those helpful folks who recently pointed me at bash 1.05.
I now have the thing successfully installed under Interactive 386/ix 2.0.2.
(with only a moderate amount of cursing)
 
My only troubles now are :
 
1)  Under csh, I used to get really nice colour 'ls' output using
    something like the following in my .cshrc :
 
  vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 
    set userid=`id | awk -F\( '{print $2}' | awk -f\) '{print $1}' `
    set todaydate="`date | cut -c5-10`"
 
    if ( "$term" == "AT386" || "$term" == "vt100" ) then
      alias ls "ls -CF \!* | sed -e 's;\([a-zA-Z0-9._+-]*\)/;^[[35m\1^[[0m/;g'
                                 -e 's;\([a-zA-Z0-9._+-]*\)\*;^[[31m\1^[[0m/;g'
                                 -e 's/${userid}/^[[36m${userid}^[[0m/'
                                 -e 's/${todaydate}/^[[33m${todaydate}^[[0m/' "
 
    endif
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
    This made for a messy alias, but it worked well and was fast.
    Under bash, I converted this to a function, something like:
 
  vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 
    function ls () {
      /bin/ls -CF $* | /bin/sed -e 's;\([a-zA-Z0-9._+-]*\)/;^[[35m\1^[[0m/;g'
                                -e 's;\([a-zA-Z0-9._+-]*\)\*;^[[31m\1^[[0m/;g'
                                -e 's/${userid}/^[[36m${userid}^[[0m/'
                                -e 's/${todaydate}/^[[33m${todaydate}^[[0m/'
    }
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
    Unfortunately, the last two sed expressions aren't working, because the 
    variables userid and todaydate are not being substituted at all.
    ie sed thinks it's looking for '${userid}' rather than the value of userid.
    Any ideas why this is so?  I really liked the ability to colour code 
    my own files and today's files.
 
2)  How is it possible to rebind the bash line-editing keys to be those my 
    (unconfigurable) console produces?  ie VT100-type sequences like 
    ^[[A for up and ^[[B for down etc.
    Things like :
      Control-[[A:   previous-history         , or
      Meta-[A:       previous-history
    in my .inputrc aren't working.
 
I don't have international mailing privs to reply to you from here, but I
will summarize to the net if anyone wants me to.
 
Thanks hugely for any help.
,-------------------------+---------------------------------------n------.
| "There's nothing quite  | Martin Dougiamas.                ,-\_/ \     |
|  so fun as a good,      | SDOUGIAMA at cc.curtin.edu.au      /  |    \    |
|  solid poke in the eye  | Curtin University               \  |_   /    |
|  with a pencil."  o.x   | Perth, Western Australia. ---->  x-' `_'     |
`===================\_/===+=======================================V======'



More information about the Comp.unix.shell mailing list