1

I'm not sure how to phrase this correctly but I want to know how in the terminal to do the equivalent of 'ls' when typing out a path.

So for example i'm typing in:

sudo "/Library/Application\ Support/

Now i get stuck, i know if i could see inside 'Application Support' I would know where to go next. However i don't know how to get it out. So i resort to opening a second terminal doing something like 'ls /Library/Application\ Support/' or opening finder and looking in the folder for file/folder i'm looking for.

Is there a way to quickly type a command that will show the contents of where i'm at and leave my current command on screen so I don't need to retype it?

An answer for both Mac & Linux would be appreciated.

1 Answer 1

4

Are you aware of the completion feature is bash which is most probably your shell at both places?

Start typing (without quotation mark)

sudo /Libra

then press TAB. Here either the line is completed to sudo /Library or nothing happened. If the latter, press TAB again and you will see a list of the possible directories/files starting with "Libra"; if you complete the name until the list of possibilities contains 1 element, then the auto-completion takes place.

When you have sudo /Library, continue typing the path you want, and try pressing TAB again, once or twice depending on if what you have already typed is ambiguous or not. And so on...

2
  • Thats exactly what I was looking for thank you. I already knew about the tab to complete but the double tap tab to give the listing of the current directory is bang on what i needed. Thank you very much!
    – Jacob2471
    Commented Apr 28, 2016 at 19:15
  • Very welcome. There are a couple of features around editing the command line which make work faster and more convenient so even if you never read a doc on bash, don't miss looking up its "history" and "readline".
    – user556625
    Commented Apr 28, 2016 at 19:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .