From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1807 invoked from network); 21 Oct 2007 22:57:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.2.3 Received: from ns2.primenet.com.au (HELO primenet.com.au) (@203.24.36.3) by ns1.primenet.com.au with (DHE-RSA-AES256-SHA encrypted) SMTP; 21 Oct 2007 22:57:30 -0000 Received: (qmail 11457 invoked from network); 21 Oct 2007 05:56:45 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns2.melb.primenet.com.au with SMTP; 21 Oct 2007 05:56:45 -0000 Received-SPF: none (ns2.melb.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 75769 invoked from network); 21 Oct 2007 04:08:54 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Oct 2007 04:08:54 -0000 Received: (qmail 28759 invoked by alias); 21 Oct 2007 04:08:45 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12071 Received: (qmail 7041 invoked from network); 21 Oct 2007 03:40:43 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Oct 2007 03:40:43 -0000 Received: (qmail 66646 invoked from network); 21 Oct 2007 03:40:43 -0000 Received: from wx-out-0506.google.com (66.249.82.226) by a.mx.sunsite.dk with SMTP; 21 Oct 2007 03:40:35 -0000 Received: by wx-out-0506.google.com with SMTP id h27so888894wxd for ; Sat, 20 Oct 2007 20:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:from:to:subject:message-id:mime-version:content-type:content-disposition:x-gnupg-keyid:x-gnupg-fingerprint:x-editor:x-operating-system:user-agent; bh=n0PiAQ7M6Ubr3Ra0weAwAZj91aWyH27lQutlFCqhBfE=; b=FU9DEwPb3qDINI5AoUhT1rvgbQfXOMX7t8R+Xvqk9+f8apl6sKrEYu0DARpyYdwUE8OCfnPetNNkx0yG+hCbTwI0Ds+aTQ0rIJlwxJ4tM/ytOm/jmHkdmGmMxCo84MzjwT56oOBJkgpLHx/ooFbg2hqh8RTteU8uiY0bMT5xPKU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:subject:message-id:mime-version:content-type:content-disposition:x-gnupg-keyid:x-gnupg-fingerprint:x-editor:x-operating-system:user-agent; b=fQcKRbYx1tW/lMh3vWCs37OKPfPE6WxWRf0TJvX9ELuPJJzkT8fP25nS/ehj0zB1EnZ8KIfwyhCxAURYNyj0lErJqQm2xbb7fRJPtccTwavX4Xfn6bBoQ7IthWq2m1Ocdr7quA68pkn0np31wMERY9Pbua+pPHtjJdoPRfvaixQ= Received: by 10.90.29.18 with SMTP id c18mr5202975agc.1192938034799; Sat, 20 Oct 2007 20:40:34 -0700 (PDT) Received: from localhost ( [85.25.141.60]) by mx.google.com with ESMTPS id 9sm8414484agc.2007.10.20.20.40.29 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 20 Oct 2007 20:40:34 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Sat, 20 Oct 2007 23:39:59 -0400 Date: Sat, 20 Oct 2007 23:39:59 -0400 From: Gwern Branwen To: zsh-users@sunsite.dk Subject: Improving spelling correction prompt to generate aliases for future use Message-ID: <20071021033959.GA4471@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="T4sUOijqQbZv57TR" Content-Disposition: inline X-GnuPG-KeyID: F7E5D682 X-GnuPG-Fingerprint: 85F9 9FDE 8F20 898F 59BC DF32 BE90 E8E4 F7E5 D682 X-Editor: "GNU Emacs 23.0.50.1" X-Operating-System: "Gentoo x86_64 GNU/Linux" User-Agent: Mutt/1.5.16 (2007-06-09) --T4sUOijqQbZv57TR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 'lo everyone. My desire is this: I have a function, 'typo', which is defined thusly: function typo () { (typo_darcs "$@" &); #Subshell to insulate environment alias $1=$2; } #now enable the typo for the current shell. function typo_darcs () { #So often I make little stupid typos while firing away #in the shell. So, I whipped up a quick shell script which #reads the two arguments provided, and constructs the appropriate #echo command to create an alias that solves that typo. cd; #we need to be in a repository directory, which is ~/ since .ztypos is there echo alias $1='"'$2'"' >> ~/.ztypos; #It goes typo wrong-command right-command tail -n 1 ~/.ztypos & #Verify that .ztypos was written, with the right thing. darcs record --compress --skip-long-comment --all --patch-name=".ztypos: alias $1="$2"" .ztypos; } It basically makes an alias to fix a typo I've just made. This was very useful in Bash since there was no spelling correction. Now, I've only just recently switched from using Bash to using Zsh, and a little experience with spelling correction has convinced it that it would be excellent if, when I make a typo, I could get correction but also somehow have 'typo' be automatically run. Looking into it, though, it is not very clear how to do this. I though one could perhaps modify SPROMPT to execute 'typo %R %r', but there doesn't seem to be any escape to run arbitrary shell commands. Precmd() also doesn't seem to work, since I don't see anyway for it to get access to %R, %r, or to know there is a misspelling going on at all. I asked around on #zsh, but no one seemed to really know and someone suggested emailing this list might help. -- gwern digicash RRF bemd Beach HRT GSM Blowpipe INR Zen AC --T4sUOijqQbZv57TR Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFHGsoPvpDo5Pfl1oIRCow2AKCLGhC/d8hSfxMI9/afRPdroOvwdgCfdzs8 k10FMejN8bCifMih43LNyAA= =nlWL -----END PGP SIGNATURE----- --T4sUOijqQbZv57TR--