Configs
Introduction:
This page will list a few of my config files.
.zsh*
Zsh is a very powerful shell. It's power is only matched by it's awesome configurability - which can be quite daunting at first glance. Luckily, though, there are lots of people zsh config files online (have a look). There's also the really useful Zsh-lovers package, which is part of GRML is available as a .deb.
My Zsh config files are a mish mash of bits I've found on the 'net, and so you should realise that the coolness isn't mine - so these files can't be CC licensed - except for the.shrcs directory,
which was my idea!
Have a look at my Zsh config files. (Dependent of my work machine being switched on
.dircolors
Despite being English, and so wishing it was spelt differently, I
think that dircolors is cool. In case you aren't already
aware, dircolors works by setting the environment variable
that ls uses when you tell it to use colour (most distro
enable this in the default bash skeleton files).
Start by adding
eval $(dircolors -b ~/.dircolors)
to your bashrc so that it gets run when you log in, and
then tweaking ~/.dircolors so that things look how you
like them.
Start by trying things like
.swp 01;30
which makes vim swap files fade very dark grey, or
*tags 01;32
Which makes ctags files green. You can also highlight specific files, for example readme files using something like:
*README 01;31 *readme 00;31
The possibilities are endless, you could make all your source code one colour, all your docs another colour - or just make everything look stupid; it's up to you.
Download my .dircolors
as a starting point, and go from there.
.vimrc
I'd like to update the old saying 'An Englishman's Home is his Castle' by saying 'A Hacker's Home is his Editor' but that's far too cliched, so forget I did. Still, you get the idea - having an environment you're comfortable in is a very important part of everyday life. In The Pragmatic Programmer Hunt and Thomas stress how important it is to find an editor you like and make yourself comfortable. Vim lets you do just that by being almost totally configurable.
All my .vimrc does is set a few handy options, and
overide a few defaults, but it should help give you an idea of
how easily things can be added or changed.
A few of the things in the config file will require some downloads, the most notable are:
- Biogoo. The one and only GVim theme. This is possibly the best theme in the world :)
- My MatSkell function, which envokes a ruby script
matlabSkell.rbwhich creates skeleton Matlab files. To use it, write a line something like:[c, d] = makeMovie(input) % optional desc.
Then press the button you have assigned to call the function (in my case, that's F5. Vim calls the script using the current line as it's argument, and then switches the current buffer to one containing the new file - much quicker. The content of the file will be something like:
matt@zenith ~ $ cat makeMovie.m function [c, d] = makeMovie(input) % optional desc. % function a = makeMovie(input) % optional desc. % % Matt Foster <ee1mpf@bath.ac.uk>
Download ruby/matlabSkell.rb
If you install a Vim package which is built with ruby support, you can use Ruby directly in Vim (see help ruby). The ruby garden VimRubyInterface page has some cool ideas to start you off, like an XMMS interface and some crazy on the fly ruby evaluation.
I use these mappings in my config to allow me to easily round sets of figures to two decimal places:
map
,,t :. rubydo $_.gsub!(/(\d+\.\d+)/) { sprintf("%.*f", 2, $1.to_f) } map ,,td :rubydo $_.gsub!(/(\d+\.\d+)/) { sprintf("%.*f", 2, $1.to_f) } The code loops through the input range (which depends on which mapping is invoked), grepping for floating point numbers, and replacing them with rounded versions. I could probably do it a bit more elegantly, but I've not got it worked out that far yet. By default,
rubydoloops over the entire file, which means that the second rounds ever floating point number in the current file to two deciaml places. To tweak the number of d.ps, change the 2 in the sprintf to the number you want.Vim/Ruby Configuration Files is the place to get the latest syntax, indentation and ftplugins for editing ruby in vim. This is best used with a
shiftwidthof 2.Perfect Ruby folding. Get this, and then keep it in a subdirectory under ftplugins. Mine's called
~/.vim/ftplugin/ruby/, that way it won't squash the settings provided above.Vimspell is a general spelling suite for vim/gvim, and is worth looking at. It's especially good for emails etc.
Also good for emails, are the functions provided by Charles Mauch.
Download my .vimrc.
Note: I'm afriad this is out of date. I'll try and update it
soon.
.ctags
This is trivial really, but if you want to use the cool tags feature
of vim for Matlab/Octave, you need to add the following to your
~/.ctags file:
--langdef=matlab --langmap=matlab:.m --regex-matlab=/^function.*=[ \t]([,a-zA-Z0-9_]+)/\1/f,function/
.lftprc
lftp is a really, really good file transfer program, with support for a lot more than just ftp. This tutorial gives you an idea of just how powerful it is.
My lftp config file (~/.lftprc) contains the
floowing goodness:
set cmd:prompt "\[\e[1;37m\]lftp\] \[\e[01;32m\]\]\u\@\h \[\e[01;34m\]\]\\W $ \[\e[00m\]\]" set cmd:default-title "lftp \h:\w" set cmd:csh-history on
This sets the window title to the current site, and sets the prompt to look like my zsh prompt: