4

So I am looking at creating multiple shell scripts for my Lubuntu machine (the hope is to get it close to autonomous as possible). I have used apps such as Geany (which is good), but obviously I want the best. I have had a look at Editor for writing shell scripts, with autocompletion and syntax highlighting but the answer does not help me.

I want a editor that can perform (and please let me know if Geany can do this, I will be doing some testing tonight...):

  1. Tab completion: by pressing the Tab key, it is able to auto-populate the possible commands.
  2. Possible ability for it to highlight errors on the shell (e.g. The parameter used is not correct).
  3. Alignment of command (sort of like in HTML) where you can clearly identify the sections of the command by the way formatted (preferably the system detects it) like so:

demonstration of indentation

Of course I would assume that the system is able to handle multiple languages, even though I will only be doing low-end Batch, PowerShell, Shell and HTML; if I could use the same program that would be a bonus.

I would probably say that the main hopes of this program are error-checking my code and also helping with command completion. I have not posted on Ask Ubuntu because this isn't an issue but more of a question on software.

  • Be prepared to use a different key combination for competion than Tab, which is typically used to indent or insert an actual tab character. For example, in vim, completion is Ctrl+N in insert mode – glenn jackman Dec 11 '14 at 0:47
  • @glennjackman Thanks for that, tab was just an assumption. – ThisIsNotMyRealName Dec 11 '14 at 21:17
5

“Alignment” is called indentation. Most editors intended for programmers do a reasonable job of indenting program text automatically out of the box (Vim is a notable exception, getting it to indent automatically requires some configuration).

“Tabbed finishing” is called “completion” or “autocomplete”, or sometimes “tab completion” because it's commonly performed when the user presses the Tab key.

Geany is a pretty lean editor, I don't know how good its indentation and completion facilities are.

Emacs

Emacs is a very powerful text editor. It does all you want and more. It's widely available on Linux, Windows, Mac, etc.

Emacs does a good job of indenting shell scripts and most other programming languages out of the box. Press Tab to indent the current line. Emacs can be customized extensively; you can make it indent automatically, you can tune the amount and style of indentation, etc.

Emacs provides completion for command names when editing shell scripts. There aren't many editors where this works out of the box for shell scripts: Emacs has a clear advantage here. (Some other editors tend to do a better job for the language they specialize in, e.g. Eclipse with Java, but for complex multi-file projects Emacs can usually be configured to do a better job than the default.) You need Emacs 24 (the current version, a few distributions still ship Emacs 23 which doesn't have this feature yet.) Press Esc Tab to complete the current word.

Syntax highlighting provides immediate feedback for some syntax errors, in particular mismatched quotes tend to be obvious. It works out of the box in Emacs (but that's not a unique feature, many editors have it as well).

For more advanced feedback on your programming style, you can install the Flycheck package. (Install it through Emacs's package facility.) It requires Emacs 24. Flycheck supports many languages including shell scripts. The external program shellcheck provides additional feedback. The combination of flycheck and shellcheck is, if not unique to Emacs, at least a distinguishing feature, which makes me recommend Emacs not just as a good editor in general but specifically for your use case. I don't use shellcheck but I've heard good things about it; I do recommend using it to any newcomer to shell scripting and its many pitfalls.

Emacs has a large community, so if you face problems or if you want some feature, there's a good chance that you aren't the first one. Some go-to places include:

  • The manual. Use the menu entry “Help → Read the Emacs manual” or press Ctrl+H R to read the Emacs manual inside Emacs.
  • Emacs's built-in self-documentation features, such as pressing Ctrl+H K and then a key or key sequence to find out what that key does.
  • The Emacs wiki is a nice collection of resources and tips.
  • You can ask questions on Emacs Stack Exchange.
2

Try EditRocket Shell Script Editor, which is cross-platform.

As a free alternative, you can try an Eclipse plugin ShellEd.

  • I will try your alternative and see what I can do. Thanks! – ThisIsNotMyRealName Dec 11 '14 at 21:18
  • ERSSE is in Java, is proprietary, and its download is a 30-day trial. ($49.95 for per/user license + 2 years of upgrades). – agc Apr 21 '16 at 9:12
  • @agc The question was not limited to open-source non-Java programs. There is also ShellEd, which is free. – niutech Apr 21 '16 at 13:02
  • @niutech, sorry, it wasn't meant as a contradiction, just a relevant detail added for "thems that likes them sort of things." – agc Apr 21 '16 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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