1

Edit: Using bash.

I am in a directory that has several files in it. As a quicker method than typing it out, I would like to get one of those file names to "type itself" on the command line.

So far, my command is

mv

I would now like to "select" a file name to "populate" onto the command line.

whitelightning
  • 469
  • 10
  • 23
  • 1
    Hit `Tab` twice. and your shell ( to find out `echo $SHELL` or `getent passwd $USER | cut -d: -f7`) will show you your choices. – waltinator Feb 21 '19 at 16:24
  • 1
    It now lists each file on a separate line below the line where I typed the command. But, how do I get one to populate on the command line (besides highlight and copy). – whitelightning Feb 21 '19 at 16:30
  • 3
    You should type the first few characters of the filename, and hit `Tab` again. If what you typed uniquely specifies 1 file, that filename will be filled in, if not, you'll see another list. – waltinator Feb 21 '19 at 16:33
  • I don't know of a shell that does that by default, you can do it with `dialog` (eg [this](https://unix.stackexchange.com/a/239632/60747)). Or perhaps use something like `mc`, select file with cursors and then F6 to move/rename. – pbhj Feb 21 '19 at 16:42
  • Fwiw, it's a pretty common [idea](https://unix.stackexchange.com/questions/44471/display-a-menu-of-files-names-and-let-the-user-select-a-file-by-entering-a-numbe). – pbhj Feb 21 '19 at 17:01
  • @waltinator that works. Do you want to put that as an answer and I will mark as accepted? – whitelightning Feb 21 '19 at 17:26
  • 1
    Related: [Select a particular result from completion suggestions](https://askubuntu.com/questions/707202/select-a-particular-result-from-completion-suggestions) – steeldriver Feb 21 '19 at 18:11

1 Answers1

0

Hit Tab twice. and your shell ( to find out echo $SHELL or getent passwd $USER | cut -d: -f7) will show you your choices.

Then, type the first few characters of the filename, and hit Tab again. If what you typed uniquely specifies 1 file, that filename will be filled in, if not, you'll see another list.

waltinator
  • 35,099
  • 19
  • 57
  • 93