_wd.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #compdef wd
  2. zstyle ':completion:*:descriptions' format '%B%d%b'
  3. zstyle ':completion::complete:wd:*:commands' group-name commands
  4. zstyle ':completion::complete:wd:*:warp_points' group-name warp_points
  5. zstyle ':completion::complete:wd::' list-grouped
  6. zmodload zsh/mapfile
  7. function _wd() {
  8. local CONFIG=$HOME/.warprc
  9. local ret=1
  10. local -a commands
  11. local -a warp_points
  12. warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
  13. commands=(
  14. 'add:Adds the current working directory to your warp points'
  15. 'add!:Overwrites existing warp point'
  16. 'rm:Removes the given warp point'
  17. 'ls:Outputs all stored warp points'
  18. 'show:Outputs all warp points that point to the current directory'
  19. 'help:Show this extremely helpful text'
  20. '..:Go back to last directory'
  21. )
  22. _arguments -C \
  23. '1: :->first_arg' \
  24. '2: :->second_arg' && ret=0
  25. case $state in
  26. first_arg)
  27. _describe -t warp_points "Warp points" warp_points && ret=0
  28. _describe -t commands "Commands" commands && ret=0
  29. ;;
  30. second_arg)
  31. case $words[2] in
  32. add\!|rm)
  33. _describe -t points "Warp points" warp_points && ret=0
  34. ;;
  35. add)
  36. _message 'Write the name of your warp point' && ret=0
  37. ;;
  38. esac
  39. ;;
  40. esac
  41. return $ret
  42. }
  43. _wd "$@"
  44. # Local Variables:
  45. # mode: Shell-Script
  46. # sh-indentation: 2
  47. # indent-tabs-mode: nil
  48. # sh-basic-offset: 2
  49. # End:
  50. # vim: ft=zsh sw=2 ts=2 et