skip to main content

ratbum's Great Blog

A collection of hacks.

A Friendly Octopus

I really liked the look of octopress, but I wasn’t keen on typing rake new_post[bla] every time I wanted a new post, so I made this bash script to neaten it up a little.

I’m running Mac OS 10.8, so I did have to install bash 4 to get the fall throughs working in the switch statement.

octo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash

case "$1" in
      init)
          git clone git://github.com/imathis/octopress.git .
          bundle install
          rake install
          ;;
      newpost)
          rake new_post["$2"]
          ;;
      newpage)
          rake new_page["$2"]
          ;;
      gen)
          ;&
      generate)
          rake generate
          ;;
      watch)
          rake watch
          ;;
      preview)
          rake preview
          ;;
      up)
          ./upload.sh
          ;;
      genup)
          octo gen
          octo up
          ;;
      *)
          echo $"Usage: octo {init|newpost|newpage|generate|watch|preview|up}"
          exit 1
esac

In case you’re wondering, upload.sh is just another bash script which automatically uploads all the files in ./public.

Mine looks something like this. Pretty dumb. It would be better if it detected what had actually changed, but that’s something I’ll intend to do and never get around to.

upload.sh
1
2
3
4
#!/bin/bash
cd public
ncftpput -R -v -u "the_best_user" -p "redacted_password" ftp.ratbum.com / .
cd ..

Hello World

You shouldn’t be reading this. It’s a test.