<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: Command Line Tips (part I: simple key bindings)</title>
    <link>http://blog.kineticweb.com/articles/2007/07/22/command-line-tips-part-i-simple-key-bindings</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>Command Line Tips (part I: simple key bindings)</title>
      <description>&lt;p&gt;Working on the command line can seem daunting and 
slow.  With a few handy tips working on the command
line can be productive and efficient.&lt;/p&gt;


	&lt;p&gt;This entry is the first of a few to cover some of the command line techniques I use to be more productive on the command line.&lt;/p&gt;


	&lt;p&gt;Before we get started, there are two things I should  cover.&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;It&amp;#8217;s all bash/ sh.  Other shells are great, but
   I don&amp;#8217;t know them.  Bash is pretty much the
   default in Linux distros these days, which is
   probably why I wound up learning it.&lt;/li&gt;
		&lt;li&gt;This is geared toward the beginner, and is aimed
   at interactive use as opposed to programming.&lt;/li&gt;
		&lt;li&gt;[ctrl] commands are a simultaenous press.  Press both
  keys at the same time.&lt;/li&gt;
		&lt;li&gt;[esq] commands require that you press escape, then let off,
  then press the next key.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;The most general key bindings used in bash are for
history navigation and command editing.  The ones
I commonly use are:&lt;/p&gt;


	&lt;table&gt;
		&lt;tr&gt;
			&lt;td&gt;[arrow up] or [ctrl]-p &lt;/td&gt;
			&lt;td&gt; Move back in command history &lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[arrow down] or [ctrl]-n&lt;/td&gt;
			&lt;td&gt; Move forward in command history&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[ctrl]-a&lt;/td&gt;
			&lt;td&gt;move cursor to begining of line&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[ctrl]-e&lt;/td&gt;
			&lt;td&gt;move cursor to end of line&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[ctrl]-k&lt;/td&gt;
			&lt;td&gt;erase to end of line&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[esq]-b&lt;/td&gt;
			&lt;td&gt;skip back one word&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[esq]-f&lt;/td&gt;
			&lt;td&gt;skip forward one word&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[esq]-d&lt;/td&gt;
			&lt;td&gt;erase word to right of cursor&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;[ctrl]-r&lt;/td&gt;
			&lt;td&gt;backward history search*&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;




	&lt;p&gt;The [ctrl]-r requires some explanation.&lt;/p&gt;


	&lt;p&gt;When you hit [ctrl]-r, you are in a history search mode,
typing further characters performs an auto-complete style
search of your command history.&lt;/p&gt;


	&lt;p&gt;By typing &amp;#8216;if&amp;#8217; at this prompt, I find that I have a match
&amp;#8217;/sbin/ifconfig -a&amp;#8217;, which I&amp;#8217;d recently executed.&lt;/p&gt;


&lt;pre&gt;
(reverse-i-search)`': 
(reverse-i-search)`if': /sbin/ifconfig -a
&lt;/pre&gt;

	&lt;p&gt;Pressing enter then executes the command.  Other keys like cursor navigation will bring you back to regular command prompt mode, and allow you to edit the command.&lt;/p&gt;


	&lt;p&gt;Good luck and have fun!&lt;/p&gt;</description>
      <pubDate>Sun, 22 Jul 2007 11:26:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:0689e0a6-9f88-436c-b8f7-01704caadb09</guid>
      <author>Andy Libby</author>
      <link>http://blog.kineticweb.com/articles/2007/07/22/command-line-tips-part-i-simple-key-bindings</link>
      <category>CLI</category>
      <trackback:ping>http://blog.kineticweb.com/articles/trackback/48</trackback:ping>
    </item>
    <item>
      <title>"Command Line Tips (part I: simple key bindings)" by Colin</title>
      <description>This is a great list! Thanks, Andy.
When I first learned a few of these a month or two ago, my command-line productivity skyrocketed!!</description>
      <pubDate>Thu, 26 Jul 2007 07:14:27 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:083b28f1-27d6-4a48-b56c-d6964d1eb757</guid>
      <link>http://blog.kineticweb.com/articles/2007/07/22/command-line-tips-part-i-simple-key-bindings#comment-85</link>
    </item>
  </channel>
</rss>
