Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!uniwa!cc.curtin.edu.au!sdougiama From: sdougiama@cc.curtin.edu.au Newsgroups: comp.unix.shell Subject: Variables and keybinding in bash Message-ID: <1991May31.114454.8523@cc.curtin.edu.au> Date: 31 May 91 03:44:54 GMT Organization: Curtin University of Technology Lines: 60 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@cc.curtin.edu.au / | \ | | solid poke in the eye | Curtin University \ |_ / | | with a pencil." o.x | Perth, Western Australia. ----> x-' `_' | `===================\_/===+=======================================V======'