Files
dotfiles/utils.sh
Andrejus 0d87c48e9c cleanup
intsall fix attempts

add pyenv path after install

use https repository

install apt-utils

set FAST_MODE in bootstrap.sh

keep truthy FAST_MODE variable

source bashrc after linking

clean up errors

further install fixes

further cleanup

fix fisher install

chmod +x install

remove source bashrc from make
2020-03-02 21:18:00 +00:00

114 lines
2.3 KiB
Bash

#!/usr/bin/env bash
#
# Alias commands and utilities.
#
# ---------------------------------------------------------------------------- #
# Helper functions
# ---------------------------------------------------------------------------- #
clean() {
sudo apt-get clean
}
update() {
sudo apt-get update -qq
}
# Non-interactive upgrade
# Skip if FAST_MODE is defined
upgrade() {
[ "$FAST_MODE" != false ] && return
DEBIAN_FRONTEND=noninteractive \
sudo apt-get dist-upgrade -qq \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"
}
# @arg $1 packages to install
install() {
sudo apt-get install -qq $1
refresh
}
# @arg $1 package list file to install
install_file() {
sudo apt-get install -fqq $(cat $1)
refresh
}
# @arg $1 repository to add
add_ppa() {
sudo add-apt-repository -y ppa:$1
}
# @arg $1 url to add
add_key() {
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true \
curl -fsSL $1 \
| sudo apt-key add -
}
# @arg $1 URL to run
# @arg $2 binary to use
run() {
curl -fsSL $1 | $2 | indent
}
# Symlink contents of source folder to target
#
# @arg $1 source folder
# @arg $2 target folder
link_folder() {
mkdir -p $2
cp -srf $1/. $2
}
indent() { sed 's/^/ /'; }
# @arg $1 binary to test
not_installed() {
! [ -x "$(command -v $1)" ]
}
# Refreshes PATH
refresh() {
hash -r
}
# Add to PATH and refresh
# @arg $1 path to add to PATH
add_path() {
export PATH="$1:$PATH"
refresh
}
# ---------------------------------------------------------------------------- #
# Function exports
# ---------------------------------------------------------------------------- #
export -f clean update upgrade install install_file add_ppa add_key run \
link_folder indent not_installed refresh add_path
# ---------------------------------------------------------------------------- #
# Shell colours
# ---------------------------------------------------------------------------- #
C_BLACK='\033[0;30m'
C_DGRAY='\033[1;30m'
C_RED='\033[0;31m'
C_LRED='\033[1;31m'
C_GREEN='\033[0;32m'
C_LGREEN='\033[1;32m'
C_ORANGE='\033[0;33m'
C_YELLOW='\033[1;33m'
C_BLUE='\033[0;34m'
C_LBLUE='\033[1;34m'
C_PURPLE='\033[0;35m'
C_LPURPLE='\033[1;35m'
C_CYAN='\033[0;36m'
C_LCYAN='\033[1;36m'
C_LGRAY='\033[0;37m'
C_WHITE='\033[1;37m'
C_NC='\033[0m'