[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: run command via ps/bash prompt



On 3/9/06, Joe Szilagyi <js axxs net> wrote:
> Hi,
>
> Have something I have tried to get working, unsuccessfully:
>
> PS1="\n\[`cat $HOME/file.txt`\] \n \@ \u \h \w $ "
>
> Basically, wanting the bash prompt to always execute a command. It does not
> update, unless bashrc is updated with source .bashrc. Is there any way
> around this directly in the PS1 settings? If not, I saw more complex ways to
> do similar things by defining functions, but was curious if there was a more
> basic way to do this.

you have to quote the `cat ` otherwise it is executed when you define
PS1.  Something like

   PS1="\n\[\`cat $HOME/file.txt\`\]\n \@ \u \h \w $ "

Should do the trick.

NB $HOME is also evaluated at the point where you define PS1. 
Although probably unnecessary, you could delay that by using \$HOME
instead of just $HOME.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]