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:
36
bashrc.sh
36
bashrc.sh
@@ -22,6 +22,11 @@ else
|
|||||||
export PS1='\[$BOLD\]\[$GRAY\][\[$ORANGE\]\t \[$GREEN\]\w\[$GRAY\]]\[$RESET\]\$ '
|
export PS1='\[$BOLD\]\[$GRAY\][\[$ORANGE\]\t \[$GREEN\]\w\[$GRAY\]]\[$RESET\]\$ '
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$BRANCH" ]]; then
|
||||||
|
export BRANCH="dev"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
## Aliases ##
|
## Aliases ##
|
||||||
|
|
||||||
# Quickly log onto production server.
|
# Quickly log onto production server.
|
||||||
@@ -118,16 +123,26 @@ function commit {
|
|||||||
|
|
||||||
# Easily test this project after committing changes.
|
# Easily test this project after committing changes.
|
||||||
# Otherwise can just source this file unless testing setup.sh.
|
# Otherwise can just source this file unless testing setup.sh.
|
||||||
|
project="$HOME/.git-env-termux"
|
||||||
function test-termux {
|
function test-termux {
|
||||||
sh -c "rm -rf ~/termux-deleteme ~/TRASH/termux-deleteme" 2>/dev/null
|
if [[ -d "$project" ]]; then
|
||||||
git clone https://git.hyperling.com/me/env-termux \
|
log "`date` - Updating '$project'.\n"
|
||||||
--branch=dev ~/termux-deleteme
|
git -C "$project" switch "$branch"
|
||||||
chmod 755 ~/termux-deleteme/*.sh
|
git -C "$project" pull --recurse-submodules || \
|
||||||
~/termux-deleteme/setup.sh "$@"
|
( echo "Failed to pull project, exiting." && return 1 )
|
||||||
|
else
|
||||||
|
log "`date` - Downloading '$project'.\n"
|
||||||
|
git clone https://git.hyperling.com/me/env-termux \
|
||||||
|
--branch=$BRANCH "$project"
|
||||||
|
fi
|
||||||
|
chmod 755 "$project"/*.sh
|
||||||
|
"$project"/setup.sh "$@"
|
||||||
}
|
}
|
||||||
alias reload-termux="test-termux "
|
alias reload-termux="test-termux "
|
||||||
alias termux-test="test-termux "
|
alias termux-test="test-termux "
|
||||||
alias termux-reload="reload-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.
|
# 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"
|
alias prod-pull="pull_prod_backups"
|
||||||
|
|
||||||
|
|
||||||
|
## Finalize ##
|
||||||
|
|
||||||
# Export all functions! #
|
# Export all functions! #
|
||||||
eval "$(declare -F | grep -v _ | sed 's/-f /-fx /')"
|
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!
|
# Complete!
|
||||||
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
||||||
echo "`date` - '$PROG' completed!"
|
echo "`date` - '$PROG' completed!"
|
||||||
|
|||||||
Reference in New Issue
Block a user