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.

47 lines
918 B

3 years ago
  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 ] && builtin source ~/.config/znt/n-list.conf
  15. [ -f ~/.config/znt/n-aliases.conf ] && builtin source ~/.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: