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.

85 lines
3.2 KiB

3 years ago
  1. # Fewer than 47 columns will probably work. Haven't tried it.
  2. typeset -gr __p9k_wizard_columns=47
  3. # The bottleneck is ask_tails with nerd fonts. Everything else works fine with 12 lines.
  4. typeset -gr __p9k_wizard_lines=14
  5. typeset -gr __p9k_zd=${ZDOTDIR:-$HOME}
  6. typeset -gr __p9k_zd_u=${${${(q)__p9k_zd}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
  7. typeset -gr __p9k_zshrc=${${:-$__p9k_zd/.zshrc}:A}
  8. typeset -gr __p9k_zshrc_u=$__p9k_zd_u/.zshrc
  9. typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
  10. function _p9k_can_configure() {
  11. [[ $1 == '-q' ]] && local -i q=1 || local -i q=0
  12. function $0_error() {
  13. (( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2
  14. }
  15. typeset -g __p9k_cfg_path_o=${POWERLEVEL9K_CONFIG_FILE:=${ZDOTDIR:-~}/.p10k.zsh}
  16. typeset -g __p9k_cfg_basename=${__p9k_cfg_path_o:t}
  17. typeset -g __p9k_cfg_path=${__p9k_cfg_path_o:A}
  18. typeset -g __p9k_cfg_path_u=${${${(q)__p9k_cfg_path_o}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
  19. {
  20. [[ -o multibyte ]] || { $0_error "multibyte option is not set"; return 1 }
  21. [[ -e $__p9k_zd ]] || { $0_error "$__p9k_zd_u does not exist"; return 1 }
  22. [[ -d $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not a directory"; return 1 }
  23. [[ ! -d $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a directory"; return 1 }
  24. [[ ! -d $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is a directory"; return 1 }
  25. local dir=${__p9k_cfg_path:h}
  26. while [[ ! -e $dir && $dir != ${dir:h} ]]; do dir=${dir:h}; done
  27. if [[ ! -d $dir ]]; then
  28. $0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is not a directory"
  29. return 1
  30. fi
  31. if [[ ! -w $dir ]]; then
  32. $0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is readonly"
  33. return 1
  34. fi
  35. [[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || {
  36. $0_error "$__p9k_cfg_path_u is a special file"
  37. return 1
  38. }
  39. [[ ! -e $__p9k_zshrc || -f $__p9k_zshrc || -h $__p9k_zshrc ]] || {
  40. $0_error "$__p9k_zshrc_u a special file"
  41. return 1
  42. }
  43. [[ ! -e $__p9k_zshrc || -r $__p9k_zshrc ]] || {
  44. $0_error "$__p9k_zshrc_u is not readable"
  45. return 1
  46. }
  47. local style
  48. for style in lean lean-8colors classic rainbow pure; do
  49. [[ -r $__p9k_root_dir/config/p10k-$style.zsh ]] || {
  50. $0_error "$__p9k_root_dir_u/config/p10k-$style.zsh is not readable"
  51. return 1
  52. }
  53. done
  54. (( LINES >= __p9k_wizard_lines && COLUMNS >= __p9k_wizard_columns )) || {
  55. $0_error "terminal size too small; must be at least $__p9k_wizard_columns columns by $__p9k_wizard_lines lines"
  56. return 1
  57. }
  58. [[ -t 0 && -t 1 ]] || {
  59. $0_error "no TTY"
  60. return 2
  61. }
  62. return 0
  63. } always {
  64. unfunction $0_error
  65. }
  66. }
  67. function p9k_configure() {
  68. eval "$__p9k_intro"
  69. _p9k_can_configure || return
  70. (
  71. set -- -f
  72. builtin source $__p9k_root_dir/internal/wizard.zsh
  73. )
  74. local ret=$?
  75. case $ret in
  76. 0) builtin source $__p9k_cfg_path; _p9k__force_must_init=1;;
  77. 69) return 0;;
  78. *) return $ret;;
  79. esac
  80. }