You are not logged in.

#1 2013-07-10 19:43:23

orphius
Member
Registered: 2009-01-24
Posts: 9

[SOLVED] How to open default text editor from bash script?

as header states i would like my script to open the desktops default text editor. I use xfce.
I currently have it set to open medit, however i want to be able to use script on other desktops

Last edited by orphius (2013-07-12 07:24:34)

Offline

#2 2013-07-10 19:47:18

oliver
Member
Registered: 2007-12-12
Posts: 448

Re: [SOLVED] How to open default text editor from bash script?

export your EDITOR in .bashrc and then use $EDITOR in your scripts?

Offline

#3 2013-07-10 19:52:25

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,332
Website

Re: [SOLVED] How to open default text editor from bash script?

EDITOR will often not be the default desktop environment editor - it is usually limited to being a systemwide (and usually console-ready) editor.

xdg-open, or a related tool, can give you the desktop's text editor.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2013-07-11 04:03:03

thiagowfx
Member
Registered: 2013-07-09
Posts: 586

Re: [SOLVED] How to open default text editor from bash script?

Yeah, I think that you should set up the correct MIME types and then open your text files with xdg-open. Try the 'xdg-mime default' command.

Offline

#5 2013-07-11 07:07:02

jakobcreutzfeldt
Member
Registered: 2011-05-12
Posts: 1,041

Re: [SOLVED] How to open default text editor from bash script?

Trilby wrote:

EDITOR will often not be the default desktop environment editor - it is usually limited to being a systemwide (and usually console-ready) editor.

xdg-open, or a related tool, can give you the desktop's text editor.

Truth. VISUAL is typically used for the graphical text editor.

So, to use VISUAL if it exists, but otherwise default to medit, do:

editor="${VISUAL:-medit}"
$editor foo.txt

Last edited by jakobcreutzfeldt (2013-07-11 07:09:02)

Offline

#6 2013-07-12 07:24:10

orphius
Member
Registered: 2009-01-24
Posts: 9

Re: [SOLVED] How to open default text editor from bash script?

thank you jakobcreutzfeldt
  that was just what i needed

Offline

Board footer

Powered by FluxBB