Custom personal monitor sql by writing the .psqlrc file
Using psql variables with quotes is a bit tricky.  As you noticed, they don't get substituted in certain positions, among other, between quotes.  

My only solution to this so far has been including the quote in the variable itself.  This is also not very straightforward:

test=# \set a 'parrot'
test=# \echo :a
parrot
test=# \set a ''parrot''
test=# \echo :a
parrot
test=# \set a '''parrot'''
test=# \echo :a
'parrot'
test=# \set a ''''parrot''''
test=# \echo :a
'parrot'


and so on.  This is, to my eyes, is basically the same as the quote duplication magic elsewhere (mentioned more than once in the documentation).

The solution I've posted in the comment is basically an ugly version of the three-quote version.

Note that dollar quoting does not work here:

test=# \set a $$'parrot'$$
test=# \echo :a
$$parrot$$
test=# \set a '$$parrot$$'
test=# \echo :a
$$parrot$$