7

When editing shell file in gedit, is there a way I could send current line (or selected block?) to terminal?

When learning Python I use Spyder IDE. It has an option to execute code selection or block in the console. Which I found very useful in learning what my scripts are doing step by step (or not doing ;).

Any chance to have something like that with gedit? Or any other text editor?

4 Answers 4

4

sudo apt-get install gedit-plugins

This adds more plugins, one of which is an embedded terminal -- Once you've installed, open gedit, go to preferences, and check it in the "plugins" tab.

You can't specifically pipe commands or blocks through, but you can save the file and easily ./test.sh, and it can be helpful for running commands through it as opposed to having another terminal open.

http://www.linuxnov.com/how-to-install-additional-plugins-for-gedit-text-editor/

Hope this helps!

3
  • Thanks. Installed plugins - embedded terminal is useful thing indeed.
    – radek
    Oct 19, 2011 at 7:44
  • The terminal plug-in does not have this feature. It is not even possible to switch between the editor and the terminal panel with keyboard. May 7, 2019 at 15:31
  • You can enter the selected line in the embedded terminal with a short tool like the example given here and have a shortcut to run your script.
    – FrViPofm
    Apr 11, 2023 at 22:29
2

Do you know Autokey?

It wouldn't be hard to make a keyboard shortcut to run the selected line in a shell.

Autokey has many automation features, very useful to have around. And it uses pythons as its scripting language, since you already know it, it will be to get around.

1
  • Not yet - but will explore. Thanks.
    – radek
    Oct 19, 2011 at 7:44
0

unfortunately, gedit don't have this function... However, GNU Emacs has the function you want!

To install it you must type:

sudo apt-get install emacs

After installed, you can create a new buffer (i.e., a new file). Depending on the file extension, the Emacs will change the menus to give you appropriate options...

For a simple test, you can create a new shell script file (with the extension ".sh"). After saving the file, a new menu "Sh-Script" will appear. This menu has two options related to your demand: "Execute Script..." and "Execute region".

I don't know what kind of files you want to use this functionality, but you can try to use Emacs!

Best regards,

Rafael.

1
  • Thanks a lot. I'm aware that Emacs is really powerful toy indeed. Learning curve is a little bit steep tho so was hoping for simpler ad hoc solution.
    – radek
    Oct 19, 2011 at 0:28
0

A kludgy solution - a sort of "manual send" - would be to copy the line in Gedit with Ctrl-C and then paste it into Terminal with Ctrl-Shift-V.

1
  • 1
    Yup - that is what I've been using so far - hence the question ;]
    – radek
    Oct 19, 2011 at 7:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .