n-aliases 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copy this file into /usr/share/zsh/site-functions/
  2. # and add 'autoload n-aliases` to .zshrc
  3. #
  4. # This function allows to choose an alias for edition with vared
  5. #
  6. # Uses n-list
  7. emulate -L zsh
  8. setopt extendedglob
  9. zmodload zsh/curses
  10. zmodload zsh/parameter
  11. local IFS="
  12. "
  13. unset NLIST_COLORING_PATTERN
  14. [ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
  15. [ -f ~/.config/znt/n-aliases.conf ] && . ~/.config/znt/n-aliases.conf
  16. local list
  17. local selected
  18. NLIST_REMEMBER_STATE=0
  19. list=( "${(@k)aliases}" )
  20. list=( "${(@M)list:#(#i)*$1*}" )
  21. local NLIST_GREP_STRING="$1"
  22. if [ "$#list" -eq 0 ]; then
  23. echo "No matching aliases"
  24. return 1
  25. fi
  26. list=( "${(@i)list}" )
  27. n-list "$list[@]"
  28. if [ "$REPLY" -gt 0 ]; then
  29. selected="$reply[REPLY]"
  30. echo "Editing \`$selected':"
  31. print -rs "vared aliases\\[$selected\\]"
  32. vared aliases\[$selected\]
  33. fi
  34. # vim: set filetype=zsh: