Other Selecting a file without typing its filename when in terminal

I have some folders or files that are in Greek. How can i select them via lets say commands cd, mpv, vim etc without referencing them by name? This is a basic problem, i know i could install Greek, but the same holds for Chinese, or whatever character set you happen to stumble upon a server for example. Can i select the fist file in the folder by unicode categorization, the third file in size, the fifth file as listed in ls command output etc? Its a general question mostly, not about my specifics. Thanks.
PS: Autocomplete only helps when you type some characters first, but if you dont have installed lets say Japanese you can't do that.
I
 
You can use the position of the file in the output of ls. For instance, if the file is shown in the 14th position, do:
Bash:
vim "$(ls | awk 'NR == 14 {print; exit}')"
to edit the file in vim.

You can use:
Bash:
ls | less -n
to find out the position previously.

You can use "$(ls | awk 'NR == 14 {print; exit}')" in lieu of the filename in any command.
 
[…] select the […] file in the folder […]
Like cracauer@ suggested, try file managers such as misc/mc. Pressing some key combo inserts the path names of currently highlighted files to the command line editor.​
[…] Autocomplete only helps when you type some characters first, […]
Type ./ and then tab. Some shells (e. g. shells/zsh) even permit tabbing pathnames after the first word without having typed anything, granted there is no contradictory completion rule.

If you have a mouse, you can highlight the filename displayed on screen and then press the middle mouse button (mouse wheel) to paste the contents of the (primary) clipboard buffer. It usually works out‑of‑the box in X11, see moused(8)/rc.conf(5) for the vt(4) console.​
You could write a shell script that takes inode number as arg and returns name.
Or is there a command for that?
Yes, find(1) has the non‑standardized ‑inum extension:​
Bash:
find ./ -inum 1152996   # and -maxdepth 1, or some “quit” after first match, I don’t know
[…] How can i select them […] without referencing them by name? […]
This is not possible, the system calls like open(2) etc. require a pathname, a string. You cannot open(2) a file without knowing (one of) its pathname(s). (Well, not entirely true, if you’re programming a program, fhopen(2), but that’s not really an option in the terminal.)​
 
Have you tried fzf ? just run it in the directory will produce quick list

sh:
$ cd $( find . -type d | fzf)
$ nvim $( find . -type f | fzf)

also highly recommend shells/fish - autosuggest by fuzzyfind any part of the file, eg
$ cd /u/l/etc <tab> will go to /usr/local/etc
$ touch mysuperfile-123-extention; vim 123<tab> will autocomplete filename in any known to me languages

and try misc/lf and sysutils/py-ranger and imho too heavy sysutils/yazi
 
It seems that the most realistic solution is the file manager, although I would always trend to trick with some commands.

Since I think that a file manager in some situation could be useful, I have 4 installed:

1) rox-filer
2) ytree
3) nnn
4) dired (belongs to emacs that I always install)

The only one I really used is the graphic one, rox-filer, and only few times, to see thumbnails of image files.
 
fzf is quite bloated, but there is a meager package pick-4.0.0_1 that I just installed tested a little.

It reads from stdin white space separated options, offers a ncurses menu, throws the selection to stdout.

You can do thinks like find . -type f | pick | xargs xdg-open or just ls | pick | xargs emacs

Other solution: bash and ksh have a "select" command, you can do things like:
select a in `ls`; do echo $a; break; done
 
There is other interesting meager program in packages by the same author of pick: yank.
It allows to select fields according to a regexp.
I made for example the following script file pssel containing: ps | yank -g '^[0-9]+' -- xargs $*

Then, for selecting and killing a process, I can do: pssel kill or pssel kill -9
 
Back
Top