You are not logged in.

#1 2010-07-11 15:04:32

petelewis
Package Maintainer (PM)
From: Birmingham, UK
Registered: 2008-08-14
Posts: 128
Website

Trying to learn zsh completion. Help me achieve it?

Hi,

I'm trying to learn to write completion functions for zsh, and started by writing one for unison, which looks in the profiles directory to tab-complete profiles. So far, I've got a _unison file containing the following:

#compdef unison

#typeset -A opt_args

local profiles

profiles=~/.unison

_files -W ${profiles} -g '*.prf' && return 0

return 1

Which works relatively well:

% unison <tab> 
default.prf      documents.prf    photographs.prf

Just for the fun of it really, I'd like to remove the .prf bit and just have it complete the basename. Any idea how I can achieve this?

Thanks :-)


"Cared thou not, thou would have abstained." - Xyne

Offline

#2 2010-07-11 15:30:36

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Trying to learn zsh completion. Help me achieve it?

I don't think 'basename' is the right word.
This works for bash:

for i in *.txt; do echo ${i%%.*}; done

Now you have to somehow add it to your workflow.

Offline

#3 2010-10-25 16:51:06

ugaciaka
Member
From: Italy
Registered: 2008-07-06
Posts: 140
Website

Re: Trying to learn zsh completion. Help me achieve it?

@karol

are you solved?

I'm very interested ...


I have never bought on ebay, the macbook I do not like, I do not need facebook or myspace or secondlife
I am not a nerd or lamer or troll or geek or hacker or cracker
and I have never voted to elect berlusconi

Offline

Board footer

Powered by FluxBB