Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

3 Answers

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
add comment

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
add comment

Or you can install gedit

sudo apt-get install gedit

Then:

right-click a text or php file;

select "properties";

select "open with" tab

choose among the listed/installed text editors;

click "set as defalut"

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.