Hello!
I am really new in shell scripting and knowing other languages as Java or C# I have been googling for an answer of the question I about to ask but I found no one. This is because I ask it here,

.
My OS is Ubuntu 8.10 (Intrepid). Using Gnome.
GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
I am customizing the file bash.bashrc in order to feel the Gnome terminal a little bit more homely. My aim now, after have changed colors and added needless stuff is to make more dynamic the actual path:
As normal, when I am in my home folder I see:
[ ~ ] $ instead of
[ /home/username ] $
That is fine, but I want to go further and abbreviate other folders, such as my workspace:
[ + ] $ instead of
[ /home/username/drive/external/workspace ] $
I have found a pretty useful code for doing that:
Code:
PROMPT_COMMAND='DIR=`pwd|sed -e "s!$HOME/drive/external/workspace!+!" | sed -e "s!$HOME!~!"`;CurDir=$DIR;'
PS1="${BLUE}${RED}${debian_chroot:+$debian_chroot}\[\033[0;38;5;32m\][\[\033[0;38;5;202m\] \$CurDir \[\033[0;38;5;32m\]]${RED}\$ ${NC} "
I can not say that I understand everything, probably that is the main problem

, but I know the comand "sed -e" and obviously "s!$HOME!~!" change the home folder for ~ in some way. But,
it is case sensitive.
So, if I type "cd ~
/drive/external/WorKsPACe", it does not work.
I have found some interesting functions which transform strings, for example:
Code:
$VAR_NAME | tr '[:upper:]' '[:lower:]'
But I guess the structure "
s!$HOME/drive/external/workspace!+!" do not let me use it because it do not use variables for the substitution.
Do you know what can I do?
Thank you.