I am trying to emulate the behaviour of ultisnips with zsh, mainly the feature of having multiple place holders. For example, I use taskwarrior a lot but always with the same structure:

taskwarrior add p:PROJECT due:DATE TASKDescription

To speed ups things I wanted to have a snippet that with a key (e.g., "tadd") expands to:

taskwarrior add p: due: 

with the placeholder after "p:" and when I press a key (e.g., ctrl+j) jumps to the next placeholder, i.e., after "due:". In Ultisnips I can do:

snippet tadd "Taskwarrio" b
taskwarrior add p:$1 due:$2 $3

Any idea of how to it in ZSH?

  • do you need the slots and jumping about or would a function tadd { taskwarrior add p:$1 due:$2 $3 } suffice?
    – thrig
    Nov 15 '18 at 23:38
  • Perhaps github.com/Paris/IronAHK could accomplish the same objective.
    – a.t.
    Jul 26 '20 at 9:45

I'm under the impression you want a function like in any Bourne-like shell:

defined like:

tadd() taskwarrior add p:$1 due:$2 $3

To be invoked as:

tadd PROJECT DATE TASKDescription
  • well, that for sure would work but it is not what I wanted. I wanted to actually expand the command and edit it as I find appropriated. Moreover, snippets are much more flexible than functions but if we do not have the multiple placeholders in ZSH it is not so useful... Nov 16 '18 at 8:12
  • @user2801023, you can use t: in vi mode to jump to the next : (or Ctrl+S : in emacs mode) assuming that's what you mean by placeholder. Nov 16 '18 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.