#!/usr/bin/env bash # Sets up termux on my android device # setup zsh files # delete default files if they exist original_files=("${HOME}/.zshenv" "${HOME}/.zshrc" "${HOME}/.zsh_history") for file in "${original_files[@]}"; do rm -rf "${file}" done # bash will typically source ~/.profile on shell launch # if we haven't switched to zsh, a shell restart should # cause this to be sourced echo 'Setting up zsh profile...' # shellcheck disable=SC2016 echo 'source "${HOME}/.profile"; export TERM=xterm-256color' >"${HOME}/.zshenv" # check if we have access to the my directories # on my $PATH, to see if zsh has been properly configured if [[ ! "$(command -v havecmd)" ]]; then printf "Issue finding 'havecmd', environment is not setup properly\n" printf "Try restarting the shell and making sure ~/.profile is getting sourced\n" exit 1 fi # set zsh as shell if ! echo "${SHELL}" | grep -q '/zsh'; then havecmd zsh || apt install zsh chsh -s zsh # seems to be different on termux? abort "Restart shell so that zsh environment is setup. Then re-run 'yadm bootstrap'" else echo "zsh is already set as your default shell" fi declare -rx TERMUX_PACKAGES="${PACKAGE_DIR}/android_packages.txt" # Install spkglist so I can parse package lists set -e havecmd go || apt install golang install_go_cmds set +e for lib in $(spkglist "${TERMUX_PACKAGES}"); do if ! dpkg-query -W -f='${Status}' "${lib}" | grep -q "ok installed"; then # if package isn't installed yes | apt install "${lib}" fi done # setup some additional directories set -u [[ ! -d "${HOME}/storage" ]] && termux-setup-storage mkdir -vp "${REPOS}" [[ ! -e "${HOME}/data" ]] && ln -vs "${HPIDATA}" "${HOME}/data" [[ ! -e "${HOME}/shared" ]] && ln -vs "${HOME}/storage/shared" "${HOME}/shared" set +u # dont want to go through all the cargo/golang package lists # I use on computers, since a lot of them aren't useful here # manually install some commands havecmd cargo || exit $? # needed to build some packages havecmd evry || cargo install evry # task scheduling havecmd wait-for-internet || cargo install wait-for-internet havecmd eza || cargo install eza CARGO_INSTALLED_PACKAGES="$(cargo install --list | sed -E -e '/^\s+/d; s|\s.*||')" grep -q 'cargo-update' <<<"$CARGO_INSTALLED_PACKAGES" || cargo install cargo-update havecmd shfmt || GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest havecmd arctee || python3 -m pip install git+https://github.com/karlicoss/arctee havecmd todo.sh || basher install todotxt/todo.txt-cli # manually build some python packages which have C extensions INSTALLED_PYTHON_PACKAGES="$(python3 -m pip list --format=freeze | cut -d'=' -f1)" # grep -xqi 'numpy' <<<"${INSTALLED_PYTHON_PACKAGES}" || LDFLAGS=" -lm -lcompiler_rt" pip install numpy --verbose grep -xqi 'cython' <<<"${INSTALLED_PYTHON_PACKAGES}" || LDFLAGS=" -lcompiler_rt" pip install cython --verbose # grep -xqi 'pandas' <<<"${INSTALLED_PYTHON_PACKAGES}" || CFLAGS="-Wno-deprecated-declarations -Wno-unreachable-code" pip install pandas --verbose # Install zsh plugins manually ZSH_PLUGINS="${XDG_DATA_HOME}/zsh_plugins" mkdir -p "$ZSH_PLUGINS" cd "$ZSH_PLUGINS" AUTOSUGGESTIONS="${ZSH_PLUGINS}/zsh-autosuggestions" if [[ -d "${AUTOSUGGESTIONS}" ]]; then (cd "${AUTOSUGGESTIONS}" && git pull) else git clone 'https://github.com/zsh-users/zsh-autosuggestions' fi cd