How to open the default GUI text editor in Ubuntu or Lubuntu via a script?












4














I have a script that uses gedit to open text file in Ubuntu. That script does not work under Lubuntu. What command is required to execute the default text editor?



I want to make the script usable under Ubuntu and Lubuntu.










share|improve this question
























  • Do you have gedit installed in lubuntu?
    – LnxSlck
    Jan 28 '13 at 12:45










  • no, i do not have gedit installed in lubuntu
    – UAdapter
    Jan 28 '13 at 12:52










  • i got gedit by default on ubuntu 14
    – Adi Prasetyo
    Jul 21 '17 at 22:48
















4














I have a script that uses gedit to open text file in Ubuntu. That script does not work under Lubuntu. What command is required to execute the default text editor?



I want to make the script usable under Ubuntu and Lubuntu.










share|improve this question
























  • Do you have gedit installed in lubuntu?
    – LnxSlck
    Jan 28 '13 at 12:45










  • no, i do not have gedit installed in lubuntu
    – UAdapter
    Jan 28 '13 at 12:52










  • i got gedit by default on ubuntu 14
    – Adi Prasetyo
    Jul 21 '17 at 22:48














4












4








4


2





I have a script that uses gedit to open text file in Ubuntu. That script does not work under Lubuntu. What command is required to execute the default text editor?



I want to make the script usable under Ubuntu and Lubuntu.










share|improve this question















I have a script that uses gedit to open text file in Ubuntu. That script does not work under Lubuntu. What command is required to execute the default text editor?



I want to make the script usable under Ubuntu and Lubuntu.







lubuntu scripts gedit default-programs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 28 '13 at 16:47







user25656

















asked Jan 28 '13 at 12:41









UAdapterUAdapter

5,147346693




5,147346693












  • Do you have gedit installed in lubuntu?
    – LnxSlck
    Jan 28 '13 at 12:45










  • no, i do not have gedit installed in lubuntu
    – UAdapter
    Jan 28 '13 at 12:52










  • i got gedit by default on ubuntu 14
    – Adi Prasetyo
    Jul 21 '17 at 22:48


















  • Do you have gedit installed in lubuntu?
    – LnxSlck
    Jan 28 '13 at 12:45










  • no, i do not have gedit installed in lubuntu
    – UAdapter
    Jan 28 '13 at 12:52










  • i got gedit by default on ubuntu 14
    – Adi Prasetyo
    Jul 21 '17 at 22:48
















Do you have gedit installed in lubuntu?
– LnxSlck
Jan 28 '13 at 12:45




Do you have gedit installed in lubuntu?
– LnxSlck
Jan 28 '13 at 12:45












no, i do not have gedit installed in lubuntu
– UAdapter
Jan 28 '13 at 12:52




no, i do not have gedit installed in lubuntu
– UAdapter
Jan 28 '13 at 12:52












i got gedit by default on ubuntu 14
– Adi Prasetyo
Jul 21 '17 at 22:48




i got gedit by default on ubuntu 14
– Adi Prasetyo
Jul 21 '17 at 22:48










5 Answers
5






active

oldest

votes


















7














Use xdg-open it works in most linux distros.

example:



xdg-open /filepath/file.txt





share|improve this answer























  • Of all the answers, this method just works.
    – u2n
    Jan 27 '15 at 0:40



















4














You might get somewhere with /usr/bin/gnome-text-editor, as that's set using the alternatives system and points to the default editor under a gnome-ish environment. Not quite sure whether it is actually useful under lubuntu/kubuntu, but you could try.





Just to supplement Dennis' answer, with respect to Lubuntu 12.10, if one runs sudo update-alternatives --display gnome-text-editor, the output is:



gnome-text-editor - auto mode
link currently points to /usr/bin/leafpad
/usr/bin/leafpad - priority 40
slave gnome-text-editor.1.gz: /usr/share/man/man1/leafpad.1.gz
Current 'best' version is '/usr/bin/leafpad'.


And, as Dennis suggested, /usr/bin/gnome-text-editor does open Leafpad in Lubuntu.






share|improve this answer



















  • 1




    it works under lubuntu. system does not allow me to accept your answer. it says I have to wait. the .... system
    – UAdapter
    Jan 28 '13 at 12:54





















4














Or you can install gedit



sudo apt-get install gedit


Then:




  1. Right-click a text or php file

  2. Select "Properties"

  3. Select "Open with" tab

  4. Choose among the listed/installed text editors

  5. Click "Set as default"

  6. Click "Close"






share|improve this answer























  • but you need the superuser password to install any new software, and it requires a internet connection. Not something you want in a "general" script.
    – Alvar
    Jan 28 '13 at 12:56










  • You only have to do this one time. Then you can execute your script normally
    – LnxSlck
    Jan 28 '13 at 14:06



















3














In addition to Dennis Kaarsemaker's answer, you could try using /usr/bin/editor for something even more generic. This will likely lead to a terminal-based editor be launched, though.



Cf. the update-alternatives manpage.






share|improve this answer

















  • 1




    The update-alternatives --config editor doesn't list any GUI text editors unfortunately.
    – gertvdijk
    Jan 28 '13 at 13:00






  • 1




    Hence the "This will likely lead to a terminal-based editor be launched, though." I forgot to mention update-alternatives --config editor, though. Thanks.
    – Michael Biech
    Jan 28 '13 at 13:02





















0














Here is a list of Lubuntu Apps. However, in 18.10 the editor has changed from Leafpad to Featherpad.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f248616%2fhow-to-open-the-default-gui-text-editor-in-ubuntu-or-lubuntu-via-a-script%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    5 Answers
    5






    active

    oldest

    votes








    5 Answers
    5






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    Use xdg-open it works in most linux distros.

    example:



    xdg-open /filepath/file.txt





    share|improve this answer























    • Of all the answers, this method just works.
      – u2n
      Jan 27 '15 at 0:40
















    7














    Use xdg-open it works in most linux distros.

    example:



    xdg-open /filepath/file.txt





    share|improve this answer























    • Of all the answers, this method just works.
      – u2n
      Jan 27 '15 at 0:40














    7












    7








    7






    Use xdg-open it works in most linux distros.

    example:



    xdg-open /filepath/file.txt





    share|improve this answer














    Use xdg-open it works in most linux distros.

    example:



    xdg-open /filepath/file.txt






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Aug 16 '14 at 19:19









    Parto

    9,3461965103




    9,3461965103










    answered Aug 16 '14 at 18:49









    andyandy

    7111




    7111












    • Of all the answers, this method just works.
      – u2n
      Jan 27 '15 at 0:40


















    • Of all the answers, this method just works.
      – u2n
      Jan 27 '15 at 0:40
















    Of all the answers, this method just works.
    – u2n
    Jan 27 '15 at 0:40




    Of all the answers, this method just works.
    – u2n
    Jan 27 '15 at 0:40













    4














    You might get somewhere with /usr/bin/gnome-text-editor, as that's set using the alternatives system and points to the default editor under a gnome-ish environment. Not quite sure whether it is actually useful under lubuntu/kubuntu, but you could try.





    Just to supplement Dennis' answer, with respect to Lubuntu 12.10, if one runs sudo update-alternatives --display gnome-text-editor, the output is:



    gnome-text-editor - auto mode
    link currently points to /usr/bin/leafpad
    /usr/bin/leafpad - priority 40
    slave gnome-text-editor.1.gz: /usr/share/man/man1/leafpad.1.gz
    Current 'best' version is '/usr/bin/leafpad'.


    And, as Dennis suggested, /usr/bin/gnome-text-editor does open Leafpad in Lubuntu.






    share|improve this answer



















    • 1




      it works under lubuntu. system does not allow me to accept your answer. it says I have to wait. the .... system
      – UAdapter
      Jan 28 '13 at 12:54


















    4














    You might get somewhere with /usr/bin/gnome-text-editor, as that's set using the alternatives system and points to the default editor under a gnome-ish environment. Not quite sure whether it is actually useful under lubuntu/kubuntu, but you could try.





    Just to supplement Dennis' answer, with respect to Lubuntu 12.10, if one runs sudo update-alternatives --display gnome-text-editor, the output is:



    gnome-text-editor - auto mode
    link currently points to /usr/bin/leafpad
    /usr/bin/leafpad - priority 40
    slave gnome-text-editor.1.gz: /usr/share/man/man1/leafpad.1.gz
    Current 'best' version is '/usr/bin/leafpad'.


    And, as Dennis suggested, /usr/bin/gnome-text-editor does open Leafpad in Lubuntu.






    share|improve this answer



















    • 1




      it works under lubuntu. system does not allow me to accept your answer. it says I have to wait. the .... system
      – UAdapter
      Jan 28 '13 at 12:54
















    4












    4








    4






    You might get somewhere with /usr/bin/gnome-text-editor, as that's set using the alternatives system and points to the default editor under a gnome-ish environment. Not quite sure whether it is actually useful under lubuntu/kubuntu, but you could try.





    Just to supplement Dennis' answer, with respect to Lubuntu 12.10, if one runs sudo update-alternatives --display gnome-text-editor, the output is:



    gnome-text-editor - auto mode
    link currently points to /usr/bin/leafpad
    /usr/bin/leafpad - priority 40
    slave gnome-text-editor.1.gz: /usr/share/man/man1/leafpad.1.gz
    Current 'best' version is '/usr/bin/leafpad'.


    And, as Dennis suggested, /usr/bin/gnome-text-editor does open Leafpad in Lubuntu.






    share|improve this answer














    You might get somewhere with /usr/bin/gnome-text-editor, as that's set using the alternatives system and points to the default editor under a gnome-ish environment. Not quite sure whether it is actually useful under lubuntu/kubuntu, but you could try.





    Just to supplement Dennis' answer, with respect to Lubuntu 12.10, if one runs sudo update-alternatives --display gnome-text-editor, the output is:



    gnome-text-editor - auto mode
    link currently points to /usr/bin/leafpad
    /usr/bin/leafpad - priority 40
    slave gnome-text-editor.1.gz: /usr/share/man/man1/leafpad.1.gz
    Current 'best' version is '/usr/bin/leafpad'.


    And, as Dennis suggested, /usr/bin/gnome-text-editor does open Leafpad in Lubuntu.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jan 28 '13 at 17:14







    user25656

















    answered Jan 28 '13 at 12:48









    Dennis KaarsemakerDennis Kaarsemaker

    5,7721736




    5,7721736








    • 1




      it works under lubuntu. system does not allow me to accept your answer. it says I have to wait. the .... system
      – UAdapter
      Jan 28 '13 at 12:54
















    • 1




      it works under lubuntu. system does not allow me to accept your answer. it says I have to wait. the .... system
      – UAdapter
      Jan 28 '13 at 12:54










    1




    1




    it works under lubuntu. system does not allow me to accept your answer. it says I have to wait. the .... system
    – UAdapter
    Jan 28 '13 at 12:54






    it works under lubuntu. system does not allow me to accept your answer. it says I have to wait. the .... system
    – UAdapter
    Jan 28 '13 at 12:54













    4














    Or you can install gedit



    sudo apt-get install gedit


    Then:




    1. Right-click a text or php file

    2. Select "Properties"

    3. Select "Open with" tab

    4. Choose among the listed/installed text editors

    5. Click "Set as default"

    6. Click "Close"






    share|improve this answer























    • but you need the superuser password to install any new software, and it requires a internet connection. Not something you want in a "general" script.
      – Alvar
      Jan 28 '13 at 12:56










    • You only have to do this one time. Then you can execute your script normally
      – LnxSlck
      Jan 28 '13 at 14:06
















    4














    Or you can install gedit



    sudo apt-get install gedit


    Then:




    1. Right-click a text or php file

    2. Select "Properties"

    3. Select "Open with" tab

    4. Choose among the listed/installed text editors

    5. Click "Set as default"

    6. Click "Close"






    share|improve this answer























    • but you need the superuser password to install any new software, and it requires a internet connection. Not something you want in a "general" script.
      – Alvar
      Jan 28 '13 at 12:56










    • You only have to do this one time. Then you can execute your script normally
      – LnxSlck
      Jan 28 '13 at 14:06














    4












    4








    4






    Or you can install gedit



    sudo apt-get install gedit


    Then:




    1. Right-click a text or php file

    2. Select "Properties"

    3. Select "Open with" tab

    4. Choose among the listed/installed text editors

    5. Click "Set as default"

    6. Click "Close"






    share|improve this answer














    Or you can install gedit



    sudo apt-get install gedit


    Then:




    1. Right-click a text or php file

    2. Select "Properties"

    3. Select "Open with" tab

    4. Choose among the listed/installed text editors

    5. Click "Set as default"

    6. Click "Close"







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 26 '17 at 20:33









    wjandrea

    8,47842259




    8,47842259










    answered Jan 28 '13 at 12:50









    LnxSlckLnxSlck

    10.2k12949




    10.2k12949












    • but you need the superuser password to install any new software, and it requires a internet connection. Not something you want in a "general" script.
      – Alvar
      Jan 28 '13 at 12:56










    • You only have to do this one time. Then you can execute your script normally
      – LnxSlck
      Jan 28 '13 at 14:06


















    • but you need the superuser password to install any new software, and it requires a internet connection. Not something you want in a "general" script.
      – Alvar
      Jan 28 '13 at 12:56










    • You only have to do this one time. Then you can execute your script normally
      – LnxSlck
      Jan 28 '13 at 14:06
















    but you need the superuser password to install any new software, and it requires a internet connection. Not something you want in a "general" script.
    – Alvar
    Jan 28 '13 at 12:56




    but you need the superuser password to install any new software, and it requires a internet connection. Not something you want in a "general" script.
    – Alvar
    Jan 28 '13 at 12:56












    You only have to do this one time. Then you can execute your script normally
    – LnxSlck
    Jan 28 '13 at 14:06




    You only have to do this one time. Then you can execute your script normally
    – LnxSlck
    Jan 28 '13 at 14:06











    3














    In addition to Dennis Kaarsemaker's answer, you could try using /usr/bin/editor for something even more generic. This will likely lead to a terminal-based editor be launched, though.



    Cf. the update-alternatives manpage.






    share|improve this answer

















    • 1




      The update-alternatives --config editor doesn't list any GUI text editors unfortunately.
      – gertvdijk
      Jan 28 '13 at 13:00






    • 1




      Hence the "This will likely lead to a terminal-based editor be launched, though." I forgot to mention update-alternatives --config editor, though. Thanks.
      – Michael Biech
      Jan 28 '13 at 13:02


















    3














    In addition to Dennis Kaarsemaker's answer, you could try using /usr/bin/editor for something even more generic. This will likely lead to a terminal-based editor be launched, though.



    Cf. the update-alternatives manpage.






    share|improve this answer

















    • 1




      The update-alternatives --config editor doesn't list any GUI text editors unfortunately.
      – gertvdijk
      Jan 28 '13 at 13:00






    • 1




      Hence the "This will likely lead to a terminal-based editor be launched, though." I forgot to mention update-alternatives --config editor, though. Thanks.
      – Michael Biech
      Jan 28 '13 at 13:02
















    3












    3








    3






    In addition to Dennis Kaarsemaker's answer, you could try using /usr/bin/editor for something even more generic. This will likely lead to a terminal-based editor be launched, though.



    Cf. the update-alternatives manpage.






    share|improve this answer












    In addition to Dennis Kaarsemaker's answer, you could try using /usr/bin/editor for something even more generic. This will likely lead to a terminal-based editor be launched, though.



    Cf. the update-alternatives manpage.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 28 '13 at 12:53









    Michael BiechMichael Biech

    45124




    45124








    • 1




      The update-alternatives --config editor doesn't list any GUI text editors unfortunately.
      – gertvdijk
      Jan 28 '13 at 13:00






    • 1




      Hence the "This will likely lead to a terminal-based editor be launched, though." I forgot to mention update-alternatives --config editor, though. Thanks.
      – Michael Biech
      Jan 28 '13 at 13:02
















    • 1




      The update-alternatives --config editor doesn't list any GUI text editors unfortunately.
      – gertvdijk
      Jan 28 '13 at 13:00






    • 1




      Hence the "This will likely lead to a terminal-based editor be launched, though." I forgot to mention update-alternatives --config editor, though. Thanks.
      – Michael Biech
      Jan 28 '13 at 13:02










    1




    1




    The update-alternatives --config editor doesn't list any GUI text editors unfortunately.
    – gertvdijk
    Jan 28 '13 at 13:00




    The update-alternatives --config editor doesn't list any GUI text editors unfortunately.
    – gertvdijk
    Jan 28 '13 at 13:00




    1




    1




    Hence the "This will likely lead to a terminal-based editor be launched, though." I forgot to mention update-alternatives --config editor, though. Thanks.
    – Michael Biech
    Jan 28 '13 at 13:02






    Hence the "This will likely lead to a terminal-based editor be launched, though." I forgot to mention update-alternatives --config editor, though. Thanks.
    – Michael Biech
    Jan 28 '13 at 13:02













    0














    Here is a list of Lubuntu Apps. However, in 18.10 the editor has changed from Leafpad to Featherpad.






    share|improve this answer


























      0














      Here is a list of Lubuntu Apps. However, in 18.10 the editor has changed from Leafpad to Featherpad.






      share|improve this answer
























        0












        0








        0






        Here is a list of Lubuntu Apps. However, in 18.10 the editor has changed from Leafpad to Featherpad.






        share|improve this answer












        Here is a list of Lubuntu Apps. However, in 18.10 the editor has changed from Leafpad to Featherpad.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 25 '18 at 12:10









        TimoTimo

        1707




        1707






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2faskubuntu.com%2fquestions%2f248616%2fhow-to-open-the-default-gui-text-editor-in-ubuntu-or-lubuntu-via-a-script%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

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido