From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9048 invoked from network); 6 Sep 2000 06:57:53 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 6 Sep 2000 06:57:53 -0000 Received: (qmail 2868 invoked by alias); 6 Sep 2000 06:57:22 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3408 Received: (qmail 2861 invoked from network); 6 Sep 2000 06:57:21 -0000 Message-ID: <20000906065717.23345.qmail@web1104.mail.yahoo.com> Date: Tue, 5 Sep 2000 23:57:17 -0700 (PDT) From: Felix Rosencrantz Subject: Zstyle trick for always adding fake filenames To: zsh-users MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Here's a style trick I'm using and think others might find useful. It seems little tricks like this might be suited for some sort of zsh cookbook, but there isn't one, so I'm sending it the zsh-users to be archived. Problem: You want to add fake file and directory names to completion for all filename completions regardless of what directory the completion may be happening in. Solution: Use ${PREFIX:h} in your reply. reply=("${PREFIX:h}:fake1 fake2 fake3") For example, when using configure I like to set the "--prefix" option to include the version of the tool I'm configuring. Usually this directory doesn't exist in the destination directory (e.g. /opt or /usr/local). Though the component name is usually a part of the current working directory, many times it ${PWD:t} (i.e. basename $PWD). Which can be added using this zstyle command. zstyle -e :completion::complete:configure:option--prefix-1:files fake 'reply=("${PREFIX:h}:${PWD:t}")' Explanation: -e says that the value of this style is determined by eval'ing the this style's value and taking the value of the parameter "reply" as the value to use. Context value (:comple...prefix-1:files) was found with the _complete_help ("^Xh") widget. binding and refers to the value of the --prefix option. fake is the style name to add names to the list of files being completed. It has an array value. Each element of the array has the format "directory:name1...nameN", where directory has to match the directory that is being completed in. If the directory matches then name1 through nameN are added to the list of directories being added, even if no such files really exist. reply=(...) This is how a "zstyle -e" communicates back to zsh what the real value should be. ${PREFIX:h} PREFIX is the value of the path that the user has already typed (or matched). The ":h" (e.g. dirname $PREFIX) makes sure that we have a directory name that will match the directory we are completing in for the purpose of adding fakes. ${PWD:t} returns "basename $PWD" just adding the component part. -FR __________________________________________________ Do You Yahoo!? Yahoo! Mail - Free email you can access from anywhere! http://mail.yahoo.com/