Similar command of "open"

I wanna know if I can open any file in default…
for ex:

  • open example.txt (Kate)
  • open example.pdf (Okular)

Clicking on a file will normally open said file in the appropriate application, depending on what flavor of desktop you are using. This is made possible by way of the xdg-open framework, which will look at what application any given file type is associated with.

You can use xdg-open as a generic command, but there’s a lot more overhead involved in that than when you simply pass the file to the correct command yourself, as in for example… :arrow_down:

kate example.txt


1 Like
xdg-open <filename>

It works with qpdf as mime for pdf files - at least on my Openbox system

1 Like


Beware of how you intend to use it: since it uses the association between a MIME type and (usually) a graphical application, it may not be appropriate for CLI specific scripts.

1 Like

I tried to do alias… but it’s doesn’t work, can u tell me reason?
alias xdg-open=open

the open command is a built-in for the shell - that won’t do.

just use xdg-open

1 Like

Okay, it’s not a problem. Style short cmd so… :slightly_smiling_face:

You can create an alias - I just realized you had reversed the arguments

alias open='xdg-open'

and my synapses wrongly associated the keyword open with read - as in read a file.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.