'Can I get bash completion to consider the text _after_ the cursor?

Motivating example:

I'm in a shell session in some directory, and I have three files: prefix_foo_suffix.txt, prefix_bar_suffix.txt and prefix_bar_another_suffix.txt. I've typed in: cat prefix_foo_suffix.txt, but I've changed my mind, I want the second file. So, I delete foo, and write b - only to realize I'veforgotten the name of that second file. So now my command-line is cat prefix_b_suffix.txt with the cursor after the b.

Now, if I press Tab, completion kicks in, but it gives me: prefix_bar_suffix.txt_suffix.txt which is not what I wanted.

Is it possible to get bash to consider the rest of the current word, or line, for completion? i.e. complete intra-word substrings to reach a relevant word?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source