36

Are there any IDEs targeted at shell scripting, specifically bash and zsh scripts? This means having syntax-highlighting for shell scripts and more importantly debugging environments with features like breakpoints, variable inspection and modification, etc., just like those available for regular programming languages like Python, Java, and C.

For instance Microsft Windows Powershell has IDEs like Powershell Plus and PowerGui.

Googling brought up a combination of ShellEd, an Eclipse plugin for editing shell scripts, and BashEclipse, a Bash debugger that works with ShellEd; I haven't tried it yet.

Are there any other shell scripting IDEs for Un*x similar to this combo? Does anyone have some experience with them?

Michael Mrozek
  • 91,316
  • 38
  • 238
  • 232
vfclists
  • 7,215
  • 14
  • 51
  • 79
  • how does someone vote down a question with 30 seconds it of being posted? – vfclists Mar 08 '14 at 22:44
  • 10
    I did not downvote but whoever did, did so because you are not asking a question. The only question in your post can be answered with a Yes/No. What are you actually asking? How do these programs work? What they do? What are you trying to do exactly? – terdon Mar 08 '14 at 22:48
  • 10
    A bash IDE? Nuclear fission to boil water for tea... – jasonwryan Mar 08 '14 at 23:00
  • I used it a while ago but remember that netbeans had a usable bash plugin for its IDE. – Ketan Maheshwari Mar 08 '14 at 23:03
  • I don't understand: Most of what I remember about scripting, I remember **because** I had torrid experience when not knowing or forgetting it. – Alois Mahdal Mar 08 '14 at 23:24
  • 5
    Actually, having a bash debugger is a very good idea -- just as with any programming language, your code will be better if you step through each line in the debugger slowly, examine the variables, think about what the code is doing, etc. A debugger is the best way to do that, even if your program or script doesn't have bugs. You can get bashdb in most distributions, which will allow you to do that in text mode. Also, the aging DDD graphic debugger can be made to work with bashdb so you have a more "visual" experience. – Stabledog Mar 09 '14 at 05:59
  • I don't care much for editors personally but `bashdb` +1. That little debugger is just so much fun! Considering I heard about it from a comment to OP's Q, I feel compelled to +1. –  Mar 09 '14 at 08:48
  • @Stabledog step-by-step in bash? We have that - the terminal. Examining variables? Just use `echo` :) – orion Mar 10 '14 at 17:41
  • 2
    Yes, certainly one can do that. And many do, and that's how they get by for years. If that suits you, I wouldn't try to convince you otherwise. In my opinion, its an inferior approach that taxes the brain with low-value tasks (like mentally keeping track of the values of variables, etc). The idea of a good debugger UI is freeing up those cycles for thinking about the program. In my experience, this matters -- you have more attention free to focus on thinking about what the program is doing if you're spending less of it on such things. – Stabledog Mar 10 '14 at 20:20
  • 1
    I would add that often programmers think that shell script is somehow not "real programming", and therefore discount the value of tools to assist. But I don't think that view is sound, it's Turing complete, you can write very complex programs with bash script and still argue that its the right language for the job, if the job works close to the shell. So it makes sense to have debuggers and editors that make such work more productive. – Stabledog Mar 10 '14 at 20:23
  • 2
    For those of us with electric kettles or ranges in the US or Europe, a good part of our baseload electrical generation is supplied by nuclear power plants, so when we boil water for tea, we are using nuclear fission, at least partially. – Andrew Janke Aug 20 '15 at 00:48
  • 1
    +1 to what Stabledog said. And for nontrivial scripts, it goes beyond convenience. Some things you can't observe easily or at all from the terminal, like state inside function executions or multi-command lists or subshells. Or the parts of the shell that interact with the terminal itself, like ZLE. Or precmd/chpwd hooks. Or variables containing trailing whitespace or terminal control sequences. Or with unexpected types, like integers, arrays, or associative arrays, or unset vs empty, or exported vs not. A graphical debugger/IDE could save time & effort on that stuff. – Andrew Janke Aug 20 '15 at 01:03
  • @Stabledog debuggers don't improve code. They _can_ improve insight into code and prompt capable developers to revisit earlier decisions, but you make it sound as if a debugger is a magic bullet against bad code. – 0xC0000022L Nov 20 '18 at 09:17

8 Answers8

17

I wouldn't say it is either well known or well used but you might have a look to basheclipse:

enter image description here

I must admit I have no experience with basheclipse and even failed to install it due to an eclipse version mismatch.

On the other hand, I'm using bash and ksh93 specific debugging features, especially the trap ERR and trap DEBUG ones but not the debuggers based on them kshdb and bashdb

jlliagre
  • 60,319
  • 10
  • 115
  • 157
  • I find it rather ironic that your screen-shot is of a Windows-style window. – Agi Hammerthief Mar 10 '14 at 17:54
  • @NigelNquande To be honest, I'm not a basheclipse (or eclipse for that matter) user. I definitely use debugging features provided by ksh93 and bash, but no GUI. This screenshot is taken from the basheclipse site. It might be some gnome theme or just a real Windows 7 screenshot given the OS="cygwin" line. – jlliagre Mar 10 '14 at 21:11
  • Well, IMO, if you're going to do something, do it with boots on, not half-a**ed (but that's neither here nor there to anybody else). To me, `bash` on Windows seems half-a**sed when it works perfectly well in GNU/Linux. – Agi Hammerthief Mar 10 '14 at 21:15
  • @NigelNquande As I wrote, this isn't a screenshot of mine. In any case, I only use bash on Windows when I have no choice and `cygwin` is quite efficient to hide the underlying OS. – jlliagre Mar 10 '14 at 21:33
  • I tried this on Eclipse 4.7 and couldn't find anything new in my IDE. – Sridhar Sarnobat Dec 13 '17 at 00:21
  • 1
    @user7000 I wrote *and even failed to install it due to an eclipse version mismatch* but I don't remember what eclipse version it was. Is is documented to work with Eclipse 4.5.2 though: https://sourceforge.net/projects/basheclipse/files/?source=navbar – jlliagre Dec 13 '17 at 07:55
6

A purpose-built IDE would sort of defeat the purpose of shell scripting, not to mention that it's nearly impossible to do, because most of what shell does is calling external commands - how do you debug that? Debugging with checkpoints is counterintuitive for a shell - shell scripts usually operate heavily on files and thus have destructive side-effects on every call. Scripting BY DESIGN works line-by line, so your "environment" is actually the terminal itself - you can always echo variables, your environment is always there for you, there is no "prescribed flow" that you would have to interrupt. You progressively do whatever you want to do, line by line, testing each time if you got what you wanted and then paste these lines into a script to use again. Any IDE would actually just disable most of what you can do in the shell itself.

For fully qualified scripting languages (Python, Perl etc) you do have all this, but bash/zsh/ksh/... are interactive "glue" for other commands and are their own debuggers.

However, most text editors will highlight the code for you, and emacs will (provided you find the right packages, I never bothered with doing that for shell scripts) provide programmable keyword completion. I believe vi can do that as well (don't start a flamewar here please).

orion
  • 12,302
  • 2
  • 31
  • 41
  • 2
    How do you define a "fully qualified scripting language?" – Trevor Sullivan Dec 19 '15 at 04:44
  • 1
    @TrevorSullivan in his own way. Don't, please, give into the hate. – Det Nov 06 '16 at 21:36
  • 1
    @Det: It was a legitimate question -- if we can't all agree on a common, concrete definition of the phrase, then we might as well not have a discussion about it. I'm just curious what is meant by that phrase. – Trevor Sullivan Nov 07 '16 at 17:59
  • I meant the distinction between shell scripting (calling external tools for almost all functionality except for flow control and a bit of logic), and scripting in a broader sense of interpreted languages, which usually have their own backing libraries. It depends on what you mean by scripting, but that's the distinction that makes the terminal itself the most reasonable IDE for shell languages. – orion Nov 07 '16 at 20:22
  • 5
    I don't agree IDEs defeat the purpose of shell scripting. You might want to clean up your shell scripts (e.g. inline extraneous variables, detect unused variables - which is what I'm trying to do in cleaning up my System V Init scripts which are getting unnecessarily long especially when duplicated from existing examples). – Sridhar Sarnobat Dec 12 '17 at 23:55
  • 4
    I would also add that and IDE provides intellisense or other tools so I don't have to keep googling or looking at man pages to remember some stuff. It also allows me to keep all my scripts together in a project, step over lines, inspect incoming arguments, test loops and switches, break apart a pipe for inspection, etc. – cjbarth Dec 22 '17 at 15:09
  • For the original idea of shell-scripting (e.g. writing a script to enter the 5-10 commands over and over again), yes, it would seem that having a full IDE may seem overblown. However, with things like functions, associative arrays and parallel programming (via _coproc_) available in BASH nowadays, once a script gets to 200, 500 or 1000 lines, you really want a toolbox like you get with _every_ other language. – B.Kaatz Oct 19 '21 at 22:26
  • @orion I say that most of my debugging is **flow control** and **logic**. You write in if-clause backwards and don't understand why it doesn't work. Then it's great to be able to see why the value of a counter is not what you expected or a boolean is set the wrong way. – d-b Aug 09 '23 at 16:17
4

Rogalmic wrote VSCode plugins for bashdb and zshdb.

They are based on my debuggers for bash and zsh, so they handle a lot of the edge cases that are lacking in say the eclipse debugger for bash.

rocky
  • 1,978
  • 11
  • 23
3

I also endorse the idea of using an IDE for bash scripts.

One can write bash scripts using the jupyter notebook.

The jupyter notebook can be installed via anaconda while a bash kernel for jupyter notebook (or jupyterlab) can be installed with the following commands (source):

pip install bash_kernel and

python -m bash_kernel.install

After that, you can select bash on a new launcher instance of anaconda navigator, as shown below.

The only thing is that (as far as I know) it does not work with commands that you have to input to the prompt, such as read or any other argument that you pass after calling the script. But other than that, it works pretty well.

enter image description here

BCArg
  • 205
  • 2
  • 8
3

I know this is very late for this thread, but there are options available now.

From MasteringUnixShell.net:

Sublime Text: Sublime Text has many powerful features that makes coding painless. It has all basic features mentioned on this page and many others like: multi-select (hold CTRL and put mouse cursor in another line), creating your own snippets(lines of code that repeat), minimap(zoomed view of entire file).

Atom: Atom is developed by Github so it supports Github integration. It is often called "hackable IDE of 21st century", so you could easy customize almost everything. Cool visual extension is "Power mode", every time you hit a key, editor does a little move, like you hit the screen.

Geany: Geany is lightweight IDE, aims to provide fast development environment. Features: filebrowser, save actions( autosave, instantsave, backupcopy), split window.

Kate: It is pre-installed text editor in Kubuntu. Some of useful features: embedded terminal, SQL plugin, find and replace, syntax highlighting, bracket matching, auto backup, auto completion with argument handling.

I'm just trying out Geany, having given up on ShellEd and BashClipse.

Hope that helps someone also looking.

B.Kaatz
  • 265
  • 1
  • 7
  • I'm a late adopter and am beginning to regret it after seeing how good Atom and Sublime are. Autocomplete (for Bash, even for Java), Minimap, Git status. I need to serious re-evaluate whether I should be using Eclipse. – Sridhar Sarnobat Aug 22 '22 at 09:53
1

encountered this issue my self , mean that I searched for bash script IDE , there is a lot of plugins on populare IDE just like eclipse and many other. but find it lots of work dealing with IDE's just to build small bash scripts. in the other hand working with editors cause lots of syntax errors and waste of time , not to mention it's not fun at all.

so I found a online bash script tool for building scripts , it's called http://bashops.net , it's online , immediately can start working on building bash script , without getting busy in any installation.

1

I would like to suggest PyCharm Community edition with BashSupport plugin. This has excellent IDE functionalities with intellij intellisense.

UserOnWeb
  • 11
  • 1
  • Unfortunately, BashSupport has been retired. And the BashSupport Pro has a monthly subscription. – Ashark Jul 01 '21 at 10:02
0

Try this site. I'm also looking for the same thing and I want to be able to test the script first and not affect my system. This is an online editor for bash.

https://repl.it/languages/bash