Autocomplete file and folder names in Bash in upper or lower case.

Those of us who make daily use of the terminal, as I said on another occasion, always look for a way to make work with this tool flow easily and as comfortably as possible. What I bring you this time, is an option that comes by default in FreeNAS and that I liked it so much, that I had to put it on me Debian.

Suppose we open the terminal, and we are going to enter the folder Documents. If we put:

$ cd docu

And we press the tab to autocomplete, nothing happens, because the folder is not called documentsBut Documents. And so this is where the magic comes in. We create the file ~ / .inputrc:

$ touch ~/.inputrc

We open it with our favorite text editor and put this inside:

set completion-ignore-case on

We save, close and reopen a terminal. Now when we put:

$ cd docu

And we press Tab, it will automatically change to the name with capital letters and it will put us

$ cd Documentos

What do you think? This tips was taught to me by a friend named Matthias apitz.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Claudio Concepcion placeholder image said

    Very good contribution. He did not know that it was possible to do that.

  2.   KZKG ^ Gaara said

    Definitely interesting 😀

  3.   Mauritius said

    Excellent. These are one of those tips that increases productivity. Very good.

  4.   proper said

    Remarkable! Too good the elav tip.

    1.    elav <° Linux said

      I think so Proper, since I saw this function in FreeNAS, I did not hesitate to look for it because it is truly useful.

  5.   Gregory Swords said

    I loved! I didn't know that trick, thank you!

  6.   oberost said

    Very useful, Good

  7.   Algave said

    I have tried it in Fedora but it does not work for me and without the file ~ / .inputrc I pose Doc and it autocompletes me (as in IRC) Documents but still thanks 😀

    1.    elav <° Linux said

      It would be interesting to see the bash configuration file in FedoraMaybe it already comes with this option by default.

      1.    Linux user (@taregon) said

        Ah! So FreeNas ... you're going to have to confess what other things you saw on that system. One day I was seeing that those who sell already have an integrated system for their administration, such as: Seagate Black Armor or QNAP NAS that I really liked the characteristics exposed on their page, but Freenas .. Let's see the video, tell me the virtues that you noticed. 😉

        1.    elav <° Linux said

          First of all, it is FreeBSD. 😀

  8.   ux said

    teacher

  9.   sieg84 said

    I'll put into practice

  10.   Erick Perez Esquivel said

    brilliant

  11.   msx said

    GO-NA-ZO! I did not know, this trick!
    Since you are talking about FreeNAS, do you know OpenMediaVault? It is a similar solution with a slightly friendlier interface than FreeNAS and the best of all is that it is a true Debian GNU / Linux, that is, you can use the solution as a NAS or log in to the system and do # apt-get update && apt -get upgrade && apt-get dist-upgrade to be continuously updated since in addition to using the official Debian repos, it adds its own for its packages.

    OpenMediaVault Distrowatch Review: http://distrowatch.com/weekly.php?issue=20120423#feature

    1.    elav <° Linux said

      : O I didn't know him .. Right now I'm checking, thanks ...

  12.   Christopher said

    Thanks, but how do I put the $ PS1 with the time as you have it in your terminal?

  13.   Diego said

    Fortunately, they don't charge for these great tips.

    1.    Linux user (@taregon) said

      Good thing that didn't happen. this is an exceptional tip. Maybe I would never have known it existed if I didn't visit the page ...

    2.    KZKG ^ Gaara said

      Who said not? … Come on, pay a few hundred €… HAHAHAHAHAHA 😀 😀 😀

      1.    Diego said

        You'll be the only idiot who's already paid.

  14.   truko22 said

    Very useful, thank you very much 😀

  15.   faustod said

    This is a marvel, it should be installed by default 10 out of 10.

  16.   Maxi3390 said

    Simply GREAT 😀

    1.    Maxi3390 said

      With the modification in that file it no longer lets me move between "separators" (I don't know how to call them haha) with the control + left / right key combination. Can it be solved by adding something to it?
      Greetings and thanks!

      1.    Maxi3390 said

        I already solved it, it is with the first 2 lines of my .inputrc that I leave below 😉
        The "\ t": menu-complete is for you to cyclically autocomplete with TAB
        And the one below is explained with the comment it brings.


        "\e[1;5C": forward-word
        "\e[1;5D": backward-word
        "\t": menu-complete
        set completion-ignore-case on
        # Don't echo ^C etc (new in bash 4.1)
        # Note this only works for the command line itself,
        # not if already running a command.
        set echo-control-characters off

        Regards!

  17.   switcher said

    Something complementary to this (besides being quite useful) is the ignore uppercase and lowercase in pattern searches. For example, if files are listed with ls a B C, by default it does not take into account the files that match ABC.
    Just add the following in .bashrc:
    shopt -s nocaseglob
    Or this line in .zshrc (for those who use zsh):
    unsetopt CASE_GLOB