Re: bash prompt update lagging
On 16/11/09 Polytropon said: Your PS1 seems to include ${SHORT_PWD}, a variable. It seems that it is not updated immediately after the cd command. Yeah, looks like it. Works on linux though... By the way, this is bash-3.2.25 on FreeBSD/x86 7. bash-4.0.33_2 on x86 6.3. Is this what you've intended the prompt to look like? I'm using an awk script to truncate any pwd that's too long. get_short_pwd() { # The actual max length is max_len + the length of trunc_symbol local max_length=$1 local trunc_symbol=... if [ -z $max_length ]; then max_length=20 fi if [ $PWD != $OLDPWD ]; then SHORT_PWD=$(awk BEGIN { path = ENVIRON[\PWD\] home = ENVIRON[\HOME\] home_len = length(home) max_len = $max_length sym_len = length(\$trunc_symbol\) if(substr(path, 0, home_len) == home) { path = sprintf(\~%s\, substr(path, home_len + 1)) } path_len = length(path) if (path_len max_len) { path = sprintf(\%s%s\, \$trunc_symbol\, substr(path, path_len + sym_len - max_len + 1)) } print path }) OLDPWD=${PWD} fi } This is called via a build_prompt() function in my .bashrc. I guess I'll echo out some variables there and see what's happening. FTR this did work, and then I updated bash in ports. Mike -- Michael P. Soulier msoul...@digitaltorque.ca Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. --Albert Einstein pgpdlhbrLLnoE.pgp Description: PGP signature
Re: bash prompt update lagging
On Sun, 15 Nov 2009 18:14:25 -0500, Michael P. Soulier msoul...@digitaltorque.ca wrote: \[\033[1;32m\]\[\033[0;36m\]\u\[\033[1;32...@\[\033[0;36m\]\h\[\033[1;32m\]:\[\033[0;37m\]${SHORT_PWD}\[\033[1;32m\]$\[\033[0;37m\] I'm wondering if this is a bash bug on bsd, or if I'm doing something wrong. Your PS1 seems to include ${SHORT_PWD}, a variable. It seems that it is not updated immediately after the cd command. Has anyone seen this? No. I don't have any path information at all when I use your PS1. p...@r55:$ By the way, this is bash-3.2.25 on FreeBSD/x86 7. But I tried to replace the ${SHORT_PWD} by the \w control sequence (as mentioned in man bash). This is the result: $ export PS1=\[\033[1;32m\]\[\033[0;36m\]\u\[\033[1;32...@\[\033[0;36m\]\h\[\033[1;32m\]:\[\033[0;37m\]\w\[\033[1;32m\]$\[\033[0;37m\] p...@r55:~$ cd /etc p...@r55:/etc$ cd /usr/src/sys p...@r55:/usr/src/sys$ And the \W short form: p...@r55:/usr/src/sys$ export PS1=\[\033[1;32m\]\[\033[0;36m\]\u\[\033[1;32...@\[\033[0;36m\]\h\[\033[1;32m\]:\[\033[0;37m\]\w\[\033[1;32m\]$\[\033[0;37m\] p...@r55:sys$ cd /bin p...@r55:bin$ cd /usr/local p...@r55:local$ The username and hostname are cyan, @, : and $ are bright green. Is this what you've intended the prompt to look like? -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org