my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

3 years ago
  1. # Copy this file into /usr/share/zsh/site-functions/
  2. # and add 'autoload n-functions` to .zshrc
  3. #
  4. # This function allows to choose a function 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 ] && builtin source ~/.config/znt/n-list.conf
  15. [ -f ~/.config/znt/n-functions.conf ] && builtin source ~/.config/znt/n-functions.conf
  16. local list
  17. local selected
  18. NLIST_REMEMBER_STATE=0
  19. list=( "${(@k)functions}" )
  20. list=( "${(@M)list:#(#i)*$1*}" )
  21. local NLIST_GREP_STRING="$1"
  22. if [ "$#list" -eq 0 ]; then
  23. echo "No matching functions"
  24. return 1
  25. fi
  26. list=( "${(@i)list}" )
  27. n-list "$list[@]"
  28. if [ "$REPLY" -gt 0 ]; then
  29. selected="$reply[REPLY]"
  30. if [ "$feditor" = "zed" ]; then
  31. echo "Editing \`$selected' (ESC ZZ or Ctrl-x-w to finish):"
  32. autoload zed
  33. print -rs "zed -f -- \"$selected\""
  34. zed -f -- "$selected"
  35. else
  36. echo "Editing \`$selected':"
  37. print -rs "vared functions\\[$selected\\]"
  38. vared functions\[$selected\]
  39. fi
  40. fi
  41. # vim: set filetype=zsh: