#!/bin/sh set -e # Fancy color setup: # https://unix.stackexchange.com/questions/9957/how-to-check-if-bash-can-print-colors if test -t 1; then ncolors=$(tput colors) if test -n "$ncolors" && test $ncolors -ge 8; then bold="$(tput bold)" underline="$(tput smul)" standout="$(tput smso)" normal="$(tput sgr0)" black="$(tput setaf 0)" red="$(tput setaf 1)" green="$(tput setaf 2)" yellow="$(tput setaf 3)" blue="$(tput setaf 4)" magenta="$(tput setaf 5)" cyan="$(tput setaf 6)" white="$(tput setaf 7)" fi fi insert_env_line() { if [ -f "$1" ]; then if [ -z "$(cat "$1" | grep "${ENV_LINE}")" ]; then echo "${ENV_LINE}" >> "$1" fi fi } echo "Installing ${yellow}starkliup${normal}..." BASE_DIR=${XDG_CONFIG_HOME:-$HOME} STARKLI_DIR=${STARKLI_DIR-"$BASE_DIR/.starkli"} STARKLI_BIN_DIR="$STARKLI_DIR/bin" STARKLI_MAN_DIR="$STARKLI_DIR/share/man/man1" STARKLI_BASH_COMPLETIONS_DIR="$STARKLI_DIR/share/bash-completions" STARKLI_FISH_COMPLETIONS_DIR="$STARKLI_DIR/share/fish-completions" STARKLI_ZSH_COMPLETIONS_DIR="$STARKLI_DIR/share/zsh-completions" BIN_URL="https://raw.githubusercontent.com/xJonathanLEI/starkli/master/starkliup/starkliup" BIN_PATH="$STARKLI_BIN_DIR/starkliup" ENV_PATH="$STARKLI_DIR/env" ENV_FISH_PATH="$STARKLI_DIR/env-fish" mkdir -p $STARKLI_BIN_DIR mkdir -p $STARKLI_MAN_DIR mkdir -p $STARKLI_BASH_COMPLETIONS_DIR mkdir -p $STARKLI_FISH_COMPLETIONS_DIR mkdir -p $STARKLI_ZSH_COMPLETIONS_DIR curl -# -L $BIN_URL -o $BIN_PATH chmod +x $BIN_PATH # Generates the env file on the fly for shells other than Fish cat > $ENV_PATH < $ENV_FISH_PATH <