brew install tmux


Split terminal:

  • horizontally: Ctrl b "
  • vertically: Ctrl b %

Move between panes:

  • Ctrl b <arrow key>

(although this interfered with a Mac keyboard shortcut)



curl: PUT

Testing curl PUT commands.

Start by creating an HTTP PUT server:

# python -m SimpleHTTPPutServer 8080
import SimpleHTTPServer
import BaseHTTPServer

class SputHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_PUT(self):
        print self.headers
        length = int(self.headers["Content-Length"])
        path = self.translate_path(self.path)
        with open(path, "wb") as dst:

if __name__ == '__main__':

and run with `python`


curl -XPUT -H "Content-Type: application/json" http://localhost:8000 -d '{"test": null}'

and now you can mess around creating arbitrary PUT commands.


  1. spaces don’t matter between -H and quotes.


is the same as:

-H "Content-Type

2. Double quotes == Single quotes. E.g.

-H'Content is OK

3. argument to -dmust be surrounded in quotes. E.g.

-d 'test=test' is OK.

-d test=test is NOT OK.

E.g. see examples here:


curl: tips – silent, using variables in bash


-s=> silent – so no Progress bar

-S=> don’t output errors

bash variables

Using a variable in a curl call within Bash – remember to double-escape quotes. E.g.

curl -X POST -H 'Content-type: application/json' --data "{\"text\": \"${message}\"}"

processing curl output

e.g. I wanted to count the lines from a GET for an Elasticsearch nodes. This seemed the obvious:

curl 0:9200/_cat/indices?v&health=yellow | wc -l

but there are a few things wrong here.

1. it outputted everything to the terminal including all the green nodes and then seemed to hang until I hit Enter – not what I was expecting


there’s an ampersand character in the URL.

2. also there’s progress output from curl


silence with -s

curl -s "0:9200/_cat/indices?v&health=yellow" | wc -l

3. you still get the header from elasticsearch. i.e.

health status index uuid pri rep docs.count docs.deleted store.size



Finding stuff – find, grep, silver searcher, ripgrep

Here’s how to find stuff in a directory:

grep -r <keyword> .


find . -type f -exec grep <keyword> {} \; -print

or, to exclude a directory:

grep -r --exclude-dir=<directory> <keyword> .


And silver searcher is pretty neat.

e.g. ag <keyword> .

Respects your .gitignore!


Having said that, it doesn’t recognise ** patterns in your .gitignore.

If that’s an issue you might want to try ripgrep.

Incredibly, ripgrep posts timings that are 5x faster than Silver Searcher.


sudo: How do you grant sudo access and other notes?

To grant sudo access to a user, use `visudo`


Why does #includedir start with a # when setting up a sudo environment?

Normally # would be used to create a comment. However, here they’re used to be more inline with C – i.e. to include files. E.g.

#includedir /etc/sudoers.d

And in this directory an included file with:

<your username> ALL=(ALL) NOPASSWD:ALL

will mean you get sudo access.



  • your sudoers file may need to be 400 or 440
  • the format of the line are the details for access. i.e. which <user> <terminal> <users you want access as> <commands> so you might see this:
    • root ALL=(ALL) ALL
  • NOPASSWD: or NOPASSWD:<space> means don’t ask for a password