<?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>Sexy Sexy Penguins &#187; Bash</title>
	<atom:link href="http://sexysexypenguins.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://sexysexypenguins.com</link>
	<description>I love the smell of &#34;Free Software&#34; in the morning</description>
	<lastBuildDate>Thu, 26 Aug 2010 16:36:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Editing command line with $EDITOR</title>
		<link>http://sexysexypenguins.com/2010/08/06/editing-command-line-with-editor/</link>
		<comments>http://sexysexypenguins.com/2010/08/06/editing-command-line-with-editor/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 20:17:02 +0000</pubDate>
		<dc:creator>herlo</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[edit]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://sexysexypenguins.com/?p=742</guid>
		<description><![CDATA[Recently, I&#8217;ve been working on a huge command line that I wanted to edit over and over.  However, the problem was that I didn&#8217;t want to use the prompt to edit the command.  It took me a while to realize what I wanted, but finally, I realized that most﻿ of the Emacs bindings are very [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been working on a huge command line that I wanted to edit over and over.  However, the problem was that I didn&#8217;t want to use the prompt to edit the command.  It took me a while to realize what I wanted, but finally, I realized that <strong>most</strong>﻿ of the Emacs bindings are very useful in bash, so I went to work.</p>
<p>I use VIM for all of my editing when I can.  I don&#8217;t much care for Emacs, but since bash uses the bindings, it&#8217;s good to know a few of the commands.  Like Ctrl+k, Ctrl+u, Ctrl+e, Ctrl+a (try them out with text on the bash command if you don&#8217;t know what they do&#8230;).  The thing is, the default editor in many of my CentOS systems at work is Emacs.  I clearly didn&#8217;t want that, so I had to change two variables in my ~/.bashrc file.  It now looks better:</p>
<p><code>$ cat ~/.bashrc<br />
.. snip ..<br />
EDITOR=/usr/bin/vim<br />
VISUAL=/usr/bin/vim<br />
export EDITOR VISUAL<br />
.. snip ..</code></p>
<p>After setting these variables up, it&#8217;s very easy to edit the command line with vim.  First, source the ~/.bashrc file.</p>
<p><code>$ source ~/.bashrc</code></p>
<p>Then bring up the command to edit:</p>
<p><code>$ yum remove -y NetworkManager.i?86 NetworkManager-glib.i?86 alsa-lib.i?86 apr.i?86 aspell.i?86 audit-libs.i?86 coolkey.i?86 cracklib.i?86 cryptsetup-luks.i?86 cyrus-sasl-lib.i?86 cyrus-sasl-plain.i?86 db4.i?86 dbus-glib.i?86 dbus-libs.i?86 device-mapper.i?86 e2fsprogs-libs.i?86 ecryptfs-utils.i?86 expat.i?86 fipscheck.i?86 freetype.i?86 giflib.i?86 glib2.i?86 gpm.i?86 hal.i?86 java-1.6.0-openjdk.i?86 keyutils-libs.i?86 krb5-libs.i?86 libICE.i?86 libSM.i?86 libX11.i?86 libXau.i?86 libXdmcp.i?86 libXext.i?86 libXi.i?86 libXt.i?86 libXtst.i?86 libXxf86vm.i?86 libaio.i?86 libcap.i?86 libdaemon.i?86 libdrm.i?86 libgcc.i?86 libgcrypt.i?86 libgpg-error.i?86 libhugetlbfs.i?86 libjpeg.i?86 libpng.i?86 libselinux.i?86 libsepol.i?86 libstdc++.i?86 libtermcap.i?86 libusb.i?86 libutempter.i?86 libvolume_id.i?86 mesa-libGL.i?86 mkinitrd.i?86 ncurses.i?86 neon.i?86 nspr.i?86 nss.i?86 nss_db.i?86 nss_ldap.i?86 numactl.i?86 openldap.i?86 openssl.i?86 openssl-devel.i?86 pam.i?86 pam_ccreds.i?86 pam_krb5.i?86 pam_passwdqc.i?86 pam_pkcs11.i?86 pam_smb.i?86 parted.i?86 readline.i?86 redhat-lsb.i?86 sqlite.i?86 tcp_wrappers.i?86 wireless-tools.i?86 zlib.i?86</code></p>
<p>As can be seen, this is pretty long and cumbersome.  It&#8217;d be nice to be able to edit the line without having to use bash, plus, if I accidentally mistype and hit &#8216;Enter&#8217;, it could be executed before the command is ready.  To edit the command, hit the following:</p>
<p><code>Ctrl+x, Ctrl+e</code></p>
<p>The command will then be opened in your $EDITOR (probably /usr/bin/vim if you followed the instructions above).  Edit away, when you save and quit (:wq in VIM), the command will be executed.  If you don&#8217;t want to execute the command after all, just quit without saving (:q in VIM).</p>
<p>Enjoy,</p>
<p>Herlo</p>
]]></content:encoded>
			<wfw:commentRss>http://sexysexypenguins.com/2010/08/06/editing-command-line-with-editor/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Succumbing to the pressure</title>
		<link>http://sexysexypenguins.com/2008/04/12/succumbing-to-the-pressure/</link>
		<comments>http://sexysexypenguins.com/2008/04/12/succumbing-to-the-pressure/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 01:31:01 +0000</pubDate>
		<dc:creator>herlo</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Guru]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[banana]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://fedora-tutorials.com/?p=234</guid>
		<description><![CDATA[My T60p. [clints@herlo-lap ~]$ history&#124;awk &#8216;{a[$2]++ } END{for(i in a){print a[i] &#8221; &#8221; i}}&#8217;&#124;sort -rn&#124;head 144 svn 144 cd 108 ls 104 ./manage.py 101 ssh 69 su 43 screen 26 vim 25 rm 15 ping [clints@thor ~]$ history&#124;awk &#8216;{a[$2]++ } END{for(i in a){print a[i] &#8221; &#8221; i}}&#8217;&#124;sort -rn&#124;head 266 git 260 make 71 cd 57 [...]]]></description>
			<content:encoded><![CDATA[<p>My T60p.</p>
<p>[clints@herlo-lap ~]$ history|awk &#8216;{a[$2]++ } END{for(i in a){print a[i] &#8221; &#8221; i}}&#8217;|sort -rn|head<br />
144 svn<br />
144 cd<br />
108 ls<br />
104 ./manage.py<br />
101 ssh<br />
69 su<br />
43 screen<br />
26 vim<br />
25 rm<br />
15 ping</p>
<p>[clints@thor ~]$ history|awk &#8216;{a[$2]++ } END{for(i in a){print a[i] &#8221; &#8221; i}}&#8217;|sort -rn|head<br />
266 git<br />
260 make<br />
71 cd<br />
57 ls<br />
55 vim<br />
55 rt<br />
26 rm<br />
19 bin/send-patch<br />
18 grep<br />
16 bin/validate</p>
<p>I guess I love RCS&#8217;.</p>
<p>Cheers,</p>
<p>Herlo</p>
]]></content:encoded>
			<wfw:commentRss>http://sexysexypenguins.com/2008/04/12/succumbing-to-the-pressure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>POW: bash-completion &#8211; Bash Auto Completion in Fedora using yum (and more)</title>
		<link>http://sexysexypenguins.com/2007/10/24/pow-bash-completion-bash-auto-completion-in-fedora-using-yum-and-more/</link>
		<comments>http://sexysexypenguins.com/2007/10/24/pow-bash-completion-bash-auto-completion-in-fedora-using-yum-and-more/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 15:29:19 +0000</pubDate>
		<dc:creator>herlo</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[POW]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yum]]></category>

		<guid isPermaLink="false">http://fedora-tutorials.com/2007/10/24/pow-bash-completion-bash-auto-completion-in-fedora-using-yum-and-more/</guid>
		<description><![CDATA[In an attempt to consistently blog, I am starting a new series here on fedora-tutorials.com. Program of the Week (POW). Hopefully, this will excite and inform all of us about the cool programs available in Fedora. So see you next Wednesday for another program. Over the past year or so, I&#8217;ve been on the hunt [...]]]></description>
			<content:encoded><![CDATA[<p>In an attempt to consistently blog, I am starting a new series here on fedora-tutorials.com. Program of the Week (POW). Hopefully, this will excite and inform all of us about the cool programs available in Fedora. So see you next Wednesday for another program.</p>
<p>Over the past year or so, I&#8217;ve been on the hunt for several things that I find in other Linux distros that I cannot find in Fedora. Its not very common, but on occasion I do run into something that&#8217;s not there on Fedora. One of them was the ability to automagically complete many of the command lines for many things.</p>
<p>One of them, and probably one of the biggest, was the fact that yum did not have tab completion for available packages. Today is my lucky day! While chatting and helping my students with their labs today, one of them mentioned to me that he could tab complete a particular command on his box. I of course inquired, because it interested me, as to the package name. It turns out my bash tab completion dreams were just about to come true! He told me about this amazing package that would let me use tab completions for things like the <strong>service</strong> command, <strong>man</strong> and of course, <strong>yum</strong>.</p>
<p>I was blown away! So immediately after this discussion, I started searching for this elusive package I&#8217;ve never heard of before. Sure enough, as he informed me, <em>bash-completion </em>does exist and does some amazing things. After hunting around a little on google, here&#8217;s some of the stuff I found. I&#8217;ll also include the links at the bottom of this post.</p>
<p>as root try this:  (note [Tab] means you should hit the tab key)</p>
<blockquote>
<pre># service ht[Tab]</pre>
</blockquote>
<p>What you&#8217;ll notice is that one of three things happen.  If you&#8217;ve got the <em>bash-completion</em> package installed already because you&#8217;re ahead of the game, it should auto-complete for you. Without bash-completion, this doesn&#8217;t happen, but its also possible that since bash already has some completion in place, it might auto complete a directory for you, but that&#8217;s definitely not what you want.</p>
<p>If you&#8217;ve not already installed bash-completion, I&#8217;d suggest you do it now.  On Fedora 7, run the following command:</p>
<blockquote>
<pre># yum install -y bash-completion
..snip..
Installed: bash-completion.noarch 0:20060301-3.fc7
Complete!</pre>
</blockquote>
<p>Now that <em>bash-completion</em> is installed, we need to invoke the tools. Normally, this is not needed, and a reboot/re-login will take care of this as well, but since I wanted to use this right away, I did the following as an unprivileged user:</p>
<blockquote>
<pre>$ source /etc/bash_completion</pre>
</blockquote>
<p>This doesn&#8217;t seem to do much, but its actually quite powerful.  The source (or .) will load the environment variables from the <em>/etc/bash_completion</em> script into my current environment.  Luckily for us, when we now log into root, <em>/etc/bashrc</em> will accomplish this for us without any intervention. To test that it worked, try running the following command as the same unprivileged user:</p>
<blockquote>
<pre>$ unalias[Tab]
<tab><tab>.=     ll=     ls=     vi=     which=</tab></tab></pre>
</blockquote>
<p>Note that when I pressed <tab> twice, a list of the currently available aliases appeared.  Nice ey?  Let&#8217;s complete this:</tab></p>
<blockquote>
<pre>$ unalias w[Tab]</pre>
</blockquote>
<p>Now produces:</p>
<blockquote>
<pre>$ unalias which</pre>
</blockquote>
<p>And completes the string as expected.  Now we&#8217;re getting somewhere!  But why did I really want to explain this?</p>
<p><big><big>Oh yeah! <strong>yum</strong></big></big></p>
<p>With <em>bash-completion</em>, yum can now provide us with a list of available packages, similar to the auto completion capability in <em>apt-get</em> or <em>aptitude</em> from Ubuntu or Debian. Say for instance you want to see all of the packages available for install that match what you&#8217;re looking for, but don&#8217;t want to run <strong>yum list</strong> or <strong>yum search</strong> because, in truth, it just takes to long!  Now you have an alternative:</p>
<blockquote>
<pre># yum -y install bal[Tab]<tab></tab></pre>
</blockquote>
<p>Produces:</p>
<blockquote>
<pre>ballbuster.i386  ballz.i386       balsa.i386</pre>
</blockquote>
<p>Adding another &#8216;lb&#8217; to the end of that string (and then the tab key of course) should help us to complete to the package we&#8217;d like to install.</p>
<blockquote>
<pre># yum -y install  ballb[Tab]</pre>
</blockquote>
<p>Then completes to:</p>
<blockquote>
<pre># yum -y install  ballbuster.i386</pre>
</blockquote>
<p>Hitting enter then installs the ballbuster package, and its quite a fun game!</p>
<blockquote>
<pre>.. snip ..
Installed: ballbuster.i386 0:1.0-1.fc6
Dependency Installed: ClanLib.i386 0:0.8.0-4.fc7
Complete!</pre>
</blockquote>
<p>Of course, there are hundreds of others tab completions available (and there&#8217;s a good way to list many of them too, even if its a bit cryptic). Try these on for size:</p>
<p>Are you a developer?</p>
<blockquote>
<pre>$ svn c[Tab]
cat checkout  ci     cleanup   co     commit    copy    cp
$ make [Tab]
all clean dist-clean</pre>
</blockquote>
<p>What about a systems administrator?</p>
<blockquote>
<pre># modprobe -r b[Tab]
battery    bay        blkcipher  bluetooth  bridge     button</pre>
</blockquote>
<blockquote>
<pre>$ man cron[Tab]
cron     crond    crontab</pre>
</blockquote>
<blockquote>
<pre>$ ssh herlo[Tab]
herlo-f7   herlo-lap  herlo.org</pre>
<pre>$ grep --[Tab][Tab]
 --after-context=  --directories=   --invert-match   --only-matching
 --basic-regexp    --exclude=       --label=         --perl-regexp
.. snip ..</pre>
</blockquote>
<p>To help you wade further through, try out the following two commands:</p>
<ul>
<li>
<pre>complete -p</pre>
</li>
<li>
<pre>declare -f</pre>
</li>
</ul>
<p>Be aware that these are advanced components and can really be confusing if you&#8217;re not a developer and just want to use the features. The <em>complete</em> command seems to provides some tools to do additional auto-completion. I also think that its nice to be able to extend this functionality to other applications as well.</p>
<p>As promised, here&#8217;s a few links to help your completion introduction.   <strong>Note</strong>:  Some of these links provide more than just the simple tab completion:</p>
<ul>
<li><a href="http:/http://www.caliban.org/bash/index.shtml#completion" target="_blank">http://www.caliban.org/bash/index.shtml#completion</a> &#8211; The GNU page on bash-completion, still needs more.</li>
<li><a href="http://www.keyboardcowboy.co.uk/bash-completion/" target="_blank">http://www.keyboardcowboy.co.uk/bash-completion/</a> &#8211; Provides some interesting scripts to improve your bash-competions</li>
<li><a href="http://www.debian-administration.org/articles/316" target="_blank">http://www.debian-administration.org/articles/316</a> &#8211; An introduction to bash completion: part 1</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sexysexypenguins.com/2007/10/24/pow-bash-completion-bash-auto-completion-in-fedora-using-yum-and-more/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
