Make a Bash Script Executable

If you constantly run the same set of commands at the command line, why not automate that?

I found myself typing the same things over and over to deploy this website. Here’s how I encapsulated it into a script that saves me keystrokes at the command line.

1) Create a new text file with a .sh extension.

I created a new file called for my website.

2) Add #!/bin/bash to the top of it.

This is necessary for the “make it executable” part.

3) Add lines that you’d normally type at the command line.

As an example, here’s the full contents of the file I use to deploy general updates to

5git add .
7git commit -m "Updates"
9git push

4) At the command line, run chmod u+x

I ran chmod u+x to make mine executable.

5) Run it whenever you need!

Now, whenever I deploy changes to my website, I run ./ and boom. Done.

comments powered by Disqus