This question already has an answer here:
- Why doesn't my bash prompt update? 2 answers
I have a very simple ps1 script in my .bashrc file, this excutes a random script generator called blah.
export PS1="\[$(tput bold)\]\[$(tput setaf 1)\]\\$ \[$(tput sgr0)\] $PWD :: **$(. blah)** ::"
the blah script simply should export a random string each time in the shell....
function silly {
local RANDOMQUOTE=$[ ($RANDOM % 10 ) ] local fooey=('rand1' 'rand2' 'rand3' 'rand4' 'rand5');
echo ${fooey[RANDOMQUOTE]}
}
silly
However it seems this script is only excuted each time I create a new window in iterm, and of course this means the script is no longer random!
Example of the random function not being called each time:
$ /Users/username :: rand2 ::
$ /Users/username :: rand2 ::
$ /Users/username :: rand2 ::
$ /Users/username :: rand2 ::
Am I doing something wrong here? Just starting to learn bash so apologies for lack of terminology, edit at will!
As said in Single/double quotes ksh:
So change
for
That is,
PS1='<code>'
instead ofPS1="<code>"
.