After reading this message on the textmate-users mailing list, I decided to have a go at writing a command to add comment chars to the ends of lines. Here’s what I ended up with:

To use it, create a command in TextMate’s bundle editor, then make a new command, and set the input and output dropdowns to look like this:

Finally, set up scope selections (e.g. source.python, source.shell, …), and a key binding if you want one.