Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ordering of file-patterns completions



On Nov 6, 11:30pm, John wrote:
} >
} > If there's nothing but options, for example, then you can probably do:
} >
} >    local first_file=$(( ${words[(I)-*]} + 1 ))
} >
} The first one nearly does it, but seems to be confused when there are no 
} options at all.

Ah, yes.  Because it's counting backwards it will run down to zero if it
finds nothing.  I listed that one first because it was the simplest
expression, but I should have stuck with the second one:

} >    local first_file=$(( ${${words[2,-1]}[(i)[^-]*]} + 1 ))

[...]

} I ended up adding:
} 
} if [[ $first_file -lt 2 ]]; then
}          first_file=2
} fi
} 
} And that fixed it.  Not realizing that the array was 1-based threw me 
} for a bit.  I also changed the :x to a :e, as :x just gave me an error, 
} and :e matched the description of what I think you had meant.

Oops, yes, I did mean :e.  Typo'd it earlier and then just kept copy-
pasting.



Messages sorted by: Reverse Date, Date, Thread, Author