summarylogtreecommitdiffstats
path: root/cursor-ai-bin.install
blob: 300aa906bb5cf96f7a7414fc23908ca7684d4ed3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
_cursor_ai_supports_color() {
  [ "${CLICOLOR_FORCE:-0}" = "1" ] && return 0
  [ -z "${NO_COLOR:-}" ] || return 1
  [ "${TERM:-dumb}" != "dumb" ] || return 1

  if command -v tput >/dev/null 2>&1; then
    _colors="$(tput colors 2>/dev/null || printf '0')"
    [ "${_colors:-0}" -ge 8 ] 2>/dev/null
    return
  fi

  # Fallback: assume ANSI colors if TERM is set and not dumb.
  return 0
}

_cursor_ai_set_theme() {
  if _cursor_ai_supports_color; then
    if command -v tput >/dev/null 2>&1; then
      C_RESET="$(tput sgr0)"
      C_BOLD="$(tput bold)"
      C_STAR="$(tput setaf 6)"
      C_SNOW="$(tput setaf 7)"
      C_TEXT="$(tput setaf 4)"
      C_LINK="$(tput setaf 3)"
    else
      C_RESET="$(printf '\033[0m')"
      C_BOLD="$(printf '\033[1m')"
      C_STAR="$(printf '\033[36m')"
      C_SNOW="$(printf '\033[37m')"
      C_TEXT="$(printf '\033[34m')"
      C_LINK="$(printf '\033[33m')"
    fi
  else
    C_RESET=""
    C_BOLD=""
    C_STAR=""
    C_SNOW=""
    C_TEXT=""
    C_LINK=""
  fi
}

_cursor_ai_print_message() {
  _cursor_ai_set_theme
  _mode="$1"

  if [ "$_mode" = "install" ]; then
    _headline="Thank you for installing cursor-ai-bin!"
  else
    _headline="Thank you for updating cursor-ai-bin!"
  fi

  printf '%s\n' "${C_STAR}${C_SNOW}❄️${C_RESET} ${C_BOLD}${_headline}${C_RESET} ${C_SNOW}❄️${C_STAR}${C_RESET}"
  printf '%s\n' "${C_TEXT}  ↳ Need help or want to report an issue?${C_RESET}"
  printf '%s\n' "${C_LINK}   ${C_BOLD}https://aur.archlinux.org/packages/cursor-ai-bin${C_RESET}"
  printf '%s\n' "${C_TEXT}  ↳ Maintainer availability: usually almost 24/7.${C_RESET}"
  printf '%s\n' "${C_TEXT}  ↳ Any kind of contribution or support is appreciated.${C_RESET}"
}

post_install() {
  _cursor_ai_print_message install
}

post_upgrade() {
  _cursor_ai_print_message upgrade
}