Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Context-aware file name completion with preferences
- X-seq: zsh-users 15039
- From: Mikael Puhakka <mr.progo@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Context-aware file name completion with preferences
- Date: Sat, 1 May 2010 23:51:08 +0300
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=WpLzvutWLjaxJydskTsAOLITIl9q0OlIh+FVZK5iOmU=; b=Nbtn0Kum8nLsF9eR/knB/EfAoWYusQ3F89sVgG7rreetdpLiRev5wTemu1zOBfkilC Nz0nVgZkdBar1FQdEGV5ARA+bAlXYSsvGriWa5dUvf7hTsnrQGi0F2J5hv0nsRHbhPpA sjjosxL/1kzQxryaCdGiy572lXnpDFbwilVRM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=f0FcUiwXxlK5kGziXlY+lA6K8RGb0NAzv6TJW9VDJeUheNwbA/Zx+xePVxhtvaulv2 45WsEXtjIhAM1VEIRAzc1VOD/JhlzoaVCU9kcQC0iRY9+5L2Ra0eiGGn/Sn1Neu1dsgD pObhCy48j++i9Z9RyQ1sKDuuTDaZXCoqN529w=
- In-reply-to: <t2z691a5d911005011327ud5958ddld67950ad59baf1cf@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <n2jd663d1bd1005010619l8468362al946bcda107870f95@xxxxxxxxxxxxxx> <t2z691a5d911005011327ud5958ddld67950ad59baf1cf@xxxxxxxxxxxxxx>
Whoah! Thanks for a thorough explanation on how this works! The book
looks tasty and doesn't cost a fortune, I'll order it if you recommend
it. Seems to me that you know your way with zsh. Is there any other
book recommendation for mastering zsh?
--Mikael
On Sat, May 1, 2010 at 23:27, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sat, May 1, 2010 at 6:19 AM, Mikael Puhakka <mr.progo@xxxxxxxxx> wrote:
>>
>> Doc1.tex
>> Doc1.aux
>> Doc1.dvi
>> Doc1.log
>> ...
>>
>> Of these files, I'd edit the .tex file most often: I would like zsh to
>> prefer .tex files to anything else from these files. They still should
>> appear in the completion cycle, but not first.
>
> Assuming you've enabled the shell function completion system with
> "compinit", you want to add some zstyle commands to your startup
> files.
>
> In particular, you're looking for the group-name, group-order, and
> tag-order styles. You use group-name to organize sets of matches,
> group-order to determine the display order of those sets, and
> tag-order to determine whether particular sets are offered (or not).
>
> Well, actually most often you set group-name to the empty string and
> allow zsh to name the groups for you.
>
> zstyle ':completion:*' group-name ''
>
> in the particular case of file completion you can use the
> file-patterns style to organize sets of file names. A common setting
> is something like this:
>
> zstyle ':completion:*' file-patterns '%p:globbed-files
> *(-/):directories' '*:all-files'
>
> This means to offer globbed files and directories in the first set of
> completions, and everything else if there are no globbed files or
> directories among the possible matches. (A globbed-file is just one
> whose name can be generated from a wildcard pattern that you may have
> typed on the command line.)
>
> You can extend this:
>
> zstyle ':completion:*' file-patterns '*.(c|cpp|java|tex|txt):editable-files' \
> '%p:globbed-files *(-/):directories' '*:all-files'
>
> Note placement of quotes and spaces; a space inside a quoted string
> separates groups that are displayed together, while a space between
> quoted strings separates groups that are displayed sequentially, e.g.
> you'll get editable files if there are any, then globbed files or
> directories, and finally anything.
>
> It's been a long time since I plugged this, but if you really want to
> learn about this in detail you should pick up a copy of "From Bash to
> Z Shell: Conquering the Command Line" from www.apress.com.
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author