Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Text Editor Filename Completion
- X-seq: zsh-users 8583
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Text Editor Filename Completion
- Date: Fri, 11 Mar 2005 16:50:27 +0000
- In-reply-to: <200503111310.j2BDA7v8013309@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20050311125532.GA22235@xxxxxxxxxxxxxxxx> <200503111310.j2BDA7v8013309@xxxxxxxxxxxxxx>
On Mar 11, 1:10pm, Peter Stephenson wrote:
} Subject: Re: Text Editor Filename Completion
}
} > Does anyone have any completion commands set up for vi or emacs that
} > give preference to plain text files -- those containing source code --
}
} zstyle ':completion:*:*:(emacs|vi):*' file-patterns \
} '*.(c|h|pl|tex|txt):globbed-files *(-/):directories' '*:all-files'
How about this:
textfiles() {
reply=( ${${(@M)${(f)"$(file $REPLY 2>/dev/null)"}\:#*text*}%:*} )
}
zstyle ':completion:*:*:(emacs|vi|vim):*' file-patterns \
'%p(e,textfiles,):globbed-files *(-/):directories' '*:all-files'
(I found that I needed the "|vim" in there because vi is aliased to vim
on my system and the alias is expanded before the completion context is
established [unless you setopt completealiases]).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author