0

I am on mac os and using default terminal, i.e. Bash. I am quite new to command line and simply trying things out. For now, I am simply trying to cd into a directory and play a mp3 file there. I cd'ed into the directory with the help of auto-complete. Pressing tab would fill up the names matching the letters I had entered so far. But, after the reaching the directory, I noticed that I could not use autocomplete to launch the file.

The name of the file is Hello.mp3. So, from the directory, I typed 'h', and then pressed Tab, but that would not add Hello.mp3 to the line.

Could you please tell me how to run Hello.mp3 in my case, and how to leverage auto-complete in the process?

I would like to make sure that I understand auto-complete correctly because it would be very difficult to work with files with long names otherwise.

  • What if you type a capital H? – Jonno Feb 21 '16 at 15:22
  • @Jonno I am getting some really weird behavior. My file is actually called Data.pdf. So, I typed D, and pressed Tab, and that returned with 3 options - DevToolsSecurity, DirectoryService, and DeRez. As per ls, All these 3 are not even in the pwd. – snow and ice Feb 21 '16 at 15:27
  • @Jonno Also, when I enter Data.pdf in the command line, it says Command not found. – snow and ice Feb 21 '16 at 15:30
  • Are you certain you're in the right path? If you type ls you can see it? – Jonno Feb 21 '16 at 15:32
  • 1
    @Jonno I figured it out. It looks to open a file, eg. Data.pdf, you need to type Open Data.pdf. Simple doing Data.pdf does not work. Also, after I type Open, autocompletion works after that. – snow and ice Feb 21 '16 at 15:40
0

From the command line, every line you enter needs to be a command, and commands always start with the name of a program, optionally followed by the arguments. Auto-complete is smart and knows that when you are typing something as the first word in a command, it has to be a program name and will not autocomplete to a filename. That is why you saw program names like DirectoryService when trying to autocomplete after D. open is a program on the Mac which can open programs using the default application depending on the filetype.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.