Is there an “open with” command for the command line? The Next CEO of Stack OverflowIs there any way to detect file type and open it with GUI in terminal in Fedora?xdg-open opens a different application to the one specified by xdg-mime queryHow an application is chosen over others to open a particular filetype in LinuxIs there a GNU/Linux equivalent to the Mac OS X open command?How can I find the application for a MIME type on linux?Is there a glibc API that can find the default handing application for a MIME type on linux?Adding bindings for ed2k:// links with xdg-open?How to open any file through the command line?Is there a FreeDesktop command to open an open-with dialog similar to xdg-open?Canonical way to simulate a file manager “open item” from the command lineHow to open a file based on the output of the `file` commandOpen Link (type 2) desktop files from the command lineHow to make xdg-open follow mailcap settings in DebianWhat is the correct way to associate MIME type with applications that have multiple desktop entries?

Is there an analogue of projective spaces for proper schemes?

How to avoid supervisors with prejudiced views?

If a black hole is created from light, can this black hole then move at speed of light?

Contours of a clandestine nature

Unreliable Magic - Is it worth it?

Rotate a column

To not tell, not take, and not want

What benefits would be gained by using human laborers instead of drones in deep sea mining?

What is "(CFMCC)" on an ILS approach chart?

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

How do scammers retract money, while you can’t?

Bold, vivid family

Inappropriate reference requests from Journal reviewers

What exact does MIB represent in SNMP? How is it different from OID?

Is it professional to write unrelated content in an almost-empty email?

How do I make a variable always equal to the result of some calculations?

Why has the US not been more assertive in confronting Russia in recent years?

Complex fractions

Make solar eclipses exceedingly rare, but still have new moons

MessageLevel in QGIS3

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

Is "for causing autism in X" grammatical?

If the heap is initialized for security, then why is the stack uninitialized?

What was the first Unix version to run on a microcomputer?



Is there an “open with” command for the command line?



The Next CEO of Stack OverflowIs there any way to detect file type and open it with GUI in terminal in Fedora?xdg-open opens a different application to the one specified by xdg-mime queryHow an application is chosen over others to open a particular filetype in LinuxIs there a GNU/Linux equivalent to the Mac OS X open command?How can I find the application for a MIME type on linux?Is there a glibc API that can find the default handing application for a MIME type on linux?Adding bindings for ed2k:// links with xdg-open?How to open any file through the command line?Is there a FreeDesktop command to open an open-with dialog similar to xdg-open?Canonical way to simulate a file manager “open item” from the command lineHow to open a file based on the output of the `file` commandOpen Link (type 2) desktop files from the command lineHow to make xdg-open follow mailcap settings in DebianWhat is the correct way to associate MIME type with applications that have multiple desktop entries?










23















Does the command line have a way to get a recommended list of programs used to open a particular file, based on the file type? For example, a .pdf file would have an open with... recommendation using the programs Evince and Document Viewer.



I use the command line for most things, but sometimes I forget the name of a program that I want to use to open a particular type of file.



BTW I am using Ubuntu 13.10.



pro-tip



Thanks to @slm 's selected answer below, I made the following bash script in a file called openwith.sh:



xdg-mime query default $(xdg-mime query filetype $1)


Add as an alias or execute directly as an openwith command. Hope this helps!










share|improve this question



















  • 1





    You can try with gnome-open file. I have added alias o='gnome-open' to my .bashrc for simplicity.

    – Pål GD
    Apr 15 '14 at 8:18












  • gnome-open works similarly to xdg-open.

    – slm
    Apr 15 '14 at 12:44











  • Apparently, so does gvfs-open. Question What can I use instead of gnome-open? from ask ubuntu.

    – Pål GD
    Apr 15 '14 at 13:30















23















Does the command line have a way to get a recommended list of programs used to open a particular file, based on the file type? For example, a .pdf file would have an open with... recommendation using the programs Evince and Document Viewer.



I use the command line for most things, but sometimes I forget the name of a program that I want to use to open a particular type of file.



BTW I am using Ubuntu 13.10.



pro-tip



Thanks to @slm 's selected answer below, I made the following bash script in a file called openwith.sh:



xdg-mime query default $(xdg-mime query filetype $1)


Add as an alias or execute directly as an openwith command. Hope this helps!










share|improve this question



















  • 1





    You can try with gnome-open file. I have added alias o='gnome-open' to my .bashrc for simplicity.

    – Pål GD
    Apr 15 '14 at 8:18












  • gnome-open works similarly to xdg-open.

    – slm
    Apr 15 '14 at 12:44











  • Apparently, so does gvfs-open. Question What can I use instead of gnome-open? from ask ubuntu.

    – Pål GD
    Apr 15 '14 at 13:30













23












23








23


9






Does the command line have a way to get a recommended list of programs used to open a particular file, based on the file type? For example, a .pdf file would have an open with... recommendation using the programs Evince and Document Viewer.



I use the command line for most things, but sometimes I forget the name of a program that I want to use to open a particular type of file.



BTW I am using Ubuntu 13.10.



pro-tip



Thanks to @slm 's selected answer below, I made the following bash script in a file called openwith.sh:



xdg-mime query default $(xdg-mime query filetype $1)


Add as an alias or execute directly as an openwith command. Hope this helps!










share|improve this question
















Does the command line have a way to get a recommended list of programs used to open a particular file, based on the file type? For example, a .pdf file would have an open with... recommendation using the programs Evince and Document Viewer.



I use the command line for most things, but sometimes I forget the name of a program that I want to use to open a particular type of file.



BTW I am using Ubuntu 13.10.



pro-tip



Thanks to @slm 's selected answer below, I made the following bash script in a file called openwith.sh:



xdg-mime query default $(xdg-mime query filetype $1)


Add as an alias or execute directly as an openwith command. Hope this helps!







files desktop-environment mime-types freedesktop file-opening






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Rui F Ribeiro

41.8k1483142




41.8k1483142










asked Apr 15 '14 at 1:16









modulitosmodulitos

1,19262039




1,19262039







  • 1





    You can try with gnome-open file. I have added alias o='gnome-open' to my .bashrc for simplicity.

    – Pål GD
    Apr 15 '14 at 8:18












  • gnome-open works similarly to xdg-open.

    – slm
    Apr 15 '14 at 12:44











  • Apparently, so does gvfs-open. Question What can I use instead of gnome-open? from ask ubuntu.

    – Pål GD
    Apr 15 '14 at 13:30












  • 1





    You can try with gnome-open file. I have added alias o='gnome-open' to my .bashrc for simplicity.

    – Pål GD
    Apr 15 '14 at 8:18












  • gnome-open works similarly to xdg-open.

    – slm
    Apr 15 '14 at 12:44











  • Apparently, so does gvfs-open. Question What can I use instead of gnome-open? from ask ubuntu.

    – Pål GD
    Apr 15 '14 at 13:30







1




1





You can try with gnome-open file. I have added alias o='gnome-open' to my .bashrc for simplicity.

– Pål GD
Apr 15 '14 at 8:18






You can try with gnome-open file. I have added alias o='gnome-open' to my .bashrc for simplicity.

– Pål GD
Apr 15 '14 at 8:18














gnome-open works similarly to xdg-open.

– slm
Apr 15 '14 at 12:44





gnome-open works similarly to xdg-open.

– slm
Apr 15 '14 at 12:44













Apparently, so does gvfs-open. Question What can I use instead of gnome-open? from ask ubuntu.

– Pål GD
Apr 15 '14 at 13:30





Apparently, so does gvfs-open. Question What can I use instead of gnome-open? from ask ubuntu.

– Pål GD
Apr 15 '14 at 13:30










4 Answers
4






active

oldest

votes


















32














There isn't a command that I've ever seen that will act as "open with..." but you can use the command xdg-open <file> to open a given <file> in the application that's associated with that particular type of file.



Examples



Opening a text file:



$ xdg-open tstfile.txt
$


Resulting in the file tstfile.txt being opened in gedit:



                         ss of gedit



Opening a LibreOffice Writer document:



$ xdg-open tstfile.odt 
$


Resulting in the file tstfile.odt being opened in Writer:



                         ss of writer



What apps get used?



You can use xdg-mime to query the system to find out what applications are associated to a given file type.



$ xdg-mime query default $(xdg-mime query filetype tstfile.txt)
gedit.desktop calibre-ebook-viewer.desktop

$ xdg-mime query default $(xdg-mime query filetype tstfile.odt)
libreoffice-writer.desktop calibre-ebook-viewer.desktop


This is a 2 step operation. First I'm querying for the mime-type of a given file, xdg-mime query filetype tstfile.txt, which will return text/plain. This is then used to perform another lookup to find out the list of applications that are associated with this mime-type. As you can see above I have 2 apps associated, gedit and calibre, for .txt files.



You can use xdg-mime to change the associations too. See man xdg-mime for more details.






share|improve this answer

























  • Is there a way to display other kinds of programs besides the default ones? For example, I just installed okular to view PDF's, but your example above only shows evince when I run it on a .pdf file.

    – modulitos
    May 6 '14 at 21:01






  • 1





    @Lucas - yes the examples I've shown show the applications that are associated with a given file type above. For ex. files of type .txt are associated with gedit and calibre for example.

    – slm
    May 6 '14 at 23:37











  • Do I need to have .desktop files for the programs that I want listed? For example, when I run the script on a .pdf file, it returns evince.desktop, even though I can run okular as well.

    – modulitos
    May 7 '14 at 5:53












  • @Lucas - this is probably best asked as a new Q, since we're meandering away from the original Q now.

    – slm
    May 7 '14 at 6:27


















5














If you mostly work on the command line, you could look at a curses-based file manager, like ranger or vifm. Both allow you to define default actions for filetypes.



In vifm, for example, in ~/.vifm/vifmrc you can define associations like so:



" Images
filetype *.jpg,*.jpeg,*.gif,*.tif,*.png,*.bmp sxiv

" Media
filetype *.flv,*.avi,*.mp4,*.mpeg,*.mpg,*.mov,*.ogg,*.ogv,*.mkv mpv

" Web
filetype *.html,*.htm,*.shtml /home/jason/Scripts/vimprobtab.sh

" PDF
filetype *.pdf apvlv


Hitting Enter whith the cursor on any file with one of the defined actions will see it opened by the relevant application. As you can see in the case of .html files, you can trigger a script as well as an application.






share|improve this answer






























    5














    Sort of, but it will change your default application as a result. I'm not sure what other operating systems this works on, but the instructions below work for Ubuntu 12.04 - Desktop X86-64. I didn't have any pdf files handy so I tested with a .zip archive.



    General Steps



    Step #1

    In a terminal type:



    $ mimeopen -d /home/username/example.zip


    screenshot #1 = https://copy.com/qfWSZaZ4FzlA

        ss #1



    Step #2

    Choose from the list by entering the # of the application you want, and pressing enter. The file will immediately open in the application you chose.



    screenshot #2 = https://copy.com/um6Rf7zRdceT

        ss #2



    screenshot #3 = https://copy.com/ytwKCqR6nv8i

        ss #3



    Notes



    Note #1

    This changes the default application to the one you choose, and so any time you open that file type it will now open in whatever application you last chose from the list.






    share|improve this answer

























    • Did you mean to put a hash sign (#) in the URL for screenshot 3?

      – trysis
      Apr 15 '14 at 17:33











    • @trysis I just used it to bypass the max 2 urls limit.

      – please delete me
      Apr 15 '14 at 23:44











    • Oh, makes sense. Still looks weird, though.

      – trysis
      Apr 15 '14 at 23:55











    • I cleaned up you A and added the 3rd URL for you.

      – slm
      Apr 16 '14 at 13:05


















    2














    Depends on the flavor of Unix you're using, I guess. In OS X, you can use the open command:



    OPEN(1) BSD General Commands Manual OPEN(1)

    NAME
    open -- open files and directories

    SYNOPSIS
    open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]
    [-a application] file ... [--args arg1 ...]

    DESCRIPTION
    The open command opens a file (or a directory or URL), just as if you had
    double-clicked the file's icon. If no application name is specified, the
    default application as determined via LaunchServices is used to open the
    specified files.

    If the file is in the form of a URL, the file will be opened as a URL.

    ...





    share|improve this answer























    • Also, the open command first appeared in NextStep and was inherited by OS X, so it may be available in some form on other more or less OpenStep-based platforms (e.g. AfterStep, LiteStep).

      – Ionoclast Brigham
      Apr 15 '14 at 16:26











    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f124811%2fis-there-an-open-with-command-for-the-command-line%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    32














    There isn't a command that I've ever seen that will act as "open with..." but you can use the command xdg-open <file> to open a given <file> in the application that's associated with that particular type of file.



    Examples



    Opening a text file:



    $ xdg-open tstfile.txt
    $


    Resulting in the file tstfile.txt being opened in gedit:



                             ss of gedit



    Opening a LibreOffice Writer document:



    $ xdg-open tstfile.odt 
    $


    Resulting in the file tstfile.odt being opened in Writer:



                             ss of writer



    What apps get used?



    You can use xdg-mime to query the system to find out what applications are associated to a given file type.



    $ xdg-mime query default $(xdg-mime query filetype tstfile.txt)
    gedit.desktop calibre-ebook-viewer.desktop

    $ xdg-mime query default $(xdg-mime query filetype tstfile.odt)
    libreoffice-writer.desktop calibre-ebook-viewer.desktop


    This is a 2 step operation. First I'm querying for the mime-type of a given file, xdg-mime query filetype tstfile.txt, which will return text/plain. This is then used to perform another lookup to find out the list of applications that are associated with this mime-type. As you can see above I have 2 apps associated, gedit and calibre, for .txt files.



    You can use xdg-mime to change the associations too. See man xdg-mime for more details.






    share|improve this answer

























    • Is there a way to display other kinds of programs besides the default ones? For example, I just installed okular to view PDF's, but your example above only shows evince when I run it on a .pdf file.

      – modulitos
      May 6 '14 at 21:01






    • 1





      @Lucas - yes the examples I've shown show the applications that are associated with a given file type above. For ex. files of type .txt are associated with gedit and calibre for example.

      – slm
      May 6 '14 at 23:37











    • Do I need to have .desktop files for the programs that I want listed? For example, when I run the script on a .pdf file, it returns evince.desktop, even though I can run okular as well.

      – modulitos
      May 7 '14 at 5:53












    • @Lucas - this is probably best asked as a new Q, since we're meandering away from the original Q now.

      – slm
      May 7 '14 at 6:27















    32














    There isn't a command that I've ever seen that will act as "open with..." but you can use the command xdg-open <file> to open a given <file> in the application that's associated with that particular type of file.



    Examples



    Opening a text file:



    $ xdg-open tstfile.txt
    $


    Resulting in the file tstfile.txt being opened in gedit:



                             ss of gedit



    Opening a LibreOffice Writer document:



    $ xdg-open tstfile.odt 
    $


    Resulting in the file tstfile.odt being opened in Writer:



                             ss of writer



    What apps get used?



    You can use xdg-mime to query the system to find out what applications are associated to a given file type.



    $ xdg-mime query default $(xdg-mime query filetype tstfile.txt)
    gedit.desktop calibre-ebook-viewer.desktop

    $ xdg-mime query default $(xdg-mime query filetype tstfile.odt)
    libreoffice-writer.desktop calibre-ebook-viewer.desktop


    This is a 2 step operation. First I'm querying for the mime-type of a given file, xdg-mime query filetype tstfile.txt, which will return text/plain. This is then used to perform another lookup to find out the list of applications that are associated with this mime-type. As you can see above I have 2 apps associated, gedit and calibre, for .txt files.



    You can use xdg-mime to change the associations too. See man xdg-mime for more details.






    share|improve this answer

























    • Is there a way to display other kinds of programs besides the default ones? For example, I just installed okular to view PDF's, but your example above only shows evince when I run it on a .pdf file.

      – modulitos
      May 6 '14 at 21:01






    • 1





      @Lucas - yes the examples I've shown show the applications that are associated with a given file type above. For ex. files of type .txt are associated with gedit and calibre for example.

      – slm
      May 6 '14 at 23:37











    • Do I need to have .desktop files for the programs that I want listed? For example, when I run the script on a .pdf file, it returns evince.desktop, even though I can run okular as well.

      – modulitos
      May 7 '14 at 5:53












    • @Lucas - this is probably best asked as a new Q, since we're meandering away from the original Q now.

      – slm
      May 7 '14 at 6:27













    32












    32








    32







    There isn't a command that I've ever seen that will act as "open with..." but you can use the command xdg-open <file> to open a given <file> in the application that's associated with that particular type of file.



    Examples



    Opening a text file:



    $ xdg-open tstfile.txt
    $


    Resulting in the file tstfile.txt being opened in gedit:



                             ss of gedit



    Opening a LibreOffice Writer document:



    $ xdg-open tstfile.odt 
    $


    Resulting in the file tstfile.odt being opened in Writer:



                             ss of writer



    What apps get used?



    You can use xdg-mime to query the system to find out what applications are associated to a given file type.



    $ xdg-mime query default $(xdg-mime query filetype tstfile.txt)
    gedit.desktop calibre-ebook-viewer.desktop

    $ xdg-mime query default $(xdg-mime query filetype tstfile.odt)
    libreoffice-writer.desktop calibre-ebook-viewer.desktop


    This is a 2 step operation. First I'm querying for the mime-type of a given file, xdg-mime query filetype tstfile.txt, which will return text/plain. This is then used to perform another lookup to find out the list of applications that are associated with this mime-type. As you can see above I have 2 apps associated, gedit and calibre, for .txt files.



    You can use xdg-mime to change the associations too. See man xdg-mime for more details.






    share|improve this answer















    There isn't a command that I've ever seen that will act as "open with..." but you can use the command xdg-open <file> to open a given <file> in the application that's associated with that particular type of file.



    Examples



    Opening a text file:



    $ xdg-open tstfile.txt
    $


    Resulting in the file tstfile.txt being opened in gedit:



                             ss of gedit



    Opening a LibreOffice Writer document:



    $ xdg-open tstfile.odt 
    $


    Resulting in the file tstfile.odt being opened in Writer:



                             ss of writer



    What apps get used?



    You can use xdg-mime to query the system to find out what applications are associated to a given file type.



    $ xdg-mime query default $(xdg-mime query filetype tstfile.txt)
    gedit.desktop calibre-ebook-viewer.desktop

    $ xdg-mime query default $(xdg-mime query filetype tstfile.odt)
    libreoffice-writer.desktop calibre-ebook-viewer.desktop


    This is a 2 step operation. First I'm querying for the mime-type of a given file, xdg-mime query filetype tstfile.txt, which will return text/plain. This is then used to perform another lookup to find out the list of applications that are associated with this mime-type. As you can see above I have 2 apps associated, gedit and calibre, for .txt files.



    You can use xdg-mime to change the associations too. See man xdg-mime for more details.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 15 '14 at 1:44

























    answered Apr 15 '14 at 1:28









    slmslm

    255k71539687




    255k71539687












    • Is there a way to display other kinds of programs besides the default ones? For example, I just installed okular to view PDF's, but your example above only shows evince when I run it on a .pdf file.

      – modulitos
      May 6 '14 at 21:01






    • 1





      @Lucas - yes the examples I've shown show the applications that are associated with a given file type above. For ex. files of type .txt are associated with gedit and calibre for example.

      – slm
      May 6 '14 at 23:37











    • Do I need to have .desktop files for the programs that I want listed? For example, when I run the script on a .pdf file, it returns evince.desktop, even though I can run okular as well.

      – modulitos
      May 7 '14 at 5:53












    • @Lucas - this is probably best asked as a new Q, since we're meandering away from the original Q now.

      – slm
      May 7 '14 at 6:27

















    • Is there a way to display other kinds of programs besides the default ones? For example, I just installed okular to view PDF's, but your example above only shows evince when I run it on a .pdf file.

      – modulitos
      May 6 '14 at 21:01






    • 1





      @Lucas - yes the examples I've shown show the applications that are associated with a given file type above. For ex. files of type .txt are associated with gedit and calibre for example.

      – slm
      May 6 '14 at 23:37











    • Do I need to have .desktop files for the programs that I want listed? For example, when I run the script on a .pdf file, it returns evince.desktop, even though I can run okular as well.

      – modulitos
      May 7 '14 at 5:53












    • @Lucas - this is probably best asked as a new Q, since we're meandering away from the original Q now.

      – slm
      May 7 '14 at 6:27
















    Is there a way to display other kinds of programs besides the default ones? For example, I just installed okular to view PDF's, but your example above only shows evince when I run it on a .pdf file.

    – modulitos
    May 6 '14 at 21:01





    Is there a way to display other kinds of programs besides the default ones? For example, I just installed okular to view PDF's, but your example above only shows evince when I run it on a .pdf file.

    – modulitos
    May 6 '14 at 21:01




    1




    1





    @Lucas - yes the examples I've shown show the applications that are associated with a given file type above. For ex. files of type .txt are associated with gedit and calibre for example.

    – slm
    May 6 '14 at 23:37





    @Lucas - yes the examples I've shown show the applications that are associated with a given file type above. For ex. files of type .txt are associated with gedit and calibre for example.

    – slm
    May 6 '14 at 23:37













    Do I need to have .desktop files for the programs that I want listed? For example, when I run the script on a .pdf file, it returns evince.desktop, even though I can run okular as well.

    – modulitos
    May 7 '14 at 5:53






    Do I need to have .desktop files for the programs that I want listed? For example, when I run the script on a .pdf file, it returns evince.desktop, even though I can run okular as well.

    – modulitos
    May 7 '14 at 5:53














    @Lucas - this is probably best asked as a new Q, since we're meandering away from the original Q now.

    – slm
    May 7 '14 at 6:27





    @Lucas - this is probably best asked as a new Q, since we're meandering away from the original Q now.

    – slm
    May 7 '14 at 6:27













    5














    If you mostly work on the command line, you could look at a curses-based file manager, like ranger or vifm. Both allow you to define default actions for filetypes.



    In vifm, for example, in ~/.vifm/vifmrc you can define associations like so:



    " Images
    filetype *.jpg,*.jpeg,*.gif,*.tif,*.png,*.bmp sxiv

    " Media
    filetype *.flv,*.avi,*.mp4,*.mpeg,*.mpg,*.mov,*.ogg,*.ogv,*.mkv mpv

    " Web
    filetype *.html,*.htm,*.shtml /home/jason/Scripts/vimprobtab.sh

    " PDF
    filetype *.pdf apvlv


    Hitting Enter whith the cursor on any file with one of the defined actions will see it opened by the relevant application. As you can see in the case of .html files, you can trigger a script as well as an application.






    share|improve this answer



























      5














      If you mostly work on the command line, you could look at a curses-based file manager, like ranger or vifm. Both allow you to define default actions for filetypes.



      In vifm, for example, in ~/.vifm/vifmrc you can define associations like so:



      " Images
      filetype *.jpg,*.jpeg,*.gif,*.tif,*.png,*.bmp sxiv

      " Media
      filetype *.flv,*.avi,*.mp4,*.mpeg,*.mpg,*.mov,*.ogg,*.ogv,*.mkv mpv

      " Web
      filetype *.html,*.htm,*.shtml /home/jason/Scripts/vimprobtab.sh

      " PDF
      filetype *.pdf apvlv


      Hitting Enter whith the cursor on any file with one of the defined actions will see it opened by the relevant application. As you can see in the case of .html files, you can trigger a script as well as an application.






      share|improve this answer

























        5












        5








        5







        If you mostly work on the command line, you could look at a curses-based file manager, like ranger or vifm. Both allow you to define default actions for filetypes.



        In vifm, for example, in ~/.vifm/vifmrc you can define associations like so:



        " Images
        filetype *.jpg,*.jpeg,*.gif,*.tif,*.png,*.bmp sxiv

        " Media
        filetype *.flv,*.avi,*.mp4,*.mpeg,*.mpg,*.mov,*.ogg,*.ogv,*.mkv mpv

        " Web
        filetype *.html,*.htm,*.shtml /home/jason/Scripts/vimprobtab.sh

        " PDF
        filetype *.pdf apvlv


        Hitting Enter whith the cursor on any file with one of the defined actions will see it opened by the relevant application. As you can see in the case of .html files, you can trigger a script as well as an application.






        share|improve this answer













        If you mostly work on the command line, you could look at a curses-based file manager, like ranger or vifm. Both allow you to define default actions for filetypes.



        In vifm, for example, in ~/.vifm/vifmrc you can define associations like so:



        " Images
        filetype *.jpg,*.jpeg,*.gif,*.tif,*.png,*.bmp sxiv

        " Media
        filetype *.flv,*.avi,*.mp4,*.mpeg,*.mpg,*.mov,*.ogg,*.ogv,*.mkv mpv

        " Web
        filetype *.html,*.htm,*.shtml /home/jason/Scripts/vimprobtab.sh

        " PDF
        filetype *.pdf apvlv


        Hitting Enter whith the cursor on any file with one of the defined actions will see it opened by the relevant application. As you can see in the case of .html files, you can trigger a script as well as an application.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 15 '14 at 7:39









        jasonwryanjasonwryan

        50.8k14135190




        50.8k14135190





















            5














            Sort of, but it will change your default application as a result. I'm not sure what other operating systems this works on, but the instructions below work for Ubuntu 12.04 - Desktop X86-64. I didn't have any pdf files handy so I tested with a .zip archive.



            General Steps



            Step #1

            In a terminal type:



            $ mimeopen -d /home/username/example.zip


            screenshot #1 = https://copy.com/qfWSZaZ4FzlA

                ss #1



            Step #2

            Choose from the list by entering the # of the application you want, and pressing enter. The file will immediately open in the application you chose.



            screenshot #2 = https://copy.com/um6Rf7zRdceT

                ss #2



            screenshot #3 = https://copy.com/ytwKCqR6nv8i

                ss #3



            Notes



            Note #1

            This changes the default application to the one you choose, and so any time you open that file type it will now open in whatever application you last chose from the list.






            share|improve this answer

























            • Did you mean to put a hash sign (#) in the URL for screenshot 3?

              – trysis
              Apr 15 '14 at 17:33











            • @trysis I just used it to bypass the max 2 urls limit.

              – please delete me
              Apr 15 '14 at 23:44











            • Oh, makes sense. Still looks weird, though.

              – trysis
              Apr 15 '14 at 23:55











            • I cleaned up you A and added the 3rd URL for you.

              – slm
              Apr 16 '14 at 13:05















            5














            Sort of, but it will change your default application as a result. I'm not sure what other operating systems this works on, but the instructions below work for Ubuntu 12.04 - Desktop X86-64. I didn't have any pdf files handy so I tested with a .zip archive.



            General Steps



            Step #1

            In a terminal type:



            $ mimeopen -d /home/username/example.zip


            screenshot #1 = https://copy.com/qfWSZaZ4FzlA

                ss #1



            Step #2

            Choose from the list by entering the # of the application you want, and pressing enter. The file will immediately open in the application you chose.



            screenshot #2 = https://copy.com/um6Rf7zRdceT

                ss #2



            screenshot #3 = https://copy.com/ytwKCqR6nv8i

                ss #3



            Notes



            Note #1

            This changes the default application to the one you choose, and so any time you open that file type it will now open in whatever application you last chose from the list.






            share|improve this answer

























            • Did you mean to put a hash sign (#) in the URL for screenshot 3?

              – trysis
              Apr 15 '14 at 17:33











            • @trysis I just used it to bypass the max 2 urls limit.

              – please delete me
              Apr 15 '14 at 23:44











            • Oh, makes sense. Still looks weird, though.

              – trysis
              Apr 15 '14 at 23:55











            • I cleaned up you A and added the 3rd URL for you.

              – slm
              Apr 16 '14 at 13:05













            5












            5








            5







            Sort of, but it will change your default application as a result. I'm not sure what other operating systems this works on, but the instructions below work for Ubuntu 12.04 - Desktop X86-64. I didn't have any pdf files handy so I tested with a .zip archive.



            General Steps



            Step #1

            In a terminal type:



            $ mimeopen -d /home/username/example.zip


            screenshot #1 = https://copy.com/qfWSZaZ4FzlA

                ss #1



            Step #2

            Choose from the list by entering the # of the application you want, and pressing enter. The file will immediately open in the application you chose.



            screenshot #2 = https://copy.com/um6Rf7zRdceT

                ss #2



            screenshot #3 = https://copy.com/ytwKCqR6nv8i

                ss #3



            Notes



            Note #1

            This changes the default application to the one you choose, and so any time you open that file type it will now open in whatever application you last chose from the list.






            share|improve this answer















            Sort of, but it will change your default application as a result. I'm not sure what other operating systems this works on, but the instructions below work for Ubuntu 12.04 - Desktop X86-64. I didn't have any pdf files handy so I tested with a .zip archive.



            General Steps



            Step #1

            In a terminal type:



            $ mimeopen -d /home/username/example.zip


            screenshot #1 = https://copy.com/qfWSZaZ4FzlA

                ss #1



            Step #2

            Choose from the list by entering the # of the application you want, and pressing enter. The file will immediately open in the application you chose.



            screenshot #2 = https://copy.com/um6Rf7zRdceT

                ss #2



            screenshot #3 = https://copy.com/ytwKCqR6nv8i

                ss #3



            Notes



            Note #1

            This changes the default application to the one you choose, and so any time you open that file type it will now open in whatever application you last chose from the list.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 16 '14 at 13:04









            slm

            255k71539687




            255k71539687










            answered Apr 15 '14 at 5:47









            please delete meplease delete me

            212511




            212511












            • Did you mean to put a hash sign (#) in the URL for screenshot 3?

              – trysis
              Apr 15 '14 at 17:33











            • @trysis I just used it to bypass the max 2 urls limit.

              – please delete me
              Apr 15 '14 at 23:44











            • Oh, makes sense. Still looks weird, though.

              – trysis
              Apr 15 '14 at 23:55











            • I cleaned up you A and added the 3rd URL for you.

              – slm
              Apr 16 '14 at 13:05

















            • Did you mean to put a hash sign (#) in the URL for screenshot 3?

              – trysis
              Apr 15 '14 at 17:33











            • @trysis I just used it to bypass the max 2 urls limit.

              – please delete me
              Apr 15 '14 at 23:44











            • Oh, makes sense. Still looks weird, though.

              – trysis
              Apr 15 '14 at 23:55











            • I cleaned up you A and added the 3rd URL for you.

              – slm
              Apr 16 '14 at 13:05
















            Did you mean to put a hash sign (#) in the URL for screenshot 3?

            – trysis
            Apr 15 '14 at 17:33





            Did you mean to put a hash sign (#) in the URL for screenshot 3?

            – trysis
            Apr 15 '14 at 17:33













            @trysis I just used it to bypass the max 2 urls limit.

            – please delete me
            Apr 15 '14 at 23:44





            @trysis I just used it to bypass the max 2 urls limit.

            – please delete me
            Apr 15 '14 at 23:44













            Oh, makes sense. Still looks weird, though.

            – trysis
            Apr 15 '14 at 23:55





            Oh, makes sense. Still looks weird, though.

            – trysis
            Apr 15 '14 at 23:55













            I cleaned up you A and added the 3rd URL for you.

            – slm
            Apr 16 '14 at 13:05





            I cleaned up you A and added the 3rd URL for you.

            – slm
            Apr 16 '14 at 13:05











            2














            Depends on the flavor of Unix you're using, I guess. In OS X, you can use the open command:



            OPEN(1) BSD General Commands Manual OPEN(1)

            NAME
            open -- open files and directories

            SYNOPSIS
            open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]
            [-a application] file ... [--args arg1 ...]

            DESCRIPTION
            The open command opens a file (or a directory or URL), just as if you had
            double-clicked the file's icon. If no application name is specified, the
            default application as determined via LaunchServices is used to open the
            specified files.

            If the file is in the form of a URL, the file will be opened as a URL.

            ...





            share|improve this answer























            • Also, the open command first appeared in NextStep and was inherited by OS X, so it may be available in some form on other more or less OpenStep-based platforms (e.g. AfterStep, LiteStep).

              – Ionoclast Brigham
              Apr 15 '14 at 16:26















            2














            Depends on the flavor of Unix you're using, I guess. In OS X, you can use the open command:



            OPEN(1) BSD General Commands Manual OPEN(1)

            NAME
            open -- open files and directories

            SYNOPSIS
            open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]
            [-a application] file ... [--args arg1 ...]

            DESCRIPTION
            The open command opens a file (or a directory or URL), just as if you had
            double-clicked the file's icon. If no application name is specified, the
            default application as determined via LaunchServices is used to open the
            specified files.

            If the file is in the form of a URL, the file will be opened as a URL.

            ...





            share|improve this answer























            • Also, the open command first appeared in NextStep and was inherited by OS X, so it may be available in some form on other more or less OpenStep-based platforms (e.g. AfterStep, LiteStep).

              – Ionoclast Brigham
              Apr 15 '14 at 16:26













            2












            2








            2







            Depends on the flavor of Unix you're using, I guess. In OS X, you can use the open command:



            OPEN(1) BSD General Commands Manual OPEN(1)

            NAME
            open -- open files and directories

            SYNOPSIS
            open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]
            [-a application] file ... [--args arg1 ...]

            DESCRIPTION
            The open command opens a file (or a directory or URL), just as if you had
            double-clicked the file's icon. If no application name is specified, the
            default application as determined via LaunchServices is used to open the
            specified files.

            If the file is in the form of a URL, the file will be opened as a URL.

            ...





            share|improve this answer













            Depends on the flavor of Unix you're using, I guess. In OS X, you can use the open command:



            OPEN(1) BSD General Commands Manual OPEN(1)

            NAME
            open -- open files and directories

            SYNOPSIS
            open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier]
            [-a application] file ... [--args arg1 ...]

            DESCRIPTION
            The open command opens a file (or a directory or URL), just as if you had
            double-clicked the file's icon. If no application name is specified, the
            default application as determined via LaunchServices is used to open the
            specified files.

            If the file is in the form of a URL, the file will be opened as a URL.

            ...






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 15 '14 at 7:52









            Ionoclast BrighamIonoclast Brigham

            49135




            49135












            • Also, the open command first appeared in NextStep and was inherited by OS X, so it may be available in some form on other more or less OpenStep-based platforms (e.g. AfterStep, LiteStep).

              – Ionoclast Brigham
              Apr 15 '14 at 16:26

















            • Also, the open command first appeared in NextStep and was inherited by OS X, so it may be available in some form on other more or less OpenStep-based platforms (e.g. AfterStep, LiteStep).

              – Ionoclast Brigham
              Apr 15 '14 at 16:26
















            Also, the open command first appeared in NextStep and was inherited by OS X, so it may be available in some form on other more or less OpenStep-based platforms (e.g. AfterStep, LiteStep).

            – Ionoclast Brigham
            Apr 15 '14 at 16:26





            Also, the open command first appeared in NextStep and was inherited by OS X, so it may be available in some form on other more or less OpenStep-based platforms (e.g. AfterStep, LiteStep).

            – Ionoclast Brigham
            Apr 15 '14 at 16:26

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f124811%2fis-there-an-open-with-command-for-the-command-line%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.