Search code examples
linuxshellvimgeany

run line selection on linux shell script


I have a day routine shell script as follows

#!/bin/bash or whatever

## block1 comments
program1 filepath1 &
program2 filepath2 &

## block1 comments
program3 filepath1 &
program4 filepath2 &

Although it does not usually happens, a block can be sometimes more complicated, involving defined variables and unix commands. Each morning I open this file, and all day long what I endup doing is select a block of text, paste into a 'run' script and call it from the terminal ($ ./run.sh)

What I want is to simplify the "select/copy/paste/switch to terminal/run" into "select/run". This is conveniently done in many simple editors. I happen to use Geany, where I don't know how to do this, and I heard Vim can do this, but I don't know how.

If you know other editors that can do this, please drop a line. Many script editors allow you to run a selected text in their associated language interpreter for example. What I want is to run these shell script lines in the terminal, from a simple editor, preferably Geany or Vim.


Solution

  • In Geany:

    Please check Edit->Commands->Send selection to Terminal. You can also assign a keybinding for this. To do so: go to Edit->Preferences and pick the Keybindings tab.