mirror of
https://github.com/ff4500/utilities.git
synced 2026-07-01 11:47:04 -05:00
working
This commit is contained in:
81
system/macos/basic_IM_utilities_setup/lib/echos.sh
Executable file
81
system/macos/basic_IM_utilities_setup/lib/echos.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!//bin/bash
|
||||
|
||||
###
|
||||
# some colorized echo helpers
|
||||
# @author Adam Eivy
|
||||
# https://raw.githubusercontent.com/atomantic/dotfiles/master/lib_sh/echos.sh
|
||||
###
|
||||
|
||||
# Colors
|
||||
ESC_SEQ="\x1b["
|
||||
COL_RESET=$ESC_SEQ"39;49;00m"
|
||||
COL_RED=$ESC_SEQ"31;01m"
|
||||
COL_GREEN=$ESC_SEQ"32;01m"
|
||||
COL_YELLOW=$ESC_SEQ"33;01m"
|
||||
COL_BLUE=$ESC_SEQ"34;01m"
|
||||
COL_MAGENTA=$ESC_SEQ"35;01m"
|
||||
COL_CYAN=$ESC_SEQ"36;01m"
|
||||
SEP_COLOR=$ESC_SEQ"36;01m"
|
||||
|
||||
COL_DIM=$ESC_SEQ"2;49;90m"
|
||||
SEP_COLOR_DIM=$ESC_SEQ"38;5;8m"
|
||||
DIMDOTS=$ESC_SEQ"2;49;90m..."$COL_RESET
|
||||
|
||||
COL_PURPLE_BG=$ESC_SEQ"38;2;0;0;0m"$ESC_SEQ"48;2;110;0;255m"
|
||||
|
||||
columns="$(tput cols)"
|
||||
ov_sep="-------------------------------------------------"
|
||||
open_vers_1="MacOS install script - v0.0.1"
|
||||
open_vers_2="via https://github.com/ff4500/utilities"
|
||||
open_title="We're going to run some tests to see what you already have setup on your system."
|
||||
|
||||
function ok() {
|
||||
echo -e "${COL_GREEN}[ok]${COL_RESET}" $1
|
||||
}
|
||||
|
||||
function bot() {
|
||||
echo -e "\n${COL_GREEN}\[._.]/${COL_RESET} -" $1
|
||||
}
|
||||
|
||||
function running() {
|
||||
echo -e "${COL_YELLOW} ⇒ ${COL_RESET}" $1 ": "
|
||||
}
|
||||
|
||||
function action() {
|
||||
echo -e "\n${COL_YELLOW}[action]:${COL_RESET}\n ⇒ $1..."
|
||||
}
|
||||
|
||||
function warn() {
|
||||
echo -e "${COL_YELLOW}[warning]${COL_RESET}" $1
|
||||
}
|
||||
|
||||
function error() {
|
||||
echo -e "${COL_RED}[error]${COL_RESET}" $1
|
||||
}
|
||||
|
||||
function seperator() {
|
||||
local sized=$(stty size | awk '{print $2}')
|
||||
local len=${sized}
|
||||
local ch="-"
|
||||
local TERM_WIDTH="$(printf '%*s' "${len}" | tr ' ' "${ch}")"
|
||||
|
||||
echo -e "${SEP_COLOR}${TERM_WIDTH}${COL_RESET}"
|
||||
}
|
||||
|
||||
function display_center() {
|
||||
while IFS= read -r line; do
|
||||
printf "%*s\n" $(( (${#line} + columns) / 2)) "$line"
|
||||
done < "$1"
|
||||
}
|
||||
|
||||
function opening_title() {
|
||||
echo -e "${SEP_COLOR_DIM}"
|
||||
printf "%*s\n" $(((${#ov_sep}+$columns)/2)) "$ov_sep"
|
||||
printf "%*s\n" $(((${#open_vers_1}+$columns)/2)) "$open_vers_1"
|
||||
printf "%*s\n" $(((${#open_vers_2}+$columns)/2)) "$open_vers_2"
|
||||
printf "%*s\n" $(((${#ov_sep}+$columns)/2)) "$ov_sep"
|
||||
echo -e "${COL_RESET}";
|
||||
seperator
|
||||
printf "%*s\n" $(((${#open_title}+$columns)/2)) "$open_title"
|
||||
seperator
|
||||
}
|
||||
70
system/macos/basic_IM_utilities_setup/lib/functions.sh
Executable file
70
system/macos/basic_IM_utilities_setup/lib/functions.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
function install_homebrew() {
|
||||
brew_check=$(command -v brew) > /dev/null 2>&1
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "You don't have Homebrew installed. Installing..."
|
||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
if [[ $? != 0 ]]; then
|
||||
error "unable to install homebrew, script $0 abort!"
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
echo -e "Brew is already installed"
|
||||
read -r -p "Would you like to run brew update && upgrade? [y|N] " response
|
||||
if [[ $response =~ (y|yes|Y) ]]; then
|
||||
action "Updating homebrew..."
|
||||
brew update
|
||||
ok "Homebrew updated"
|
||||
action "Upgrading brew packages..."
|
||||
brew upgrade
|
||||
ok "Brews upgraded"
|
||||
else
|
||||
ok "Skipped brew package upgrades."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function install_brewcask() {
|
||||
output=$(command -v brew cask --version) > /dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "brew-cask is not installed"
|
||||
else
|
||||
echo -e "brew-cask is installed"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# source ./echos.sh
|
||||
|
||||
function require_cask() {
|
||||
running "brew cask $1"
|
||||
brew cask list $1 > /dev/null 2>&1 | true
|
||||
if [[ ${PIPESTATUS[0]} != 0 ]]; then
|
||||
action "brew cask install $1 $2"
|
||||
brew cask install $1
|
||||
if [[ $? != 0 ]]; then
|
||||
error "failed to install $1! aborting..."
|
||||
# exit -1
|
||||
fi
|
||||
fi
|
||||
ok
|
||||
}
|
||||
|
||||
function require_brew() {
|
||||
running "brew $1 $2"
|
||||
brew list $1 > /dev/null 2>&1 | true
|
||||
if [[ ${PIPESTATUS[0]} != 0 ]]; then
|
||||
action "brew install $1 $2"
|
||||
brew install $1 $2
|
||||
if [[ $? != 0 ]]; then
|
||||
error "failed to install $1! aborting..."
|
||||
# exit -1
|
||||
fi
|
||||
fi
|
||||
ok
|
||||
}
|
||||
23
system/macos/basic_IM_utilities_setup/setup.sh
Executable file
23
system/macos/basic_IM_utilities_setup/setup.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Install Homebrew
|
||||
# ----------------------------------------------------------------
|
||||
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
#
|
||||
# Install iterm2 and Atom
|
||||
# ----------------------------------------------------------------
|
||||
# brew cask install iterm2 atom
|
||||
#
|
||||
# Install ImageMagick
|
||||
# ----------------------------------------------------------------
|
||||
# brew install imagemagick
|
||||
|
||||
source ./lib/echos.sh
|
||||
source ./lib/functions.sh
|
||||
|
||||
opening_title
|
||||
|
||||
# Install Homebrew
|
||||
# ----------------------------------------------------------------
|
||||
running "Checking homebrew..."
|
||||
install_homebrew
|
||||
Reference in New Issue
Block a user