On 2012-02-13, Mihamina Rakotomandimby wrote:
> Hi all,
>
> Running Bash 4.2.20, I would like to have a prompt composed by the first
> letters of the base path, excluding the last one.
>
>
> Example:
> - /u/l/bin if I'm in /usr/local/bin
> - /v/w/h/my-website if I'm in /var/www/html/my-website
> - /h/mihamina if I'm in /home/mihamina
PROMPT_COMMAND='PS1=$(IFS=/ read -a x <<< "$PWD"
for d in "${x[@]}"
do
[ -n "$d" ] && pwd=$pwd/${d:0:1}
done
echo "$pwd${PWD##*/?}")\ \\$\ '
--
Chris F.A. Johnson <
http://cfajohnson.com>
Author: =======================
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)