Editing (or running) file(s) regardless of current directory. [Cli tip]
from GustavoM@lemmy.world to linux@lemmy.ml on 17 Jun 2024 19:07
https://lemmy.world/post/16637191

tl;dr

Editing;

$photoortexteditoryoulike $(find / -iname incompletefilenam*)

Running;

exec $(find / -iname incompletepackagenam*)

Interacting (copying, moving, etc);

$desiredinteraction $(find / -iname desiredfileorpackag*) /desired/output/directory

It may be a “not-so-attractive” tip for most of you, but I find it really useful when I want to edit a specific file (that is located alongside several ones, like a picture or a text file). Or when I’ve finished compiling something and I want to find the binary file asap. Saves me lots of time on really slow pcs (like a rpi zero).

#linux

threaded - newest

evanstucker@lemmy.ml on 17 Jun 2024 19:12 next collapse

Why not use bash-completion? The running example you gave is dangerous - you could end up running one or more of the wrong executables.

andrew_s@piefed.social on 17 Jun 2024 19:22 next collapse

I wouldn't do this personally, but if I did, I think I'd at least pipe the results to head -n 1 to only act on the first result.

CsXGF8uzUAOh6fqV@lemmy.world on 17 Jun 2024 21:44 collapse

What about FZF? For example, I want to play a video file without digging through my files, I type fflpay and press ctrl-t which opens a fzf fuzzy finder. Type the incomplete name and select it. I would suggest this at least for the second example as running the wrong executable may get you in trouble. This is on the fish shell but I think other shells have similar possibilities. I also use this ctrl-t thing in combination with nvim or even cd.