43

I use netbeans 6.8 beta and when i load .sh (bash) file it's not colored at all. i can add a new file association for the .sh extension but it doesn't seem that there is a known associated mime type.

3 Answers 3

69

I have not tried this myself but you can get shell script support in Netbeans if you install the C/C++ plugin.

7
  • 1
    i already have netbeans packages with everything including c/c++.
    – ufk
    Oct 29, 2009 at 13:02
  • 2
    works for me, but how about bash scripts without an extension?
    – simpatico
    May 16, 2011 at 9:41
  • 1
    NetBeans only recognizes files by name (mostly by extension). Oct 24, 2012 at 15:47
  • 4
    For sh and bash files without extension there is a netbeans-noext-mime-resolver plugin Jun 25, 2014 at 6:10
  • 1
    FWIW I just installed the C++ plugin (Tools > Plugins) on macOS (PHP profile of NetBeans) and it works. My file had no extension (.bash_aliases) but started with #!/bin/bash and that seems to trigger the bash formatting! Thanks 🙏
    – jerclarke
    Aug 15, 2018 at 19:09
29

old question, time for an update (tested for 8.0.2,8.1,8.2).

Here's what worked for me

  1. Install C/C++ plugin. This will recognize .sh extensions as bash files
  2. Install nb-noext-mime-resolver (for 8.2 you'll find it as No Extension MIME Resolver) . This will add support for files with no extension by recognizing the shebang line
  3. Go to tools/options/editor/spellchecker and uncheck 'Script and make comments'.(not available after 8.2) This will get rid of the red squiggly lines that appear under 'usr' and other legitimate notations in the shebang line and elsewhere.

You'll get full syntax highlighting as well as the ability to right click and select 'run' which will launch your script in the built in terminal. very nice.

To get the context menu 'run' to work with your shell

  1. Select 'Run'/'Set Project Configuration'/'Customize'
  2. Click 'New' and add a name for your shell like 'bash' or 'cygwin'
  3. Select 'Run As' 'Script (run in command line'
  4. Where it says 'Php Interpreter' (or equivilent) add the path to your bash shell. e.g: C:\cygwin\bin\bash.exe
  5. Click 'ok'.

Also, check out the properties of the bash files and you'll find some helpful ones.

1
  • 3
    As Oct 2017 on NetBeans 8.2: I only had to install the C/C++ plugin and restart the IDE but the details about noext plugin is very usefull to know, Saved me an headache Oct 17, 2017 at 16:05
0

This is very odd. I have NB6.8beta installed with the C/C++ plugin. When I open a .sh file I do see syntax high lighting. Quotes strings show up in orange, commands are in blue.

2
  • under tools -> options -> Miscellaneous -> Files under file extension sh what is the associated file type (mime) ?
    – ufk
    Nov 2, 2009 at 11:33
  • Again, very old question, but for anyone stumbling across this the MIME type for sh on NB 8.2 (and previously) is Shell Scripts (text/sh).
    – idclaar
    Feb 16, 2017 at 22:07

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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