_weechat 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #compdef weechat-curses
  2. local state ret=-1
  3. _arguments -s -C \
  4. '(-a --no-connect)'{-a,--no-connect}'[disable auto-connect to servers at startup]' \
  5. '(-c --config)'{-c,--config}'[display config file options]' \
  6. '(-d --dir)'{-d,--dir}'[set WeeChat home directory (default: ~/.weechat)]:dir:_dir_list' \
  7. '(-f --key-functions)'{-f,--key-functions}'[display WeeChat internal functions for keys]' \
  8. '(-h --help)'{-h,--help}'[display help and usage]' \
  9. '(-i --irc-commands)'{-i,--irc-commands}'[display IRC commands]' \
  10. '(-k --keys)'{-k,--keys}'[display WeeChat default keys]' \
  11. '(-l --license)'{-l,--license}'[display WeeChat license]' \
  12. '(-p --no-plugin)'{-p,--no-plugin}"[don't load any plugin at startup]" \
  13. '(-v --version)'{-v,--version}'[display WeeChat version]' \
  14. '(-w --weechat-commands)'{-w,--weechat-commands}'[display WeeChat commands]' \
  15. '1:url:->weeurl' \
  16. '*::arguments _normal' \
  17. && ret=0
  18. if [ "$state" = 'weeurl' ]; then
  19. urls=( irc:// ircs:// irc6:// irc6s:// )
  20. nicks=( $(grep server_nick ~/.weechat/weechat.rc | tr -d '"' | cut -d ' ' -f3 | tr '\n' ' ') )
  21. nicks+=('undef')
  22. pass=( $(grep server_password ~/.weechat/weechat.rc | tr -d '"' | cut -d ' ' -f3 | tr '\n' ' ') )
  23. pass+=('undef')
  24. servers=( $(grep server_address ~/.weechat/weechat.rc | tr -d '"' | cut -d ' ' -f3 | tr '\n' ' ') )
  25. servers+=('undef')
  26. set -a weeconf
  27. weeconf=()
  28. for u in $urls ; do
  29. for n in $nicks ; do
  30. for p in $pass; do
  31. for s in $servers; do
  32. value=$u
  33. if [ "$n" != 'undef' ]; then
  34. if [ "$p" != 'undef' ]; then
  35. value="${value}${n}:${p}"
  36. else
  37. value="${value}${n}"
  38. fi
  39. if [ "$s" != 'undef' ]; then
  40. value="${value}@${s}"
  41. fi
  42. else
  43. if [ "$s" != 'undef' ]; then
  44. value="${value}${s}"
  45. fi
  46. fi
  47. weeconf+=( $value )
  48. done
  49. done
  50. done
  51. done
  52. _wanted weeconf expl weeconf compadd $weeconf
  53. fi
  54. return ret