<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jabbering Giraffe &#187; vim</title>
	<atom:link href="http://happygiraffe.net/blog/tag/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<lastBuildDate>Wed, 19 Oct 2011 10:40:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>assignment alignment in vim</title>
		<link>http://happygiraffe.net/blog/2009/07/09/vim-assignment-alignment/</link>
		<comments>http://happygiraffe.net/blog/2009/07/09/vim-assignment-alignment/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 09:42:32 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1551</guid>
		<description><![CDATA[I&#8217;ve just been reading some articles about programming vim from Damian Conway. * Scripting the Vim editor, Part 1: Variables, values, and expressions * Scripting the Vim editor, Part 2: User-defined functions The latter has a very useful example. function &#8230; <a href="http://happygiraffe.net/blog/2009/07/09/vim-assignment-alignment/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been reading some articles about programming vim from <a href="http://en.wikipedia.org/wiki/Damian_Conway">Damian Conway</a>.</p>
<p>* <a href="http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html">Scripting the Vim editor, Part 1: Variables, values, and expressions</a><br />
* <a href="http://www.ibm.com/developerworks/linux/library/l-vim-script-2/index.html">Scripting the Vim editor, Part 2: User-defined functions</a></p>
<p>The latter has a <em>very</em> useful example.</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #804040;">function</span> AlignAssignments<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
   <span style="color: #C5A22D;">&quot; Patterns needed to locate assignment operators. &quot;</span>
   <span style="color: #804040;">let</span> ASSIGN_OP   = <span style="color: #C5A22D;">'[-+*/%|&amp;]<span style="">\?</span>=<span style="">\@</span>&lt;!=[=~]<span style="">\@</span>!'</span>
   <span style="color: #804040;">let</span> ASSIGN_LINE = <span style="color: #C5A22D;">'^<span style="">\(</span>.<span style="">\{</span>-}<span style="">\)</span><span style="">\s</span>*<span style="">\(</span>'</span> <span style="color: #000000;">.</span> ASSIGN_OP <span style="color: #000000;">.</span> <span style="color: #C5A22D;">'<span style="">\)</span>'</span>
&nbsp;
   <span style="color: #C5A22D;">&quot; Locate block of code to be considered (same indentation, no blanks) &quot;</span>
   <span style="color: #804040;">let</span> indent_pat = <span style="color: #C5A22D;">'^'</span> <span style="color: #000000;">.</span> <span style="color: #25BB4D;">matchstr</span><span style="color: #000000;">&#40;</span><span style="color: #25BB4D;">getline</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'.'</span><span style="color: #000000;">&#41;</span>, <span style="color: #C5A22D;">'^<span style="">\s</span>*'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">.</span> <span style="color: #C5A22D;">'<span style="">\S</span>'</span>
   <span style="color: #804040;">let</span> firstline  = <span style="color: #25BB4D;">search</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'^<span style="">\%</span>('</span> <span style="color: #000000;">.</span> indent_pat <span style="color: #000000;">.</span> <span style="color: #C5A22D;">'<span style="">\)</span><span style="">\@</span>!'</span>, <span style="color: #C5A22D;">'bnW'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">+</span> <span style="color: #000000; font-weight:bold;">1</span>
   <span style="color: #804040;">let</span> lastline   = <span style="color: #25BB4D;">search</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'^<span style="">\%</span>('</span> <span style="color: #000000;">.</span> indent_pat <span style="color: #000000;">.</span> <span style="color: #C5A22D;">'<span style="">\)</span><span style="">\@</span>!'</span>,  <span style="color: #C5A22D;">'nW'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">-</span> <span style="color: #000000; font-weight:bold;">1</span>
   <span style="color: #804040;">if</span> lastline <span style="color: #000000;">&lt;</span> <span style="color: #000000; font-weight:bold;">0</span>
       <span style="color: #804040;">let</span> lastline = <span style="color: #25BB4D;">line</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">'$'</span><span style="color: #000000;">&#41;</span>
   <span style="color: #804040;">endif</span>
&nbsp;
   <span style="color: #C5A22D;">&quot; Find the column at which the operators should be aligned. &quot;</span>
   <span style="color: #804040;">let</span> max_align_col = <span style="color: #000000; font-weight:bold;">0</span>
   <span style="color: #804040;">let</span> max_op_width  = <span style="color: #000000; font-weight:bold;">0</span>
   <span style="color: #804040;">for</span> linetext <span style="color: #804040;">in</span> <span style="color: #25BB4D;">getline</span><span style="color: #000000;">&#40;</span>firstline, lastline<span style="color: #000000;">&#41;</span>
       <span style="color: #C5A22D;">&quot; Does this line have an assignment in it? &quot;</span>
       <span style="color: #804040;">let</span> left_width = <span style="color: #804040;">match</span><span style="color: #000000;">&#40;</span>linetext, <span style="color: #C5A22D;">'<span style="">\s</span>*'</span> <span style="color: #000000;">.</span> ASSIGN_OP<span style="color: #000000;">&#41;</span>
       <span style="color: #804040;">if</span> left_width <span style="color: #000000;">&gt;</span>= <span style="color: #000000; font-weight:bold;">0</span>
           <span style="color: #804040;">let</span> max_align_col = <span style="color: #25BB4D;">max</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>max_align_col, left_width<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
           <span style="color: #804040;">let</span> op_width      = <span style="color: #25BB4D;">strlen</span><span style="color: #000000;">&#40;</span><span style="color: #25BB4D;">matchstr</span><span style="color: #000000;">&#40;</span>linetext, ASSIGN_OP<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
           <span style="color: #804040;">let</span> max_op_width  = <span style="color: #25BB4D;">max</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>max_op_width, op_width <span style="color: #000000;">+</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
       <span style="color: #804040;">endif</span>
   <span style="color: #804040;">endfor</span>
&nbsp;
   <span style="color: #C5A22D;">&quot; Code needed to reformat lines so as to align operators. &quot;</span>
   <span style="color: #804040;">let</span> FORMATTER = <span style="color: #C5A22D;">'<span style="">\=</span>printf(&quot;%-*s%*s&quot;, max_align_col, submatch(1),
   <span style="">\ </span>                                   max_op_width,  submatch(2))'</span>
&nbsp;
   <span style="color: #C5A22D;">&quot; Reformat lines with operators aligned in the appropriate column. &quot;</span>
   <span style="color: #804040;">for</span> linenum <span style="color: #804040;">in</span> <span style="color: #25BB4D;">range</span><span style="color: #000000;">&#40;</span>firstline, lastline<span style="color: #000000;">&#41;</span>
       <span style="color: #804040;">let</span> oldline = <span style="color: #25BB4D;">getline</span><span style="color: #000000;">&#40;</span>linenum<span style="color: #000000;">&#41;</span>
       <span style="color: #804040;">let</span> newline = <span style="color: #25BB4D;">substitute</span><span style="color: #000000;">&#40;</span>oldline, ASSIGN_LINE, FORMATTER, <span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
       <span style="color: #804040;">call</span> <span style="color: #25BB4D;">setline</span><span style="color: #000000;">&#40;</span>linenum, newline<span style="color: #000000;">&#41;</span>
   <span style="color: #804040;">endfor</span>
endfunction
&nbsp;
nmap <span style="color: #668080;">&lt;silent&gt;</span> ;= <span style="color: #000000;">:</span><span style="color: #804040;">call</span> AlignAssignments<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #668080;">&lt;cr&gt;</span></pre></div></div>

<p>This allows you to line up assignments so that all the the equals appear in a column.  I find this much easier to read.</p>
<p>To use this code, paste it into a file <code>~/.vim/plugin/AlignAssignments.vim</code>.  It&#8217;ll get loaded automatically.  From then on you use it by going to a group of assignments and hitting <code>;=</code>.  Blam!</p>
<p>There are <a href="http://www.vim.org/scripts/script_search_results.php?keywords=align&#038;script_type=&#038;order_by=rating&#038;direction=descending&#038;search=search">other alignment plugins</a> available in the <a href="http://www.vim.org/scripts/">vim scripts archive</a>, but this one is relatively small &#038; simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/07/09/vim-assignment-alignment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing Byte Order Marks</title>
		<link>http://happygiraffe.net/blog/2009/02/19/removing-byte-order-marks/</link>
		<comments>http://happygiraffe.net/blog/2009/02/19/removing-byte-order-marks/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 11:10:35 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1476</guid>
		<description><![CDATA[I keep getting sent files, which are encoded in UTF-8, but include a BOM. Which is completely unnecessary. Thankfully, it&#8217;s pretty easy to remove with vim. Just load up the file and type in :set nobomb (docs for the bomb &#8230; <a href="http://happygiraffe.net/blog/2009/02/19/removing-byte-order-marks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I keep getting sent files, which are encoded in UTF-8, but include a <abbr title="Byte order mark"><a href="http://en.wikipedia.org/wiki/Byte-order_mark">BOM</a></abbr>.  Which is completely unnecessary.  Thankfully, it&#8217;s pretty easy to remove with <a href="http://www.vim.org/">vim</a>.  Just load up the file and type in <code>:set nobomb</code> (<a href="http://www.vim.org/htmldoc/options.html#'bomb'">docs for the bomb option</a>) and save.  Problem successfully defused!</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2009/02/19/removing-byte-order-marks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vim completion</title>
		<link>http://happygiraffe.net/blog/2008/10/30/vim-completion/</link>
		<comments>http://happygiraffe.net/blog/2008/10/30/vim-completion/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 14:54:10 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1404</guid>
		<description><![CDATA[I&#8217;ve just found something rather useful in vim: :set wildmode. Normally in vim, you can use TAB to complete filenames. So you enter :e some/ve&#60;TAB&#62; and vim pads it out to :e some/very_long_filename.html. Lovely. But in a directory full of &#8230; <a href="http://happygiraffe.net/blog/2008/10/30/vim-completion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just found something rather useful in <a href="http://www.vim.org/">vim</a>:  <a href="http://www.vim.org/htmldoc/options.html#%27wildmode%27">:set wildmode</a>.  Normally in vim, you can use TAB to complete filenames.  So you enter <code>:e some/ve&lt;TAB&gt;</code> and vim pads it out to <code>:e some/very_long_filename.html</code>.  Lovely.</p>
<p>But in a directory full of files with similar prefixes, it&#8217;s less than helpful.  I hit <code>:e acc&lt;TAB&gt;</code> and vim expands to <code>:e acc_click_here_to_continue.html</code>.  But then I need to backspace all the way back so it reads <code>:e acc</code> and hit TAB again.  This is a pain.</p>
<p>But, if you stick <code>set wildmode=longest,full</code> into <code>~/.vimrc</code>, then vim stops when it&#8217;s completed the longest unique prefix (&#8220;acc&#8221;) and gives you a chance to type.  Or, if you just keep banging on the TAB key like a deranged gibbon it will start rotating through all the possible completions.  But by stopping at that point, I get a chance to intervene.</p>
<p>It sounds like a teeny-tiny little thing.  But it&#8217;s one less thing that&#8217;s getting in the way of me doing things.</p>
<p>That said, any time saved has already been wiped out by writing this blog entry.  <img src='http://happygiraffe.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2008/10/30/vim-completion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My Sysadmin Toolbox</title>
		<link>http://happygiraffe.net/blog/2006/04/17/my-sysadmin-toolbox/</link>
		<comments>http://happygiraffe.net/blog/2006/04/17/my-sysadmin-toolbox/#comments</comments>
		<pubDate>Mon, 17 Apr 2006 10:32:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[lsof]]></category>
		<category><![CDATA[multitail]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[strace]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[wiki]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/04/17/my-sysadmin-toolbox/</guid>
		<description><![CDATA[After seeing lots of these at Linux.com recently, I thought I&#8217;d try to come up with my own list. I used to be a sysadmin (I&#8217;m now a programmer), and I&#8217;ve long felt that you really a good set of &#8230; <a href="http://happygiraffe.net/blog/2006/04/17/my-sysadmin-toolbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After seeing lots of these at <a href="http://www.linux.com/">Linux.com</a> recently, I thought I&#8217;d try to come up with my own list.  I used to be a sysadmin (I&#8217;m now a programmer), and I&#8217;ve long felt that you really a good set of tools (and to know how to use them) in order to be most productive.</p>
<ul>
<li>
<p><a href="http://www.zsh.org/">zsh</a></p>
<p>I spend the vast majority of my time at a command line.  Zsh ensures I make best use of my time.  If you&#8217;ve used bash, you might think you know what completion is&#8212;press the tab key and it fills out file names for you.  But zsh takes it to a whole new level.  Not only does it complete file names, but also users, hostnames, option flags, environment variables, PIDs and more.  On top of that, it does it in a context-sensitive manner.  So if you type in &#8220;chown &#8221; and press <span class="caps">TAB</span>, it starts completing usernames.  Type in a space and another <span class="caps">TAB</span> and it starts completing file names again.</p>
<p>On top of that, it allows <em>partial</em> completion.  If I type in <code>/u/l/e/r/</code> and press <span class="caps">TAB</span>, It gets expanded to <code>/usr/local/etc/rc.d/</code>.  This is phenomenally useful.</p>
<p>But it&#8217;s not just completion that zsh is good at.  It&#8217;s also good at <em>globbing</em>.  That&#8217;s turning wildcards into filenames.  In addition to the usual forms of globbing, zsh can glob recursively.  So if I want to look for &#8220;foobar&#8221; in all my files (but not directories), I can do:</p>
<pre>
  % grep foobar **/*(.)
</pre>
<p>The &#8220;<code>**/*</code>&#8221; is the recursive glob, and the &#8220;<code>(.)</code>&#8221; limits it to files and not directories.  You can also limit by user, by timestamp and a few other things.</p>
<p>This is just covering the surface of zsh.  Suffice to say that if you make heavy use of the command line, investing some time in learning zsh will make you vastly more productive.</p>
</li>
<li>
<p><a href="http://www.gnu.org/software/screen/">screen</a></p>
<p>This was mentioned on a few of the other lists as well.  <span class="caps">GNU</span> Screen on the face of it doesn&#8217;t do anything.  You just end up with another command line when you first run it.  But the beauty of it is that if you get disconnected, you can just log back in, run <code>screen -d -r</code> and pick up exactly where you left off.  For me, this is ideal, given the flakiness of my home wireless network.  But you might want to use it so you can shut down your PC at night and pick up where you left off in the morning.</p>
<p>On top of that, screen lets you run multiple command lines at once inside it, log the output and cut&#8217;n&#8217;paste between them.  Think of it as a safety harness for your work.</p>
</li>
<li>
<p><a href="http://samba.anu.edu.au/rsync/">rsync</a></p>
<p>Rsync is one of the closer things to magic that&#8217;s around.  It&#8217;s a simple file copying utility.  But the clever bit is that it only copies the things that have changed.  This doesn&#8217;t sound like much until you&#8217;ve edited several files in a collection which is 200Mb and needs to be on another box.  When rsync tells you it&#8217;s finished and only transferred 10Kb instead of 200Mb, you&#8217;ll really come to appreciate it.</p>
<p>If you&#8217;re still using tar/gzip or zip to create an archive to ship to another computer, stop wasting your time and disk space.  Learn to use rsync and your life will be far more pleasant.</p>
</li>
<li>
<p><a href="http://www.openssh.com/">OpenSSH</a></p>
<p>Thankfully, ssh is pretty ubiquitous these days.  It seems to have mostly worked in its mission to eliminate <a href="http://en.wikipedia.org/wiki/Telnet">telnet</a>.  But it has a few tricks that are worth knowing about.</p>
<p>First, the agent.  One of the nice things about ssh is that it doesn&#8217;t have to rely on sending passwords around.  Instead, you can use public key authentication.  However, even typing in your passphrase can get pretty tedious after a while for every connection.  Enter the ssh-agent.  Just stick <code>eval `ssh-agent`</code> in your startup scripts and then run <code>ssh-add</code> once.  After that, you don&#8217;t get asked for your passphrase any more.  The only caveat is that now you <em>really</em> need to lock your screen when you walk away from it.</p>
<p>Next are the tunnels.  Ssh is able to create network &#8220;tunnels&#8221; in and out of otherwise secure locations.  This is very handy for creating ad-hoc networks.  For example, I&#8217;m allowed to ssh into my work, but not to anything else.  Yet, I can use <a href="http://en.wikipedia.org/wiki/Remote_Desktop_Protocol"><span class="caps">RDP</span></a> to connect to my workstation by running this command:</p>
<pre>
  % ssh -L3389:myworkstation:3389 firewall.mywork.com
  % rdesktop localhost
</pre>
<p>That says: listen on port 3389, and any connections that come in, forward them on to myworkstation port 3389 from the other side of the ssh connection to firewall.mywork.com.</p>
<p>If you&#8217;re on windows, check out <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY</a>.  It&#8217;s got all the features, but wrapped up in a nice <span class="caps">GUI</span> interface.</p>
</li>
<li>
<p><a href="http://people.freebsd.org/~abe/">lsof</a> / <a href="http://docs.sun.com/app/docs/doc/816-5165/6mbb0m9o6?a=view">pfiles</a> / <a href="http://www.freebsd.org/cgi/man.cgi?query=sockstat&#38;sektion=1">sockstat</a></p>
<p>Lsof (List Open Files) is one of the first diagnostic tools that I reach for when I need to understand something.  The purpose is simple: it tells you what files (and network connections) a process has open.  If you&#8217;re wondering where a process is logging to, this might be able to tell you.  Conversely, it can also tell you which processes have a particular file open (usually a lock file).</p>
<p>On Solaris, the pfiles command is similiar.</p>
<p>On a related note, FreeBSD also has the very, very useful sockstat command, which lists all open sockets and what processes hold them open.  The useful bit is that it does this without needing to be root (unlike Linux&#8217;s <code>netstat -anp</code>).</p>
</li>
<li>
<p><a href="http://www.liacs.nl/~wichert/strace/">strace</a> / <a href="http://docs.sun.com/app/docs/doc/816-5165/6mbb0m9ut?a=view">truss</a> / <a href="http://www.freebsd.org/cgi/man.cgi?query=ktrace&#38;sektion=1">ktrace</a></p>
<p>These are the second diagnostic tool that I reach for when something&#8217;s not right.  Unix operating systems have a very clear distinction between userland and kernel, and this tool shows all the points where a program crosses between the two (makes a system call).  If you really want to know how a program is interacting with its environment, these tools will tell you.  It&#8217;s godo for answering questions like:</p>
<ul>
<li>What files is this process opening and closing?</li>
<li>What connections to the network are being made?</li>
<li>What&#8217;s been read in by this program?</li>
</ul>
</li>
<li>
<p><a href="http://www.vanheusden.com/multitail/">multitail</a></p>
<p>A recent addition to my toolbox.  It&#8217;s like <code>tail -f</code>, except that it looks at more than one file at once.  It also does highlighting of search terms.  Dead handy.</p>
</li>
<li>
<p><a href="http://curl.haxx.se/">curl</a></p>
<p>Most of the stuff I do these days involves the web.  Curl is a fantastic little tool for inspecting the web from the command line.  It covers all the protocols you need, and can dump out any information about the transaction.  Want to issue a <span class="caps">PUT</span> request to an <span class="caps">SSL</span> server, verifying the certificate and specifing basic auth?  It&#8217;s got you covered.</p>
</li>
<li>
<p><a href="http://www.vim.org/">vim</a></p>
<p>Everybody needs a good editor.  Vim isn&#8217;t the only choice, but it&#8217;s pretty likely to be available wherever you go.  And once you&#8217;ve started learning how to use it properly, you won&#8217;t go back.  In particular, I can&#8217;t live without <code>^P</code> and <code>^N</code> for doing completion inside the file you&#8217;re editing.</p>
</li>
<li>
<p><a href="http://www.courtesan.com/sudo">sudo</a></p>
<p>If you&#8217;re still using <a href="http://www.freebsd.org/cgi/man.cgi?query=su&#38;sektion=1" title="1">su</a>, then you need help.  Sudo allows you to dole out root access on a much more granular level and you get proper logging of who did what.  If you haven&#8217;t looked at the manual recently, then check out <code>sudo -e</code> for editing a file as another user.  It ensures that you get your regular editor (vim or Emacs) instead of the incredibly unhelpful <a href="http://www.freebsd.org/cgi/man.cgi?query=ed&#38;sektion=1" title="1">ed</a> that root probably defaults to.</p>
</li>
<li>
<p><a href="http://subversion.tigris.org/">subversion</a></p>
<p>Everybody needs version control.  If you&#8217;re editing files, stick them in subversion.  You won&#8217;t regret it.  Particularly when you need to see what those files looked like 6 months ago.</p>
</li>
<li>
<p><a href="http://www.mutt.org/">mutt</a></p>
<p>Every now and again, you need to deal with mailbox files.  Mutt is a great choice for that, thanks to its mini language for filtering mail.  Need delete all mail over 10 days old sent by cron@somehost?  Not a problem.  Even if you don&#8217;t use it on a regular basis, it&#8217;s worth getting familiar with.</p>
</li>
<li>
<p><a href="http://www.gnu.org/software/gdb/">gdb</a></p>
<p>Yes, this is a programmers tool.  But it&#8217;s worth knowing a tiny amount about if you&#8217;re a sysadmin as well.  What for?  It lets you see <em>why</em> something dumped core.  If you find a core file, then do <code>file core</code> to see what program left it behind and then <code>gdb /path/to/program core</code>.  When you&#8217;re inside gdb, type in <code>where</code> and it will (most of the time) give you a stack trace, showing what it was doing at the time of the crash.  This is normally a big help in trying to figure out what went wrong.</p>
<p>You can also use gdb to find out what a running program is doing by specifing a <span class="caps">PID</span> instead of a corefile.</p>
</li>
<li>
<p><a href="http://www.perl.org/">perl</a> / <a href="http://www.python.org/">python</a> / <a href="http://www.ruby-lang.org/">ruby</a></p>
<p>If you perform the same series of actions more than a couple of times, you should consider investing some time in automating the process.  Shell scripts are handy, but can only go so far.  Learning one of these languages will give you a really powerful ability to write your own sysadmin toolbox.</p>
</li>
<li>
<p><a href="http://www.mediawiki.org/wiki/MediaWiki">mediawiki</a></p>
<p>Documentation.  Everybody hates doing it.  Why not make it as easy as possible?  A wiki is the answer to that, and mediawiki is one of the better pieces of wiki software out there.  It&#8217;s pretty simple to get going (although it does depend on MySQL).</p>
<p>Remember: getting it documented is first priority.  Once the information is in the wiki, it can be restructured later.  So long as the information is there, it will be searchable (and hence useful).</p>
</li>
</ul>
<p>Hmmm, that&#8217;s a bit more than the 10 they wanted.  But it&#8217;s a large portion of my regular toolkit.  Hopefully there&#8217;s something useful for other people in there as well&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/04/17/my-sysadmin-toolbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Month of Mac</title>
		<link>http://happygiraffe.net/blog/2006/02/03/a-month-of-mac/</link>
		<comments>http://happygiraffe.net/blog/2006/02/03/a-month-of-mac/#comments</comments>
		<pubDate>Fri, 03 Feb 2006 08:42:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/02/03/a-month-of-mac/</guid>
		<description><![CDATA[It&#8217;s now been a month since my shiny new Mac arrived. Overall, I&#8217;m still really, really happy with it. I&#8217;ve bought NetNewsWire for feed reading and textmate for editing. I&#8217;m a little concerned that I don&#8217;t have the source code &#8230; <a href="http://happygiraffe.net/blog/2006/02/03/a-month-of-mac/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s now been a month since my shiny new Mac arrived.  Overall, I&#8217;m still really, really happy with it.  I&#8217;ve bought <a href="http://ranchero.com/netnewswire/">NetNewsWire</a> for feed reading and <a href="http://www.macromates.com/">textmate</a> for editing.  I&#8217;m a little concerned that I don&#8217;t have the source code for my editor, but we&#8217;ll see how that goes.</p>
<p>I&#8217;m normally a devout Emacs or Vim user, but <a href="http://aquamacs.org/">Aquamacs</a> turned out to be just <em>too</em> different, despite what <a href="http://tbray.org/ongoing/When/200x/2005/11/21/Aquamacs">Tim Bray says</a> about it.  <a href="http://macvim.org/OSX/index.php">Carbon Vim</a> was a bit better, but still felt a little clunky.  TextMate just felt right, and after the recommendations from the rails people, it seemed like a good idea.</p>
<p>The main irritation that I&#8217;ve been having is with the keyboard.  Apple keyboards don&#8217;t come easily to UK Unix users.  The tilde is in the wrong position to start with (it&#8217;s been swapped with backslash), and I find myself continually hitting the wrong one.  Worse is the fact that there&#8217;s no hash key on the keyboard in the UK layout.  Oh all right, you can hit ⌥-3, but that pastes into the shell as <span class="caps">UTF</span>-8 meaning that you can&#8217;t comment things out properly in Vim.  Why?  I have no idea.  But it&#8217;s meant that I&#8217;ve stuck to the US keyboard layout for now, which sucks.</p>
<p>By far and away the worst problem, though is the simple fact that you can&#8217;t copy CDs easily.  The damned machine comes with a CD burner.  It should be a piece of cake to say &#8220;take the bits off of this one, then right them on to this blank disk instead&#8221;.  But no.  The only option is to import into iTunes (converting into <span class="caps">MP3</span>) and then write the low-fi tracks out from iTunes again.  With a 2-second gap between tracks.  That really, badly sucks.  Particularly when I found out that a previous version of <span class="caps">OSX</span> used to come with a &#8220;disk copy&#8221; utility.  Thanks a bunch, Apple.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/02/03/a-month-of-mac/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vim Syntax for Textile</title>
		<link>http://happygiraffe.net/blog/2006/01/25/vim-syntax-for-textile/</link>
		<comments>http://happygiraffe.net/blog/2006/01/25/vim-syntax-for-textile/#comments</comments>
		<pubDate>Wed, 25 Jan 2006 02:50:00 +0000</pubDate>
		<dc:creator>Dominic Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[textile]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://happygiraffe.net/2006/01/25/vim-syntax-for-textile/</guid>
		<description><![CDATA[I&#8217;ve been using textile more and more these days. It&#8217;s quite convenient for writing. But what&#8217;s annoying is that there is no support for it in Vim. So, after a bit of messing around with the vim manual Your own &#8230; <a href="http://happygiraffe.net/blog/2006/01/25/vim-syntax-for-textile/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://textism.com/tools/textile/">textile</a> more and more these days.  It&#8217;s quite convenient for writing.</p>
<p>But what&#8217;s annoying is that there is no support for it in <a href="http://www.vim.org/">Vim</a>.</p>
<p>So, after a bit of messing around with the vim manual <a href="http://vimdoc.sourceforge.net/htmldoc/usr_44.html">Your own syntax highlighted</a>, I now have <a href="http://happygiraffe.net/svn/public/vim/trunk/textile.vim">textile.vim</a>.</p>
<p>It&#8217;s definitely a first attempt at such things.  There&#8217;s a lot that it doesn&#8217;t do.  But for an hours work, it&#8217;s started to highlight textile files well enough for me.</p>
<p><strong>Update:</strong> PlasticBoy has a similar <a href="http://plasticboy.com/markdown-vim-mode/">Vim syntax for Markdown</a>.  I should take a look and get some ideas from there&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/01/25/vim-syntax-for-textile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

