I am often inadvertently trying to open incomplete filenames with xdg-open, because of the presence of several files with the same basename but different extensions, e.g. very-long-filename.tex, very-long-filename.pdf etc. Using autocomplete in terminal gives me
xdg-open very-long-filename.
and I hit return before checking the name is complete. Instead of an error, this launches my web browser and attempts to open the URL http://very-long-filename./, which is a nuisance.
I never use xdg-open to open URLs from terminal. Is it possible to block xdg-open from opening URLs from terminal if they don't explicitly contain http:// or https:// (or at all), without compromising other URL-opening strategies used by the OS (Ubuntu/Kubuntu)?
I looked at xdg-settings and xdg-mime but the doc is not very exhaustive and it's not obvious to me that this can be achieved. It's not clear why xdg-open defaults to opening anything that is not a filename as a URL, and what kind of mime-type this is.
~/.config/mimeapps.listthat might be tied to not having an extension to default to web browser. Maybe try renaming the file and try again. – Terrance Oct 24 '23 at 02:25xdg-mime query filetype very-long-filename.would tell us something? – steeldriver Oct 24 '23 at 17:44mimeapps.listdidn't help (it attempted to open as an URL in Chrome rather than in Firefox)... @steeldriver: the error message isxdg-mime: file 'very-long-filename.' does not exist. That's part of the problem, I don't see in mime anything that is not a file or not specific. E.g. I seex-scheme-handler/httpwhich is handled byfirefox, but why would this be followed without mentioninghttpin the argument ofxdg-open? – armando.sano Oct 25 '23 at 08:12xdg-openpossibly. I guess you can try filing a bug against it by runningubuntu-bug xdg-openor maybe try reinstalling thexdg-utils;sudo apt install --reinstall xdg-utils– Terrance Oct 25 '23 at 13:34kde-open. Does it occur on a live Ubuntu too? Reinstallingxdg-utilsdoesn't help either. I'll file a bug atxdg-utils, though it might be a feature rather than a bug. Thanks again for your help. – armando.sano Oct 27 '23 at 07:41