Here is one possible workflow that I use often.
I use a terminal emulator that supports HTML-like explicit hyperlinks (OSC 8 escape sequence). There are quite a few such terminal emulators out there.
I have set up an alias
from ls
to ls --hyperlink=auto
(and some other options as well that are irrelevant here). Note that it's ls
from GNU coreutils
, the default on most Linux systems, which has this command line option.
I issue the ls
command to print the given filename. I could narrow down the listing using wildcards, or list the desired filename only (with the aid of tab completion). Or I can simply list the entire directory. Or if I know that it's one of the newest files in the directory then ls -ltr
and it'll be at the end of the listing, I don't have to recall its name. Whichever feels the most convenient, or whichever I feel like typing at that very moment.
Then I Ctrl+click on the printed link (some terminal emulators might need a different action to open the link), which opens the file in its default handler application.
This way I don't need to remember the name of the default application (whether it's evince
or whatever else), don't need to type that, nor type something generic like xdg-open
or something overly long such as gapplication launch org.gnome.Evince
shown in a comment above.
My PDFs and similar files often contain special characters (e.g. spaces) in their names, it's somewhat out of my control (I download many of them from the web or receive via other sources such as email, and I can't be bothered to rename them all to contain easy-to-use characters only). This method handles such characters safely, I don't need to fiddle with quoting or escaping.
The default application is launched externally to the terminal session, that is, the app's standard output or error won't appear and won't clutter my terminal session.
An obvious drawback is that it launches the default application for the given file type, I cannot pick one-off exceptions. (Theoretically there might be a terminal emulator out there which offers to pick a different application, e.g. in its right click menu. I don't know if there any.) If I need to open with a different application, I resort to more standard methods.
I personally love this method and find it super fast and convenient. Your mileage may vary. Give it a try and see if you like it or not.