Sample Header Ad - 728x90

Is it possible to tab complete by whole word in Bash

4 votes
0 answers
118 views
Suppose I have filenames as follows on my Linux system:
$ ls -1
file-index-00012.txt
file-index-00345.txt
question.txt
I start typing, where "|" represents the cursor:
$ cat fil|
If I press tab once, Bash partially completes filenames:
$ cat file-index-00|
If I press tab twice more, it shows candidate filenames:
$ cat file-index-00
file-index-00012.txt  file-index-00345.txt
$ cat file-index-00|
The problem with this is that I have to check how many digits have been partially completed, before entering the remaining ones. For example, the first time I get a "file-index-01000.txt" in this directory, I have to enter an additional digit:
$ cat file-index-0
file-index-00012.txt  file-index-00345.txt  file-index-01000.txt  
$ cat file-index-0|
Is it possible to make Bash stop completing at the start of the word (separated by hyphen, underscore or whitespace) like this:
$ cat file-index-
file-index-00012.txt  file-index-00345.txt
$ cat file-index-|
Asked by Huw Walters (151 rep)
Dec 28, 2024, 04:36 PM
Last activity: Dec 28, 2024, 06:20 PM