Name: Alexandre Vassalotti
Member since: 2007-01-07 21:57:39
Last Login: 2007-05-25 04:00:01
Homepage: http://peadrop.com
How to not switch to Dvorak
Once in a while, I practice to improve my touch typing skills. Most of the time, I just find some online stuff or use KTouch. But today, I wanted to try something different. I always hear good things about the Dvorak keyboard layout — i.e., how it’s supposedly more efficient and more comfortable than the Qwerty layout. Being a curious person, I wanted to test this out.
So when I opened up KTouch, I selected the Dvorak lecture, instead of the typical Qwerty one. The first lessons were fairly easy. As I went through the lecture, I managed to keep a fairly pace and accuracy — i.e., about 210 characters per minute with a 95% accuracy. About at the fifth or sixth lesson, I said to myself: “Wow, I must have been a Dvorak typist in another life.” I was really impressed how quickly I had learnt the basics of the layout and I was indeed starting to believe that the Dvorak layout was vastly superior to Qwerty.
Shortly after, I was sold. At this point, I was thinking how was going to remap my Emacs key bindings. :-)
However, when I got to the tenth lesson, I found something strange, very strange. The letter ‘q’ on the Dvorak layout was in the upper row on the left — exactly where it is on the Qwerty layout.
I stop typing for a second…
…and look at the keyboard displayed on the screen.
“asdf asdf asdf”
Oops! I had forgot the change the actual layout of my keyboard. So, I was still using Qwerty.
Now, I realize that I have been victim of what they call the “placebo effect”. This little anecdote has certainly thought me to be more careful, in the future, when trying something new sold has “better”.
Changing
It been a while since I have written a blog post. It’s not that I haven’t tried, or that I am lacking of ideas. It’s just that these things take forever to write. I found the hard way that perfectionism is the enemy of getting things done (or in fact to get them started in the first place).
So now that I got a bunch of half-finished blog posts that I won’t ever finish, what should I do with them?
Well, I guess that is my chance to start breaking my perfectionism habits and put them on the web. (When I said “half-finished” I really meant it, by the way).
Shell tricks: shorthands
Even with tab completion, typing long commands is tedious. But, there’s something even worst: typing the same long commands again, and again, and again… So how do you solve that? It’s simple: you shorten them. Surprising, uh? Okay enough theory, let me show you some examples.
Here’s a tedious command of Type-A:
% sudo aptitude install zsh
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:
# Package Management
alias pkg="aptitude"
alias spkg="sudo aptitude"
alias spkgi="sudo aptitude install"
alias spkgu="sudo aptitude safe-upgrade"
alias spkgr="sudo aptitude remove"
alias spkgd="sudo apt-get build-dep"
# Miscellaneous Helpers
alias nc="rlwrap nc"
alias e=$EDITOR
alias se=sudoedit
alias reload="source ~/.zshrc"
alias g=egrep
# To produce annoying alliterations
alias alli="cat /usr/share/dict/words | grep"
Next after Type-A tedious commands, we have the Type-S ones. To execute these, you will you need some sort of special shell support. So, here’s some examples of the Type-S monstrosity:
% find Lib/ -name '*.c' -print0 | xargs -0 grep ^PyErr
% find -name '*.html' -print0 | xargs -0 rename 's/\.html$/.var/'
% find -name '*.patch' -print0 | xargs -0 -I {} cp {} patches/
I hope you start to see some patterns (if you don’t, then try harder). The first one could (and should) be rewritten as:
% rgrep --include='*.c' ^PyErr Lib/
But that isn’t short enough for me, so I have a short helper:
rg()
{
filepat="$1"
pat="$2"
shift 2
grep -Er --include=$filepat $pat ${@:-.}
}
# In Zsh, 'noglob' turns off globing.
# (e.g, "noglob echo *" outputs "*")
alias rg='noglob rg'
It is lovely to use:
% rg *.c ^PyErr Lib/
% rg *.c PyErr_Restore . -C 10 | less
% rg *.[ch] stringlib
% rg *.c ^[a-zA-Z]*_dealloc Modules/ Objects/
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:
% gcc -o stackgrow stackgrow.c
% pkg show emacs-snapshot-bin-common emacs-snapshot-common emacs-snapshot-gtk emacs-snapshot
% cat ../lispref.patch ../lwlib.patch ../etc.patch | patch -p1
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:
% gcc -o stackgrow{,.c}
% pkg show emacs-snapshot{{-bin,}-common,-gtk,}
Now, you are surely asking yourself: “what is different about the third one?” Well, think about it. Got it? No? Ah, come on, it is easy. Here’s a hint:
% echo 'cat ../{lispref,lwlib,etc}.patch | patch -p1' | wc -c
45
% echo 'cat ../lispref.patch ../lwlib.patch ../etc.patch | patch -p1' | wc -c
61
You like my hint, don’t you? Here’s the answer:
% echo 'cat ../li\t ../lw\t ../et\t | patch -p1' | wc -c
37
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.
Pretty Emacs Reloaded
My popular<sup id="fnref:1">1</sup> Pretty 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.
To use the updated package on Ubuntu 6.10 “Edgy Eft”, add the
following lines to your /etc/apt/sources.list file:
deb http://ppa.launchpad.net/avassalotti/ubuntu edgy main
deb-src http://ppa.launchpad.net/avassalotti/ubuntu edgy main
To use the package on Ubuntu 7.04 “Feisty Fawn”, add the following
lines to your /etc/apt/sources.list file:
deb http://ppa.launchpad.net/avassalotti/ubuntu feisty main
deb-src http://ppa.launchpad.net/avassalotti/ubuntu feisty main
To use the package on the development version of Ubuntu “Gutsy
Gibbon”, add the following lines to your /etc/apt/sources.list file:
deb http://ppa.launchpad.net/avassalotti/ubuntu gutsy main
deb-src http://ppa.launchpad.net/avassalotti/ubuntu gutsy main
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
Please note, my package does not have multi-tty support. If you want multi-tty support and don’t mind about using bitmap fonts, use Romain Francoise’s excellent package of the CVS trunk for Debian. Also, 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. ↩
Syndicated 2007-09-17 05:08:47 (Updated 2007-09-17 05:25:11) from Alexandre Vassalotti
Protected: Installation scripts review
<form action="http://peadrop.com/blog/wp-pass.php" method="post">This post is password protected. To view it please enter your password below:
<label>Password: <input name="post_password" type="password" size="20" /></label> <input type="submit" name="Submit" value="Submit" /> </form>
avassalotti certified others as follows:
Others have certified avassalotti as follows:
[ Certification disabled because you're not logged in. ]
FOAF updates: Trust rankings are now exported, making the data available to other users and websites. An external FOAF URI has been added, allowing users to link to an additional FOAF file.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!