Tmux scripting

I’ve been using tmux for a while no to manage my terminal sessions. One thing I kept on doing was after starting tmux that I would be manually adding windows, splitting them and issuing commands in each pane such as echoing the contents of log files with tail -f.

I had heard about scripting tmux before but never really looked into it yet, until now. Since I solely use the key bindings I had to figure out how to issue these commands without them. Turns out this is pretty easy and it’s documented in the man page.

Here’s an example of a tmux script I just added to Maximus-Web.

#!/bin/bash
SESSION=$USER

tmux -2 new-session -d -s $SESSION

# Setup a window for tailing log files
tmux new-window -t $SESSION:1 -n 'Logs'
tmux split-window -h
tmux select-pane -t 0
tmux send-keys "tail -f /vagrant/maximus.log" C-m
tmux select-pane -t 1
tmux send-keys "tail -f /vagrant/maximus-worker.log" C-m
tmux split-window -v
tmux resize-pane -D 20
tmux send-keys "tail -f /vagrant/maximus-mojo.log" C-m
# Setup a CoffeeScript compiler/watchdog pane
tmux select-pane -t 0
tmux split-window -v
tmux resize-pane -D 20
tmux send-keys "coffee -o /vagrant/root/static/js/ -cw /vagrant/root/coffee/" C-m

# Setup a MySQL window
tmux new-window -t $SESSION:2 -n 'MySQL' 'mysql -uroot'

# Set default window
tmux select-window -t $SESSION:1

# Attach to session
tmux -2 attach-session -t $SESSION

You can view the (up to date) origin of this script at GitHub.

So what exactly does this script do?

  1. It creates a new tmux session.
  2. It creates a new window called ‘Logs’ which is split into a grid of 2×2 with the bottom 2 panes being smaller in size (height). In every pane a command is executed. For example in pane 0 the command tail -f /vagrant/maximus.log gets executed.
  3. A second window called ‘MySQL’ is created which runs the mysql -uroot command.
  4. Then we switch back to the first window (actually second, as tmux pane numbers start with 0) which is the window that shows us the contents of these log files.
  5. Finally we attach to the tmux session.

The added benefit of this small script is that from now on all I have to do is run it and my tmux session will be configured for this specific project (Maximus in this case).

I’ve also found some other useful tmux resources as well which are listed below:

DiggEmailRedditShare

Any interest in a module manager for Monkey?

Having done a module manager for BlitzMax called Maximus I’ve received one question several times: will you also make a module manager for Monkey?

My answer at the time was ‘no’. Simply because I didn’t use Monkey nor was I planning to. To be honest, I’m still not planning on using Monkey myself. But there are lots of people who do use Monkey and with the (my assumption) amount of available modules I think Monkey would benefit from a module manager.

Sure, Monkey has a module page which lists some modules, but that’s just a listing. When in time there are more and more modules being released for Monkey it’ll become more tedious and painful to manage all your (installed) Monkey modules.

So I’d like to know if Monkey users have any interest in a module manager which for users will allow them to easily install and update modules. For module authors it’ll be an easy way to publish a module to a central repository (like Maximus does).

That way everyone can benefit from a central repository hosting these modules.

Why am I asking if there’s any interest in this? I’ve got some ideas and I think it’ll make up for a nice summer project. I’m interested to hear peoples opinions on this which I can use to decide to start it all up.

——————————————————————————————————————————

This is a cross post from a topic I started at the BlitzMax forum. Which has also been copied to the Monkey forum. I decided to put it on here as well.

DiggEmailRedditShare

htbaapub.zmq 0.03 released

I’ve released htbaapub.zmq 0.03, a wrapper for ZeroMQ. This release fixes data corruption when sending messages. The corruption was caused by BlitzMax collection String data a bit too soon. This was a tough one to find as garbage collectors are hard to predict.

As of now htbaapub.zmq also contains several unit tests to make sure everything works as expected. It doesn’t have full coverage, but I’ll improve this in the future. In case anyone is interested, the test module used is bah.maxunit.

You can install this version with maximus, download it or fetch the sources from GitHub.

DiggEmailRedditShare

htbaapub.zmq 0.02 released – ZeroMQ for BlitzMax

This is just a short announcement on my Blog to let people know I’ve been busy wrapping ZeroMQ (or ZMQ) for BlitzMax. The result of this a new module called htbaapub.zmq. It’s available from the Maximus website, meaning you can install it using Maximus. If you rather fetch the Git repository that’s possible as well.

The module is still very much a Work In Progress. Most of ZMQ’s functions are available from BlitzMax and both Windows and Linux are supported. It should work fine on a Mac as well, but I’m unable to verify since I don’t actually own one.

A couple of examples are included as well. Have fun playing with ZMQ and if you encounter any bugs, please report them. I’ll then be able to look into fixing them.

DiggEmailRedditShare

Maximus 1.1.1 released

Earlier today I released Maximus 1.1.1. Maximus is a BlitzMax module manager. With Maximus it’s possible to easily install and update BlitzMax modules which are provided by 3rd party module developers.

Version 1.1.1 improves the usability for the GUI users. If maximus-gui can’t find your BMXPATH it will now present you with a directory dialog in which you can select your BlitzMax installation directory. Another improvement is in communicating back to the user when a certain action has finished.

Binaries for both Windows and Linux are available from maximus.htbaa.com/client as well as an installer for Windows.

DiggEmailRedditShare