Git Ready and the ZSH Prompt

Posted by matt
on Friday, January 30

Git is one of those programs, like, say vim, which contains more functionality than it seems humanly possible to grasp. Thankfully, there are sites like gitready, which are designed to help us mere mortals to grasp the awesomeness.

I’m very pleased to be able to report that a bit of awesomeness that I’ve been involved in has been listed. Have a look at the ZSH Git Status page and you might see what I mean. That’s right: zshkit is mentioned.

If you’ve not read any of my other posts on it, zshkit is a project, started by Bryce “BonzoESC” Kerley, and forked by various people (I think I just had the honour of being the furthest up the network graph).

Over the next few days, I’m hoping to implement the vcs_info stuff mentioned in the git-ready comments.

Refactoring Commands in the MATLAB Bundle

Posted by matt
on Saturday, November 22

Sometimes, after seeing a few things, concepts collide (like icebergs, perhaps), and I come up with ideas I think are cool. Here’s one of those:


Refactoring with the MATLAB bundle from Matt Foster on Vimeo.

For those of you who prefer some code, say you have a big long ugly line of code. You know it’s bad, but it works and you don’t want to break it. Here’s an example, very, very loosely based on some Matlab code I saw at work:

The obvious thing to do, is pull out that evil range -pi:0.1:pi. With the new ‘Introduce variable’ command (bound to ⌃⇧C, by default), you can do this be selecting any on of them, and running the command.

You’ll see a dialogue box asking you for a name for you new variable, and after you press OK, you’ll see the following:

Much better. You can also repeat the process to further simplify the line, and the command will insert the new variable before the first instance it finds. Cool hey?!

This command is also general enough that is should work for most languages that use assignments based on =. For more info on this concept, see refactoring.com, which I shall also be scouring for more ideas.

Announcing the IPython TextMate Bundle

Posted by matt
on Friday, November 14

After being shown the huge potential of mixing TextMate with IPython via a little applescript, I started work on the IPython TextMate bundle. I also set up a google group, and talked to the ipython-users mailing list. Their response was great, and they’ve allowed us to discuss the project on the ipython-dev list, if we tag message subjects with [TextMate]. There’s also a possibility that we can distribute the bundle with IPython in the future!

Current features in the bundle are mostly related to interaction with IPython in a Terminal (specifically Terminal.app), and make use of applescript, and include:

  • running the current file in IPython
  • running the current line / selection in IPython
  • running the current file / selection / line in IPython with the profiler enabled
  • toggling the state of the debugger (setting this to ON will switch into the debugger when an exception occurs)
  • entering the debugger
  • adding breakpoints to the current file
  • removing those breakpoints
  • growl notification of salient points
  • rudimentary syntax highlighting of ipythonrc files, including warnings about broken comments (you can’t have a directive and a comment on the same line)
  • commands for editing the ipythonrc file and .ipython directory
  • built in help

Most of these functions are accessed by pressing (⌃⇧I), which gives you a list from which you can select the item you wish to activate. This is similar to the Git / Svn bundles. This means you need only remember one shortcut.

Re: ipython_menu
Uploaded with plasq’s Skitch!

You can grab this now, from GitHub or GetBundles. Please send feedback, ideas or comments to the ipython-dev mailing list, the google group, or directly to me.

Z-shell productivity: the prompt and title

Posted by matt
on Monday, October 13

I’ve recently been playing with a cool project on GitHub: zshkit . It’s a basically just way of organising your zsh config files, but it’s inspired me to look at improving my shell productivity and I hope to post a few times about this.

One of the many changes I made to my fork of zshkit, is to minimise the prompt. It’s something I’ve not really considered before, and I’ve pretty much always used something a lot like gentoo’s default. Here’s a screenshot of my new prompt and title:

Minimalist Prompt

The top line shows the prompt when outside of a git repository and the bottom shows how it looks from within one. Normally, it shows the current directory on the left and the last command’s exit status (a yellow $ means a failure). When I’m inside a git repository, it shows the current branch, with the branch name coloured cyan when the repository is clean and magenta when there are pending changes.

This only really works when coupled with a decent title in your terminal. Whilst looking around, I found _why’s which seems to work really well and is what you can see at the top of the screenshot. The next step would seem to be _why’s screenrc, but I don’t really ever use screen, despite being aware of the awesomeness.

My prompt is it github, with everything else:

  • prompt_git_setup
  • to use it, you need something like this: git-prompt
  • and something like this in your rc files:

    autoload promptinit && promptinit && prompt git
    

It’s probably easier to fork your own zshkit and go from there.

Getting a working Gnuplot for the TextMate bundle

Posted by matt
on Monday, September 01

I’ve been looking at getting a good build of gnuplot with everything I need for the bundle, and so I’ve tried various versions.

My currently recommended way of getting gnuplot is this:

fink install gnuplot-nox

This will automatically build and install a gnuplot with pdflib and aquaterm support, as well as everything else you’re likely to need. This only thing that it misses out it X11 support, which I don’t want and you probably don’t either! Aquaterm is a lot more convenient, and fast. Unfortunately, there’s isn’t a binary build of this in `fink` yet, but fingers crossed that there will be soon.

I’ve put this information in a wiki page on GitHub. I’ll try and keep that up to date with my current recommendation.