Jump to content

Bash tab-completion


Recommended Posts

An annoying thing I'm finding:

When I use <TAB> to complete the name of a file with ';, :, (, or )', the backslashes to tell it to interpret those literally go away. Then I have to go back to those and manually enter them in, even if I had already done that before I hit <TAB>.

 

Example:

andrew:andrew$ cat file\ (12\:
[HITS TAB]
file (12:1-1)  file (12:1-2)
andrew:andrew$ cat file (12:1-

Anyone know how to fix this?

Link to comment
Share on other sites

I don't think there is a way to correct this. There are actually two thing going on here. One is the tab completion, but the second is that you have not entered enough information to make a unique completion. Therefore, bash is giving you a list of all files that match the pattern that you have listed and then refilling in what you already typed.

 

If you do tab completion on a filename that is unique, and type enough that bash can make a unique match, then you should see the backslashes remain in what you typed.

 

My guess is that, in your case, another program is stepping in to help the tab complete and it does not reprint the backslashes on screen after it has listed all files that match what you typed.

Link to comment
Share on other sites

An annoying thing I'm finding:

When I use <TAB> to complete the name of a file with ';, :, (, or )', the backslashes to tell it to interpret those literally go away.  Then I have to go back to those and manually enter them in, even if I had already done that before I hit <TAB>.

 

Example:

andrew:andrew$ cat file\ (12\:<!--QuoteEBegin-->[HITS TAB]<!--QuoteEBegin-->file (12:1-1)  file (12:1-2)<!--QuoteEBegin-->andrew:andrew$ cat file (12:1-

Anyone know how to fix this?

You have to files with just the last letter different, how is bash's tab completion suppose to know which one you want?

 

try renaming one of the files to zz12:1-1 and then hit tab to complete it.

Link to comment
Share on other sites

OK, this is fairly ridiculous. My hypothetical example (apparently badly picked) is being picked apart, completely missing the point. Let's just assume that happened with two files with completely different names. Hell, let's just assume there's one file in the directory.

andrew:andrew$ cat file\ \(12\:
[HITS TAB]
andrew:andrew$ cat file\ (12:1-1)

So... POINT IS that whatever is in the directory, when I hit tab-completion, it doesn't act normally. With that in mind, does anyone have any ideas?

Link to comment
Share on other sites

OK, this is fairly ridiculous.  My hypothetical example (apparently badly picked) is being picked apart, completely missing the point.  Let's just assume that happened with two files with completely different names.  Hell, let's just assume there's one file in the directory.

andrew:andrew$ cat file\ \(12\:<!--QuoteEBegin-->[HITS TAB]<!--QuoteEBegin-->andrew:andrew$ cat file\ (12:1-1)

So... POINT IS that whatever is in the directory, when I hit tab-completion, it doesn't act normally.  With that in mind, does anyone have any ideas?

[thinkliberty@localhost tester]$ echo sfasgasgasaaf > "the (file :1-2)"

[thinkliberty@localhost tester]$ ls

the (file :1-2)

[thinkliberty@localhost tester]$ cat t

<I hit tab here>

[thinkliberty@localhost tester]$ cat the\ \(file\ \:1-2\)

sfasgasgasaaf

[thinkliberty@localhost tester]$cp the\ \(file\ \:1-2\) the\ \(file\ \:1-2\)~

[thinkliberty@localhost tester]$ cat the\ \(file\

<I hit tab here>

the (file :1-2) the (file :1-2)~

[thinkliberty@localhost tester]$ cat the\ \(file\ \:1-2\)

 

I don't seem to have the same problem?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...