Look at it carefully since you will need to hunt these long commands
down until none remains. Now, let me explain how you execute a such
command. Open up your personal shell initialization file
(e.g. ~/.bashrc for Bash, ~/.zshrc for Zsh, etc). Then, add the
following:

alias spkgi="sudo aptitude install"

Reload your shell and finally, enjoy:

% spkgi zsh

Now I can introduce, as you can deduce, other shorten commands that
you can produce and reproduce:

The second example is quite similar to the previous one. However, the
find/rename combination is much less common (at least for me) than the
find/grep one. This one needs to be broken in pieces. One obvious thing
to factor out is the find -name with an alias:

alias fname="noglob find -name"

Using this alias, you can rewrite the second example as:

% fname *.html -print0 | xargs -0 rename 's/\.html$/.var/'

It’s better, but it’s not short enough yet. The ugly part of this
command is the -print0 | xargs -0. I hate to type that. Wouldn’t
it be nice if we could define an alias for it? How about:

alias each="-print0 | xargs -0"

Unfortunately, that doesn’t work since aliases are only expanded if
they are in the command position. Luckly, Zsh has that neat feature
called global aliases, which does exactly what we want.

alias -g each="-print0 | xargs -0"

With this feature of Zsh, the second example become:

% fname *.html each rename 's/\.html$/.var/'

Now, we can also attack the third one:

% fname *.patch each -I {} cp {} patches/

It is possible to shorten a bit by defining another alias combining
each and -I {}, but that won’t make a big difference.

Finally, there are the Type-R tedious commands. These are hard to
avoid, unless you’re careful. Here’s again some ridiculous examples to
help you recognize these redundant commands:

To reduce these, you don’t need change your shell configuration; you
change your habits instead. Using alternations (which are
non-standard, but supported by most shells), you can rewrite the two
first example as:

Tab completion doesn’t work well with prefix alternations. Even if the
command using alternation is shorter, it still doesn’t beat good old
tab completion.

And that’s all folks. I surely have plenty of other tricks to show,
but that will be for the other posts of this short series.

]]>http://peadrop.com/blog/2007/10/18/shell-tricks-shorthands/feed/7Pretty Emacs Reloadedhttp://peadrop.com/blog/2007/09/17/pretty-emacs-reloaded/
http://peadrop.com/blog/2007/09/17/pretty-emacs-reloaded/#commentsMon, 17 Sep 2007 05:08:47 +0000http://peadrop.com/blog/2007/09/17/pretty-emacs-reloaded/Update: If you are using Ubuntu 8.04 LTS “Hardy Heron” or Ubuntu 8.10 “Intrepid Ibex”, use the packages in the PPA of the Ubuntu Emacs Lisp team, instead of the packages referenced here. For Ubuntu 9.04 “Jaunty Jackalope” and newer, use the packages in Ubuntu repositories.

My popular1Pretty Emacs package just got a tad better. I
transferred the package to the brand new PPA service provided by
Launchpad. So, what’s new about the package? First, I glad to announce
the long-awaited amd64 support. Also, I am adding Gutsy Gibbon to the
list of supported distributions.

Unfortunately, if you still use Ubuntu 6.06 "Dapper Drake", you will
have to keep using the older package release from my orignal
repository. I still support Ubuntu 6.06, but I won't update the
package with newer snapshots.

After adding the repository to your software source list, upgrade your
version of the package with:

sudo aptitude upgrade

If you do not have a previous version of the package already installed
and you desire to install it, do this instead:

sudo aptitude install emacs-snapshot emacs-snapshot-el

When upgrading the package you might get the following warning
message:

WARNING: untrusted versions of the following packages will be installed!

Untrusted packages could compromise your system's security.
You should only proceed with the installation if you are certain that
this is what you want to do.

This is due to a bug in the PPA system. I believe that it will be
resolved quickly. So, you can safely ignore the warning message for
the moment.

Final note, thank you everyone for trusting me and giving me some
great feedback about the package. I like to give special thanks to
Romain Francoise and Michael Olson for their work respectively on
emacs-snapshot and emacs22, during this summer.

A rough estimate tell me there is over 30 000 people using my
package, where 88% of them are Feisty Fawn users and 11% are Edgy Eft
users. ↩

Do you know how to fix Planet or WordPress, so when I edit an old post it does not pop back on Planet?

I do edit some of my posts, in particular the Pretty Emacs one, fairly often. I love to have my blog aggregated, but I would hate spamming Planet Ubuntu readers with my old posts. Therefore if I cannot fix this little annoyance, I will have no other choice to remove myself from Planet Ubuntu.

]]>http://peadrop.com/blog/2007/05/10/am-i-dreaming/feed/4Smoked brains for dinnerhttp://peadrop.com/blog/2007/04/21/smoked-brains-for-dinner/
http://peadrop.com/blog/2007/04/21/smoked-brains-for-dinner/#commentsSat, 21 Apr 2007 16:33:30 +0000http://peadrop.com/blog/2007/04/21/smoked-brains-for-dinner/Today, there will be a special quiz on Python hosted by me, in
#ubuntu-trivia on FreeNode, at 20:00 UTC. Most of the quiz will be to
write some simple procedures, faster than your opponents. The winner
will, of course, get a superb prize — 5 Ubuntu stickers! Obviously,
the real prize is the fun that will get during the quiz. And who knows, maybe
you will learn a few neat tricks. So, see you there!
]]>http://peadrop.com/blog/2007/04/21/smoked-brains-for-dinner/feed/2Flipping bits this summerhttp://peadrop.com/blog/2007/04/12/flipping-bits-this-summer/
http://peadrop.com/blog/2007/04/12/flipping-bits-this-summer/#commentsThu, 12 Apr 2007 14:36:03 +0000http://peadrop.com/blog/2007/04/12/flipping-bits-this-summer/Dear Applicant,
Congratulations! This email is being sent to inform you that your
application was accepted to take part in the Summer of Code.

Today, I am truly happy. I wasn’t expecting to be accepted, really,
and perhaps no other candidate did. My accepted project is to merge C
and Python implementations of the same interface (i.e.,
StringIO/cStringIO, Pickle/cPickle, etc), and my mentor is the Python
star developer, Brett Cannon. This will be a
challenging project; I will have to work hard and efficiently to be
successful. But one thing is sure, I will have some great fun.

I would like to congrats everyone who have been accepted. A special
thanks to students who will be working on Ubuntu, this summer. There
is surely some great projects for
Ubuntu. And also,
another special thanks to the mentors, who will be helping us this
summer.

]]>http://peadrop.com/blog/2007/04/12/flipping-bits-this-summer/feed/2Welcome to Mr. Crystal Ballhttp://peadrop.com/blog/2007/04/07/welcome-to-mr-crystal-ball/
http://peadrop.com/blog/2007/04/07/welcome-to-mr-crystal-ball/#commentsSat, 07 Apr 2007 20:54:45 +0000http://peadrop.com/blog/2007/04/07/welcome-to-mr-crystal-ball/As some of you may already know, I am a die-hard fan of productive
editing. That is probably because I don’t find myself very fast, on a
keyboard. So, I am always trying to find ways to improve my editing
speed. And when I ain’t surfing on the web, I am either typing stuff in my
shell or my editor. So today, I would like to share a few tricks I uses
in my default shell, Z Shell.

The shell history can be a powerful tool. If you find yourself typing
commands again, and again, and again, you probably can use it at your
advantage. You probably already know about Ctrl+R, which is bound
to history-incremental-search-backward command in most shells.
Personally, I don’t find it very useful since it tries to find a match
everywhere, but it’s better than cycling through the history with the
Up/Down keys. In fact, anything is better than the Up/Down keys. So,
why not rebind them to something more useful, like
history-search-backward? Well, that is easy. With Zsh, you need to
add these two line to your .zshrc:

In fact, if you’re using Emacs key-bindings, you don’t even need to do
anything, because Meta+P and Meta+N are already bound to these
two functions. Incidentally, Steven Harms is advocating to enable
this feature by default in Ubuntu,
for Bash’s users. Personally, I am not sure if it’s really necessary
to make it a default. I am not a fan of modifications in .inputrc,
either. But, I will leave that discussion for another blog post.

Now, that we have functional Up/Down arrow keys, can we do more? Yes,
we can! Let me introduce one of my favorite features of Zsh,
preemptive auto-completion. If you’re tired typing TAB a zillion
times a day, you will love this one. This feature implements
predictive typing using history search and auto-completion. Again, to
enable it, just copy these lines to your configuration file:

Here, note that predict-on and predict-off, are bounded to
Ctrl+Z and Ctrl+X Z respectively. That means you can turn it
on/off, whenever you need to. You will find useful to turn it off when
you edit the middle of a command, since it can confuse the prediction.
But other than that, it’s great.

Sometime, the shell editor is not enough for me — I need something
more powerful when I edit long commands. So, I use another cool
built in function of Zsh, called edit-command-line. With this feature, I can
edit the current command with an external editor, defined by the
environment variable $EDITOR. To enable it, just copy-and-paste
this:

So, when I think the command will be long, like a for-loop. I just
press Ctrl+X e, which launches, on my system, emacsclient. I
am always running Emacs with its server,
therefore the shell command is instantaneously loaded into a Emacs
buffer. Then when I am done, I close the Emacs session with Ctrl+x #
and the command appears in my shell. It is just sweet.

Even if you’re a master with your editor, nothing beats a short alias,
or a shell script. I keep a full directory of useful scripts, to
automate my daily tasks. At first, writing scripts feels a bit
awkward. If you’re like me, you will always worry that your scripts
might go terribly wrong, and eat your data. That’s totally normal, but
don’t be a fool. Automating your tasks, even the most trivial ones,
will save some of your precious time. Unlike scripts, which can really do
some heavy automation, aliases are just a shell convenience, like
auto-completion. Personally, I am not a big fan of fancy aliases. (I
tend to use functions for the more fancy things.) Anyway, here some of
my favourite aliases:

I certainly have a ton of shell tricks, but I will keep them for my other blog
posts. So, that’s all folks!

]]>http://peadrop.com/blog/2007/04/07/welcome-to-mr-crystal-ball/feed/4Back in Businesshttp://peadrop.com/blog/2007/04/06/back-in-business/
http://peadrop.com/blog/2007/04/06/back-in-business/#commentsFri, 06 Apr 2007 21:13:02 +0000http://peadrop.com/blog/2007/04/06/back-in-business/A burned video, a zapped hard drive and a corrupt RAM module later , I
have now, finally, got my system running again (and no, my computer
was not struck by a lightning).

For the fans of my Emacs package,
I just uploaded a new release, and I will continue to provide
weekly releases. Unfortunately, it seems, due to a licensing issue,
Romain Francoise orphaned emacs-snapshot
and its related packages. Therefore, this means I will have to work
harder and fix packaging bugs myself, instead of relying on his bug
fixes.

A week before I lost my system, I had promised a special Python quiz,
in the issue #31
of Ubuntu Weekly News. I have not forgotten my promise. So if you’re one of the
lovers my twisted Ubuntu quizzes,
get ready for an awesome quiz. Date and time, when the quiz will be
held, will be announced, as usual, in the #ubuntu-trivia channel on
FreeNode.

On the final note, I would like to mention that will start posting
more frequently on my blog. My current roadmap includes some cool
tips-and-tricks, fun script recipes, more stuff about Ubuntu. So, stay tuned!

]]>http://peadrop.com/blog/2007/04/06/back-in-business/feed/10Debian Packaging 101 (Part 1)http://peadrop.com/blog/2007/01/30/debian-packaging-101-part-1/
http://peadrop.com/blog/2007/01/30/debian-packaging-101-part-1/#commentsWed, 31 Jan 2007 01:46:58 +0000http://peadrop.com/blog/2007/01/30/debian-packaging-101-part-1/Making packages for Debian derivatives (like Ubuntu) isn’t really
hard. It just required some dedication to learn how the packaging
system work. Yet, most users don’t know how to make packages for
their distribution. In this series, I will try to give a brief
introduction packaging.

First, I would like to tell you that, if you never compiled a program
before, this short guide will be useless for you. Therefore, I assume
that you know and that you did compile a program before. Also, I will
use the term “package” to refer to the compiled program package ready
to installed on Debian or its derivatives. And, I will use the term
“program” to refer to the software, like “GNU Emacs”.

A package consists of two things: the source code of a program and a
debian/ directory which contains information how to build the
program. There is different methods to specify the packaging
information. The most common one, and the one I will discuss here, is
using a tool called debhelper. This tool makes the packaging process
easier by abstracting the common packaging tasks into little scripts,
run at the build time. The typical directory structure of a package
looks like this:

Obviously, this example is simplified, but you get the idea. That are
the interesting things for a packager. By the way, GNU Hello a good
example of package to study. You get it with:

$ apt-get source hello-debhelper

Here, a quick description of the files in the debian/ directory:

changelog: The history of the package’s changes.

compat: A file that contains the debhelper version that is used.

control: The description of the package and the list of
dependencies.

copyright: A copy of the licence the program uses.

postinst: A post-installation script used to setup things after
the package has been unpacked.

prerm: Another script that is run before the removal of the
package. It usually used to undo the things postinst has done.

rules: The instructions how to build the package. This is simply
a Makefile.

In more complicated programs, there is usually other files. However, I
won’t talk about them in this introduction. Anyway, I am out of time.
In the second part of this series, I will explain the tools used to
build packages.

]]>http://peadrop.com/blog/2007/01/30/debian-packaging-101-part-1/feed/0Pretty Emacshttp://peadrop.com/blog/2007/01/06/pretty-emacs/
http://peadrop.com/blog/2007/01/06/pretty-emacs/#commentsSun, 07 Jan 2007 04:56:56 +0000http://peadrop.com/blog/2007/01/06/pretty-emacs/Update: If you are using Ubuntu 8.04 LTS “Hardy Heron” or Ubuntu 8.10 “Intrepid Ibex”, use the packages in the PPA of the Ubuntu Emacs Lisp team, instead of the packages referenced here. For Ubuntu 9.04 “Jaunty Jackalope” and newer, use the packages in Ubuntu repositories.

Emacs is my editor of choice. In fact, I should say it’s my framework
of choice, but that’s for another post.
Until recently, I disliked the poor font backend of Emacs. So, I was always using Emacs within a
terminal window to get a decent looking interface. However, this grungy font era is over, since Emacs’s
hackers added recently to my favorite editor a XFont backend, thus making possible to use good looking
fonts, like Bitstream Vera Sans Mono.

I made a package that makes the installation, as painless as
possible. So, feel free to use it. However, please note that this is
an alpha release of Emacs, therefore it should only be used for
testing. (From my experience, it’s rock solid.)

Still interested? Then, here the instructions. First, add my repository into
your software source list, by adding the following lines to /etc/apt/sources.list:

Here, I use the default monospace font, but any other monospaced
font should work too. For example, if you want to use Lucida Sans
Typewriter instead, change Monospace-10 for Lucida Sans
Typewriter-10 in the above command.

And that’s it! Now, launch Emacs and enjoy the good looking fonts.

If you need support with the package, just email me at
alexandre@peadrop.com.