Pregunta

Here is the feature I wanted.

Every time I want to search something in my project directory. I use ack to search some keyword for me.

ack hey

And sometimes I want to search more than one word. So I type

ack "hey there"

I wish the double quote can be auto completed after I type ack and press tab, and the cursor can be focus between the double quotes.

Somebody know how to make it?

I had tried to make a oh-my-zsh plugin for this. But seems I need some guide for help.

function _ack_commands() {
    echo -n '"'
}

compdef _ack_commands ack
¿Fue útil?

Solución

Can't you just use

zsh -f
ack() { command ack "$*" }
ack hey there

or something along these lines?

[...]

Actually I was curious if I could write something along what you described. I have to reckon that my zsh-fu is not enough for it.

To muck with the cursor position, you would normally change the CURSOR value (see man zshzle). From within zle widgets you would access special values by using zmodload -i zsh/parameter (see man zshmodules). But the trick is that -as stated in the zshzle man page):

Inside completion widgets and traps called while ZLE is active, these parameters are available read-only.

So we can't change the value of CURSOR from inside a completion widget.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top