Announcement

Collapse
No announcement yet.

Command-line tab ignoring slashes

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Command-line tab ignoring slashes

    Before updating my system 2 days ago, using tab for file-name completion in a Konsole advanced to the end of a directory name and added the slash. E.g., if I typed out to

    cd ~/jon-pic

    and hit tab, it completed the line to

    cd ~/jon-pictures/

    with the cursor just after the slash. This is handy, as you can then go on typing the name of the next file or directory in the tree. Now however, doing the same thing goes to

    cd ~/jon-pictures

    with no slash and a blank after the directory name. This is a pain. Is this something planned or a (I hope temporary) bug?
    'I must have a prodigious quantity of mind; it takes me as much as a week sometimes to make it up.' Mark Twain

    #2
    What is the output of
    Code:
    apt-cache policy bash bash-completion
    Also, Launchpad bug 769866 might be of interest to you.

    Comment


      #3
      This is the behaviour of bash if the readline variable "mark-directories" is set to off.

      You can display your current value via
      Code:
      bind -V | grep mark-dir
      (there might be an easier way).

      If it's 'off' that's your problem, and I would search ~/.inputrc, /etc/inputrc and any other such files for a line set mark-directories off and change it to on.

      If it's not this, then it will most likely be something to do with the bash completion rules, discussed at length in the bug SR referred to. Does the same problem occur with all commands, or just cd and some others?
      Last edited by SecretCode; Apr 20, 2012, 02:17 AM.
      I'd rather be locked out than locked in.

      Comment


        #4
        Well, that's where I was headed, but in a default *buntu install, there's no ~/.inputrc and /etc/inputrc doesn't contain a mark-directories line, meaning the default behavior ("on") should be working.

        Comment


          #5
          Thanks, guys. I cannot find anywhere where bash-completion is set to off. Strangely enough, when I went back to look, it had started working like I wanted and I got this:


          $ bind -V | grep mark-dir
          mark-directories is set to `on'

          Next time it happens "wrong", I'll check on what you have recommended. Much thanks.
          'I must have a prodigious quantity of mind; it takes me as much as a week sometimes to make it up.' Mark Twain

          Comment


            #6
            Originally posted by joneall View Post
            it had started working
            Was it working with cd? Was it working with a range of different commands? If mark-directories is on as a general setting, the most likely culprit is a command-specific bash completion rule, as Mr Riley was thinking.

            (bash completion allows different kinds of completion for different commands so if one command expects a filename, or a directory name only, or a shell variable, in a certain position completion can be limited to those name-spaces. The rules, imho, can be pretty complicated.)
            I'd rather be locked out than locked in.

            Comment


              #7
              Can I put something in my .bashrc to enable this?
              'I must have a prodigious quantity of mind; it takes me as much as a week sometimes to make it up.' Mark Twain

              Comment


                #8
                Now that it's working for you again, you don't need to put anything in your .bashrc. Actually, [Tab] completion should be working for more than just subdirectories. For example, try
                Code:
                apt-get dist-[b][Tab][/b]
                Did the command complete itself for you?

                Comment


                  #9
                  Ok for commands and cd, not for ls

                  Actually, I know k-shell much better than bash, so all this completion stuff is, as one of you said, pretty complicated.

                  This morning, I looked more closely and the completion is working for the "cd" command but not for "ls". Command completion works too:

                  mogr[TAB] gives mogrify.

                  I have looked at the bash documentation at http://www.gnu.org/software/bash/manual/bashref.html and the completion stuff is indeed quite messy. There is something simpler at

                  http://www.debian-administration.org/articles/316

                  which I will look into. More later...
                  'I must have a prodigious quantity of mind; it takes me as much as a week sometimes to make it up.' Mark Twain

                  Comment


                    #10
                    Originally posted by joneall View Post
                    This morning, I looked more closely and the completion is working for the "cd" command but not for "ls".
                    Do you mean with ls completion is not working at all? Or just not including the trailing slash for directories?
                    I'd rather be locked out than locked in.

                    Comment


                      #11
                      Originally posted by SecretCode View Post
                      Do you mean with ls completion is not working at all? Or just not including the trailing slash for directories?
                      If I do ls with the beginning of a directory name, it completes the name and adds a blank, not a slash.
                      'I must have a prodigious quantity of mind; it takes me as much as a week sometimes to make it up.' Mark Twain

                      Comment

                      Working...
                      X