zsh-users / zaw

zsh anything.el-like widget.
BSD 3-Clause "New" or "Revised" License
572 stars 67 forks source link

Allow for custom actions on enter/meta-enter #96

Closed shanematley closed 6 years ago

shanematley commented 6 years ago

The custom actions may be set using zstyle configuration. Configuration is set in the following way:

zstyle ':zaw:<source-name>' default "<func-name|action description>"
zstyle ':zaw:<source-name>' alt "<func-name|action description>"

Also add "(Enter)" or "(Meta-enter)" to the description of actions when selecting an action.

An example:

# Set default action for git-files using the description
zstyle ':zaw:git-files' default 'append to edit buffer'
# Set alternate action for git-files using the name of function
zstyle ':zaw:git-files' alt zaw-callback-edit-file

Now using Enter/Meta-enter will use the actions mentioned above. When tab is hit and an action is being selected, the following will be displayed, highlighting the default/alt actions for future use:

filter:
select action for 'zaw.zsh'
edit file (Meta-enter)
add
add -p
reset
checkout
rm
append to edit buffer (Enter)
[1/7]
shanematley commented 6 years ago

I think I've addressed your comments @termoshtt. Thanks for the feedback.

termoshtt commented 6 years ago

OK, looks good for me. Thanks your contribution!

shanematley commented 6 years ago

No worries.