27

I'm Windows user. But according to my project requirements, I need to write Linux Shell Script(Bash shell). How to develop Linux Shell on Windows?

Is there any IDE for writing Linux Shell Scripting? Please share me some ideas and resource links.

Charles
  • 50,943
  • 13
  • 104
  • 142
Sai Ye Yan Naing Aye
  • 6,622
  • 12
  • 47
  • 65

10 Answers10

22

You have quite a number of options:

cygwin

Install cygwin. It will give you a bash.

mingw

The minimal GNU for windows. Comes with set of commands, compilers. This came with my Git on Windows and now the default shell for small scripts

VM, such as VirtualBox

There are tons on VMs, VirtualBox being easy to use(it powers the Boot2Docker). You can do development and test on real Linux distros.

Ubuntu on Windows 10

There is new kid on the block. This allows you to run User Space Ubuntu using Windows Subsystem for Linux (WSL). see more on it at Microsoft blog

Other notes/IDE support

Shell scripts should be small, requires less IDE etc. I use VIM with syntax highligthing. But it seems ShellED may be useful in your case. I got the link from answer for this question - Bash script plugin for Eclipse?

IntelliJ has couple of plugins too for Bash..

Community
  • 1
  • 1
Jayan
  • 18,003
  • 15
  • 89
  • 143
  • For a comparison between Cygwin, MinGW-W64 & MSYS2 and a quick mention of a few other related tools take a look at https://superuser.com/a/1207515/257859 – ndemou May 09 '17 at 14:32
10

I prefer Gow (Gnu on Windows) over Cygwin. Both will give you bash on Windows, but Cygwin has unnatural conventions for filesystem access (/cygdive/c/some/path instead of c:\some\path).

The native windows command terminal is pretty lame, take a look at Conemu.

I'm not aware of any bash IDE, but there are a plethora of windows text editors with decent syntax highlight for bash scripts. I like Notepad++ and Sublime text (the multiple cursor feature from Sublime rocks!). I don't recommend bash for anything with more than 30 lines, if you ever feel the need for an IDE, perhaps the task is more suited for Python, Ruby or Perl (IMHO Python is more maintainable).

Maximus
  • 10,751
  • 8
  • 47
  • 65
Paulo Scardine
  • 73,447
  • 11
  • 124
  • 153
10

The Bash shell is coming to Windows 10 in the upcoming Anniversary Update (Redstone).

The Bash shell is coming to Windows. Yes, the real Bash is coming to Windows, said Microsoft's Kevin Gallo at Build 2016 keynote. This is not a VM [Virtual Machine]. This is not cross-compiled tools. This is native."

Here's the steps to run Bash on Windows 10 OS:

  1. Open the Windows Start menu
  2. Type "bash" [hit enter]
  3. Which opens a console running Ubuntu's /bin/bash with full access to all of Ubuntu user space

Yes, you are right, that means apt, set, ssh, rsync, find, ls, grep, awk, sed, sort, xargs, md5sum, gpg, curl, wget, apache, mysql, python, perl, ruby, ruby gem, php, gcc, tar, vim, emacs, diff, patch, nano...and most of the tens of thousands binary packages available in the Ubuntu archives!

Reference

  1. Step-vise Guide to Enable Windows 10’s Ubuntu Bash Shell (Windows Subsystem for Linux)

  2. The Bash shell is coming to Windows 10 in the upcoming Anniversary Update (Redstone).

  3. Run native Bash on Ubuntu on Windows

Community
  • 1
  • 1
Vineet Choudhary
  • 7,433
  • 4
  • 45
  • 72
5

Since you need to write linux shell scripts, you are learning Linux. So you should install Linux on your machine (preferably on its own partition and boot from it, otherwise in a VM).

Using cygwin or whatever imitation of Linux shell is not using Linux. You'll learn a lot more by installing and using Linux (and by developing on it with an editor like emacs or gedit or gvim ....). Also, take advantage that Linux is almost entirely free software, so you can study its source code and improve it.

Not installing Linux is not doing yourself a favor.

I believe cygwin is for those who love Linux but have to use Windows. It cannot give you the entire Linux feeling (e.g. you won't be able to write shell scripts looking into /proc which does not exist in Windows, even with cygwin).

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
2

If you want to use a simple environment emulating all Linux environment as alternative to cygwin (more lightweight) you can try mingw and you can use notepad++ or emacs or vim to provide some syntax highlight on sh scripts.

lmedinas
  • 314
  • 2
  • 13
2

Everyone has said to go full Linux or use various mocks. Cloud9.io is a good option if you don't need that much. You can set up a "workspace" which can be accessed online, lets you write in literally any language similar to np++, but the best part is, it's an online Linux, so you have a terminal, with all your shell commands - no mock up, no dual boot.

The downside to this is that the free users aren't given that much power, so if you wanted to execute some high-level maths or output a large image, it will crash as you will be using too much memory. But it is still really worth getting into, it's only ever crashed once on me, and I do some pretty memory-intensive things.

kittykittybangbang
  • 2,380
  • 4
  • 16
  • 27
mdave16
  • 177
  • 1
  • 11
1

There is cygwin , that's a linux console for windows.. so you can execute all the linux command with it.

Guillaume le Floch
  • 1,083
  • 2
  • 11
  • 23
1

Install Cygwin to execute the commands. However you can use NotePad++ as editor which has native windows binaries.

http://www.cygwin.com/

http://notepad-plus-plus.org/

Einz
  • 11
  • 2
1

For Eclipse Luna Should use this one old version fails on UI error

Help > Install New Software… > Add… 

Name: ShellEd

Location: http://sourceforge.net/projects/shelled/files/shelled/update/

Robert
  • 5,278
  • 43
  • 65
  • 115
Ivor
  • 578
  • 1
  • 11
  • 27
-1

I had a similar problem. I like both Linux and Windows, and I am working on both systems, but for programming (and generally, for text editing) I use Windows, for different reasons. For example, I write C/C++ code on Windows, using the Windows DevC++ IDE, then I can compile this project on Linux, by sharing the files on LAN. Now I have to write long scripts, and I would like to do it in a similar way. Ok, maybe its a special request, but maybe I am not the only one who works in such a mixed environment. First, I tried notepad++ (it is suggested by others as well), but does it support syntax highlight for Linux scripts? I didn't found this feature... Then I tried gedit compiled for Windows. It requires the GTK library installed (actually it was already on my Windows). Gedit has syntax highlight for scripts! So I suggest using gedit for Windows for this case. The edited script can not directly be started/tested with it, but for editing, it is fine!