Change the Termux project to stay put rather than use deleteme's. Add an update checker similar to shared project.
This commit is contained in:
34
bashrc.sh
34
bashrc.sh
@@ -22,6 +22,11 @@ else
|
||||
export PS1='\[$BOLD\]\[$GRAY\][\[$ORANGE\]\t \[$GREEN\]\w\[$GRAY\]]\[$RESET\]\$ '
|
||||
fi
|
||||
|
||||
if [[ -z "$BRANCH" ]]; then
|
||||
export BRANCH="dev"
|
||||
fi
|
||||
|
||||
|
||||
## Aliases ##
|
||||
|
||||
# Quickly log onto production server.
|
||||
@@ -118,16 +123,26 @@ function commit {
|
||||
|
||||
# Easily test this project after committing changes.
|
||||
# Otherwise can just source this file unless testing setup.sh.
|
||||
project="$HOME/.git-env-termux"
|
||||
function test-termux {
|
||||
sh -c "rm -rf ~/termux-deleteme ~/TRASH/termux-deleteme" 2>/dev/null
|
||||
if [[ -d "$project" ]]; then
|
||||
log "`date` - Updating '$project'.\n"
|
||||
git -C "$project" switch "$branch"
|
||||
git -C "$project" pull --recurse-submodules || \
|
||||
( echo "Failed to pull project, exiting." && return 1 )
|
||||
else
|
||||
log "`date` - Downloading '$project'.\n"
|
||||
git clone https://git.hyperling.com/me/env-termux \
|
||||
--branch=dev ~/termux-deleteme
|
||||
chmod 755 ~/termux-deleteme/*.sh
|
||||
~/termux-deleteme/setup.sh "$@"
|
||||
--branch=$BRANCH "$project"
|
||||
fi
|
||||
chmod 755 "$project"/*.sh
|
||||
"$project"/setup.sh "$@"
|
||||
}
|
||||
alias reload-termux="test-termux "
|
||||
alias termux-test="test-termux "
|
||||
alias termux-reload="reload-termux "
|
||||
alias termux-update="reload-termux "
|
||||
alias update-termux="reload-termux "
|
||||
|
||||
|
||||
# Pulled from /me/env-ansible, need to make a shared library between it and Termux.
|
||||
@@ -317,9 +332,20 @@ alias pull-prod="pull_prod_backups"
|
||||
alias prod-pull="pull_prod_backups"
|
||||
|
||||
|
||||
## Finalize ##
|
||||
|
||||
# Export all functions! #
|
||||
eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
|
||||
|
||||
# Run update checker in background.
|
||||
( if [[ -d "$project" ]]; then
|
||||
git -C "$project" fetch >/dev/null 2>&1 && git -C "$project" status | grep "is behind" \
|
||||
| while read status; do
|
||||
log "\n\n`date` - Updates to env-termux are available via 'reload-termux'."
|
||||
log " '$status'"
|
||||
done
|
||||
fi & )
|
||||
|
||||
# Complete!
|
||||
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
||||
echo "`date` - '$PROG' completed!"
|
||||
|
||||
Reference in New Issue
Block a user