@@ -1,180 +0,0 @@
8−ORANGE='\033[38;2;255;140;0m'
9−NC='\033[0m' # No Color
11−requested_version=${VERSION:-}
13−os=$(uname -s | tr '[:upper:]' '[:lower:]')
14−if [[ "$os" == "darwin" ]]; then
19−if [[ "$arch" == "aarch64" ]]; then
23−filename="$APP-$os-$arch.tar.gz"
28− [[ "$arch" == "x86_64" || "$arch" == "arm64" || "$arch" == "i386" ]] || exit 1
31− [[ "$arch" == "x86_64" || "$arch" == "arm64" ]] || exit 1
34− echo "${RED}Unsupported OS/Arch: $os/$arch${NC}"
39−INSTALL_DIR=$HOME/.crush/bin
40−mkdir -p "$INSTALL_DIR"
42−if [ -z "$requested_version" ]; then
43− url="https://github.com/charmbracelet/crush/releases/latest/download/$filename"
44− specific_version=$(curl -s https://api.github.com/repos/charmbracelet/crush/releases/latest | awk -F'"' '/"tag_name": "/ {gsub(/^v/, "", $4); print $4}')
46− if [[ $? -ne 0 ]]; then
47− echo "${RED}Failed to fetch version information${NC}"
51− url="https://github.com/charmbracelet/crush/releases/download/v${requested_version}/$filename"
52− specific_version=$requested_version
61− info) color="${GREEN}" ;;
62− warning) color="${YELLOW}" ;;
63− error) color="${RED}" ;;
66− echo -e "${color}${message}${NC}"
70− if command -v crush >/dev/null 2>&1; then
71− crush_path=$(which crush)
74− ## TODO: check if version is installed
75− # installed_version=$(crush version)
76− installed_version="0.0.1"
77− installed_version=$(echo $installed_version | awk '{print $2}')
79− if [[ "$installed_version" != "$specific_version" ]]; then
80− print_message info "Installed version: ${YELLOW}$installed_version."
82− print_message info "Version ${YELLOW}$specific_version${GREEN} already installed"
88−download_and_install() {
89− print_message info "Downloading ${ORANGE}crush ${GREEN}version: ${YELLOW}$specific_version ${GREEN}..."
90− mkdir -p crushtmp && cd crushtmp
91− curl -# -L $url | tar xz
92− mv crush $INSTALL_DIR
93− cd .. && rm -rf crushtmp
101− local config_file=$1
104− if [[ -w $config_file ]]; then
105− echo -e "\n# crush" >> "$config_file"
106− echo "$command" >> "$config_file"
107− print_message info "Successfully added ${ORANGE}crush ${GREEN}to \$PATH in $config_file"
109− print_message warning "Manually add the directory to $config_file (or similar):"
110− print_message info " $command"
114−XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
116−current_shell=$(basename "$SHELL")
117−case $current_shell in
119− config_files="$HOME/.config/fish/config.fish"
122− config_files="$HOME/.zshrc $HOME/.zshenv $XDG_CONFIG_HOME/zsh/.zshrc $XDG_CONFIG_HOME/zsh/.zshenv"
125− config_files="$HOME/.bashrc $HOME/.bash_profile $HOME/.profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile"
128− config_files="$HOME/.ashrc $HOME/.profile /etc/profile"
131− config_files="$HOME/.ashrc $HOME/.profile /etc/profile"
134− # Default case if none of the above matches
135− config_files="$HOME/.bashrc $HOME/.bash_profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile"
140−for file in $config_files; do
141− if [[ -f $file ]]; then
147−if [[ -z $config_file ]]; then
148− print_message error "No config file found for $current_shell. Checked files: ${config_files[@]}"
152−if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
153− case $current_shell in
155− add_to_path "$config_file" "fish_add_path $INSTALL_DIR"
158− add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
161− add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
164− add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
167− add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
170− print_message warning "Manually add the directory to $config_file (or similar):"
171− print_message info " export PATH=$INSTALL_DIR:\$PATH"
176−if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then
177− echo "$INSTALL_DIR" >> $GITHUB_PATH
178− print_message info "Added $INSTALL_DIR to \$GITHUB_PATH"