psql's tab completion mode can be extremely useful. It's also seriously annoying if you're cutting and pasting.
It would be nice if you could turn it off, but it's under the control of the readline library, which, as far as I can tell in a few minutes' googling, doesn't provide a way to toggle it via an API. The only way I can see to switch it is via the .inputrc file.
The psql manual advises that if you want to turn it off, you can put this in your ~/.inputrc file:
$if psql
set disable-completion on
$endif
But the trouble with that is that it turns it off all the time. However, you can tell readline to use an alternative file, via the environment variable INPUTRC. So I created a little file called ~/.inputrc-nocompletion containing the "set" line above, and then this worked:
INPUTRC=~/.inputrc-nocompletion psql andrew
and lo and behold, no completion just for that session. But that's a pain in the neck to have to type. To the rescue: bash's alias facility. I set up this alias:
alias npsql="INPUTRC=~/.inputrc-nocompletion psql"
So now, if i use the command npsql, I get tab completion turned off, and if I use the normal psql command it's on. It's not perfect (perfect would be if I could use a psql \ command to toggle it), but it's better than nothing.