2

I would like to know, how can I set a terminal text editor as a default desktop application? I want to double-click file and open it in terminal editor.

2

I think that the right way to do this is to create a Desktop Launcher for your alternative editor, and then modify the MIME database to associate it as the default application for your target mimetype(s).

For example:

  1. Create a minimal $HOME/.local/share/applications/myedit.desktop as

    [Desktop Entry]
    Type=Application
    Exec=/usr/bin/nano %F
    Terminal=true
    Name=MyEdit

    You may want to add at least a suitable Icon field, if you have one.

  2. Edit $HOME/.local/share/applications/mimeapps.list

    [Default Applications]
    x-scheme-handler/mailto=thunderbird.desktop
    message/rfc822=thunderbird.desktop
    application/x-extension-eml=thunderbird.desktop
    text/plain=myedit.desktop

  3. Update the MIME database

    update-mime-database ~/.local/share/mime
    

After that, double-clicking a plain text file in the Nautilus file manager should open a gnome-terminal and run nano on the file.

0

Short answer: I hope I am wrong, but this is likely impossible or prohibitively difficult.

The general answer is you would want to set your terminal as the default App in the GUI, with some some arguments to it. In my experience, Terminals tend not to support "run this application" as an argument and last time I did something like this I had a launcher set an ENV variable which I then checked in my shell's .dotfile to do the right thing. So, you would have to convince your file browser to use an action like "export MAGIC_EDITOR=launch-vim; konsole %s" and then your shell would check MAGIC_EDITOR and pull %s as what ... $1?

This can get fragile and may need to be re-done after an upgrade or if you change your terminal preference, &c.

Far easier to use the GUI form of those text editors. (Example: gvim is pretty nice, but I prefer the font/colors I already have in my terminal.)

Of course, within the terminal, you can set the EDITOR and/or VISUAL environment variables.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.