* another (hopefully simple) completion question @ 2006-02-14 15:22 ` William Scott 2006-02-14 22:34 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: William Scott @ 2006-02-14 15:22 UTC (permalink / raw) To: zsh-users Hi, Citizens: Is there a simple way to complete with the sort order governed by most recently touched file first (the order ls -t produces) rather than the conventional order? Ideally I'd like to bind it to ctl-tab or some such key combo and retain the normal completion option with tab. Many thanks. Bill Scott ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: another (hopefully simple) completion question 2006-02-14 15:22 ` another (hopefully simple) completion question William Scott @ 2006-02-14 22:34 ` Peter Stephenson 2006-02-15 0:51 ` William Scott 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2006-02-14 22:34 UTC (permalink / raw) To: zsh-users William Scott wrote: > Is there a simple way to complete with the sort order governed by > most recently touched file first (the order ls -t produces) rather > than the conventional order? Ideally I'd like to bind it to ctl-tab > or some such key combo and retain the normal completion option with tab. Yes, you can do this very flexibly just using styles. The following is the solution explained by Oliver in From Bash to Z Shell (Apress, ISBN 1-59059-376-6), page 407. The _generic widget is really just a hook so you can hang a special name on it, using styles to make it do something different from normal completion. # Use menu completion to cycle through files. zle -C most-recent-file menu-complete _generic # Use file completion, but add the _match completer so # glob patterns can be used. zstyle 'completion:most-recent-file::::' completer _menu _files _match # Use the file-sort style to sort in modification time order. zstyle ':completion:most-recent-file:*' file-sort modification # We don't want to see the list of matches, just the results. zstyle ':completion:most-recent-file:*' hidden all # Optionally, restrict matches to regular files zstyle ':completion:most-recent-file:*' file-patterns '*(.):normal\ files' # Bind the widget. bindkey '^X.' most-recent-file -- Peter Stephenson <p.w.stephenson@ntlworld.com> Web page still at http://www.pwstephenson.fsnet.co.uk/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: another (hopefully simple) completion question 2006-02-14 22:34 ` Peter Stephenson @ 2006-02-15 0:51 ` William Scott 0 siblings, 0 replies; 7+ messages in thread From: William Scott @ 2006-02-15 0:51 UTC (permalink / raw) To: Peter Stephenson; +Cc: zsh-users Dear Peter: Sorry to put you through this. Not only do I have the book, I had highlighted the section. Oops. But thanks! Bill On Tue, 14 Feb 2006, Peter Stephenson wrote: > William Scott wrote: > > Is there a simple way to complete with the sort order governed by > > most recently touched file first (the order ls -t produces) rather > > than the conventional order? Ideally I'd like to bind it to ctl-tab > > or some such key combo and retain the normal completion option with tab. > > Yes, you can do this very flexibly just using styles. The following is > the solution explained by Oliver in From Bash to Z Shell (Apress, ISBN > 1-59059-376-6), page 407. The _generic widget is really just a hook so > you can hang a special name on it, using styles to make it do something > different from normal completion. > > # Use menu completion to cycle through files. > zle -C most-recent-file menu-complete _generic > # Use file completion, but add the _match completer so > # glob patterns can be used. > zstyle 'completion:most-recent-file::::' completer _menu _files _match > # Use the file-sort style to sort in modification time order. > zstyle ':completion:most-recent-file:*' file-sort modification > # We don't want to see the list of matches, just the results. > zstyle ':completion:most-recent-file:*' hidden all > # Optionally, restrict matches to regular files > zstyle ':completion:most-recent-file:*' file-patterns '*(.):normal\ files' > # Bind the widget. > bindkey '^X.' most-recent-file > > -- > Peter Stephenson <p.w.stephenson@ntlworld.com> > Web page still at http://www.pwstephenson.fsnet.co.uk/ > ^ permalink raw reply [flat|nested] 7+ messages in thread
* zsh 4.3.0-dev-2 @ 2005-12-09 15:32 Peter Stephenson 2005-12-10 3:48 ` William Scott 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2005-12-09 15:32 UTC (permalink / raw) To: Zsh users list I've put a test release of zsh 4.3 in the pub/development directory of ftp.zsh.org. It's unlikely to differ much from 4.3.1 when that appears. The main new feature compared with 4.2 is multibyte support. This is only enabled by default on some machines (most recent PC Unix-like targets in particular). Reports on other machines where it works (or compiles but doesn't work) when you explicitly supply --enable-multibyte to configure would be useful. The documentation package for 4.3 contains a PDF file instead of a PostScript file. This should be easier to browse. -- Peter Stephenson <pws@csr.com> Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: zsh 4.3.0-dev-2 2005-12-09 15:32 zsh 4.3.0-dev-2 Peter Stephenson @ 2005-12-10 3:48 ` William Scott 2005-12-10 16:03 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: William Scott @ 2005-12-10 3:48 UTC (permalink / raw) To: Peter Stephenson; +Cc: Zsh users list Dear Peter: Compiles fine on OS X v. 10.4.3, Xcode 2.2 (with gcc 4.0.1). How do I test to see if myltibyte is indeed working? All the best, Bill On Fri, 9 Dec 2005, Peter Stephenson wrote: > I've put a test release of zsh 4.3 in the pub/development directory of > ftp.zsh.org. It's unlikely to differ much from 4.3.1 when that appears. > > The main new feature compared with 4.2 is multibyte support. This is > only enabled by default on some machines (most recent PC Unix-like > targets in particular). Reports on other machines where it works (or > compiles but doesn't work) when you explicitly supply --enable-multibyte > to configure would be useful. > > The documentation package for 4.3 contains a PDF file instead of a > PostScript file. This should be easier to browse. > > -- > Peter Stephenson <pws@csr.com> Software Engineer > CSR PLC, Churchill House, Cambridge Business Park, Cowley Road > Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 > > > This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: zsh 4.3.0-dev-2 2005-12-10 3:48 ` William Scott @ 2005-12-10 16:03 ` Peter Stephenson 2005-12-10 16:27 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2005-12-10 16:03 UTC (permalink / raw) To: Zsh users list William Scott wrote: > Compiles fine on OS X v. 10.4.3, Xcode 2.2 (with gcc 4.0.1). > > How do I test to see if myltibyte is indeed working? That's a good point. I suppose this could go into the FAQ, so please correct any bits I've got wrong. Multibyte support is compiled in if the line #define MULTIBYTE_SUPPORT 1 appears in config.h. If you don't have the source, you could try running (bindkey -m) and see if you get a warning message about doing this with multibyte enabled. (The parentheses protect you from the results.) To test it, you need an appropriate environment: (1) a locale with multibyte characters. Unless you already know that you need a different character set, look for a variant of your usual locale with UTF-8 in it. Nowadays it's quite possible $LANG is already set to a UTF-8 locale. For example, mine is en_GB.UTF-8; en_US.UTF-8 is an obvious one. zsh will complete locales on assignment to the variable LANG, so export LANG=^D will show possible values. A reasonable modern Unix distribution should let you set this up consistently for your desktop environment, but exporting the variable, then starting a suitable terminal emulator is enough to get things going. (2) a corresponding font. If you use an old-style X font with lots of dashes, you need one with iso10646-1 at the end (not, for example, iso8859-1). If your terminal emulator allows you to pick fonts from a menu, it's probably smart enough to match the character set to the locale and you can forget about this. (3) a terminal emulator that handles multibyte mode. I've had mixed results with xterm, possibly out of ignorance. gnome-terminal is the best I've tried but I haven't searched too far. (This is the sort of thing Apple will almost certainly have got right in whatever they provide.) Once zsh is running in this environment, you need to be able to enter multibyte characters. If your keyboard provides such characters, don't use the "bindkey -m" option, which treats the high bit in 8-bit characters as if it were an escape character. A shell with multibyte enabled will warn if you set the option. You can remove all meta bindings with: bindkey -L | grep '\\M' | sed -e '/^bindkey \(-R \|\)"\\M/s/[^ ]*$/undefined-key/' | while read -r line; do eval $line; done (that's the simplest I could come up with; the shell doesn't provide a direct antidote), but that doesn't seem to undo the effect completely, so there may be a bug lurking. There are two zle widgets provided with 4.3 to allow you to enter characters not on the keyboard; load them in the normal way with autoload -Uz insert-unicode-char insert-composed-char zle -N insert-unicode-char zle -N insert-composed-char Bind them with bindkey as appropriate. They're described in the zshcontrib manual page. insert-unicode-char takes the Unicode value for the character as a hex number (execute the widget before and after the hex number). insert-composed-char is followed by a more memorable two-character mnemonic described in RFC 1345, http://www.faqs.org/rfcs/rfc1345.html, for various accented characters, non-Latin European and related character sets, and special characters such as punctuation and mathematical symbols. For example, try cH and see if you get a playing card heart. Not all of RFC 1345 is implemented but it's easy to extend the function. Ideally, editing with multibyte characters should behave identically to editing with ASCII, even if the characters have double width. There's one bug in cd listings reported by Mikael Magnusson in zsh-users/9741 that hasn't been looked at yet, but mostly it seems to be working OK. It's taken me six years until I can use the Euro character that came on my keyboard directly in zsh, but it's quite satisfying... -- Peter Stephenson <p.w.stephenson@ntlworld.com> Web page still at http://www.pwstephenson.fsnet.co.uk/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: zsh 4.3.0-dev-2 2005-12-10 16:03 ` Peter Stephenson @ 2005-12-10 16:27 ` Peter Stephenson 0 siblings, 0 replies; 7+ messages in thread From: Peter Stephenson @ 2005-12-10 16:27 UTC (permalink / raw) To: Zsh Users On Sat, 10 Dec 2005 16:03:33 +0000 Peter Stephenson <p.w.stephenson@ntlworld.com> wrote: > If your keyboard provides such characters, don't use the "bindkey -m" > option, which treats the high bit in 8-bit characters as if it were an > escape character. A shell with multibyte enabled will warn if you set > the option. You can remove all meta bindings with: > > bindkey -L | grep '\\M' | > sed -e '/^bindkey \(-R \|\)"\\M/s/[^ ]*$/undefined-key/' | > while read -r line; do eval $line; done > > (that's the simplest I could come up with; the shell doesn't provide a > direct antidote), but that doesn't seem to undo the effect completely, > so there may be a bug lurking. It's because I didn't restore the self-insert binding. Add: bindkey -R "\M-^@"-"\M-^?" self-insert (although note this will override any meta bindings you have). ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-02-15 0:51 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <wgscott@chemistry.ucsc.edu> 2006-02-14 15:22 ` another (hopefully simple) completion question William Scott 2006-02-14 22:34 ` Peter Stephenson 2006-02-15 0:51 ` William Scott 2005-12-09 15:32 zsh 4.3.0-dev-2 Peter Stephenson 2005-12-10 3:48 ` William Scott 2005-12-10 16:03 ` Peter Stephenson 2005-12-10 16:27 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).