Using Swift for Shell Scripting

I’ve been a command line guy since I started coding (DOS anyone?). Since moving to a Mac my go to scripting language over the years has always been either Bash or Python.

Filip W wrote about using Swift as a general purpose scripting language:

The obvious advantage of such approach is that you now have the same single language to handle iOS programming, OS X app programming and generic system/automation tasks that you might want to perform from the command line.

There are some tweaks you’ll need to make regarding selection of an Xcode version that supports Swift (Xcode 6.x and above). Rob Bazinet has some recommendations about Swift’s Read-Eval-Print-Loop (REPL) by using an alias in your bash profile. Once the production version of Xcode 6 is released, running scripts should be much easier.