Wednesday, April 24, 2024
 Popular · Latest · Hot · Upcoming
101
rated 0 times [  101] [ 0]  / answers: 1 / hits: 36575  / 2 Years ago, mon, december 13, 2021, 12:05:22

I want to be able to open files like my operating system does from console.



e.g. a .pdf file should be opened with evince or whatever the default application to open pdfs is. All the other things should work too; images -> eog, text files -> gedit and so on.



I hope that there is a solution for this, it would be really practical.


More From » files

 Answers
6

xdg-open — opens a file or URL in the user's preferred application




But what if you want to change the preferred application from the terminal?



Try this



You can use the xdg-mime program to first check which is the current default application that will open a file and then you can switch it to what ever application you want.



$ xdg-mime query default application/pdf
AdobeReader.desktop
$ xdg-mime default evince.desktop application/pdf
$ xdg-mime query default application/pdf
evince.desktop


Now as mentioned by jokerdino you can use xdg-open to open a file with your preferred application:



$ xdg-open file.pdf

[#37179] Monday, December 13, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
afyess

Total Points: 437
Total Questions: 120
Total Answers: 107

Location: San Marino
Member since Fri, Jul 3, 2020
4 Years ago
afyess questions
;