Change bye to be a function. Add spaces to the end of some aliases. Fix indentation to consistently be tabs.

This commit is contained in:
2026-03-27 17:13:14 -07:00
parent abc56b57cd
commit ab396a9739

180
bashrc.sh
View File

@@ -21,11 +21,11 @@ alias shell-reload="reload-bash"
alias reload-shell="reload-bash" alias reload-shell="reload-bash"
alias reload="reload-bash" alias reload="reload-bash"
alias l='ls' alias l='ls '
alias ll='ls -alh' alias ll='ls -alh '
alias lh='ls -ash' alias lh='ls -ash '
alias clone="rsync -auPhz --delete --exclude '.gradle' --exclude 'app/build'" alias clone="rsync -auPhz --delete --exclude '.gradle' --exclude 'app/build' "
# Easily get to storage devices. # Easily get to storage devices.
curr="`pwd`" curr="`pwd`"
@@ -60,16 +60,16 @@ alias clean-trashed='find "$SS" -name ".trashed*" -exec du -h {} \; -delete | so
alias check-trashed='find "$SS" -name ".trashed*" -exec du -h {} \; -exec mv -v {} ~/TRASH/ \; | sort -h' alias check-trashed='find "$SS" -name ".trashed*" -exec du -h {} \; -exec mv -v {} ~/TRASH/ \; | sort -h'
# Help prevent mistakes. # Help prevent mistakes.
alias cp="cp -v" alias cp="cp -v "
alias mv="mv -v" alias mv="mv -v "
alias rm="echo 'Move to ~/storage/shared/TRASH/ instead!'" alias rm="echo 'Move to ~/storage/shared/TRASH/ instead!'"
# Quickies # Quickies
alias bye="exit" function bye { exit; }
alias install="pkg install" alias install="pkg install "
alias uninstall="pkg uninstall" alias uninstall="pkg uninstall "
alias remove="uninstall" alias remove="uninstall "
alias scan="nmap -A -p- --script=vuln" alias scan="nmap -A -p- --script=vuln "
### Functions ### ### Functions ###
@@ -77,35 +77,35 @@ alias scan="nmap -A -p- --script=vuln"
## Code Related ## ## Code Related ##
function code-projects { function code-projects {
cat <<- EOF cat <<- EOF
env-termux dev env-termux dev
env-ansible dev env-ansible dev
env-docker dev env-docker dev
nodejs-website dev nodejs-website dev
hugo-jackanope main hugo-jackanope main
EOF EOF
} }
function code-reseed { function code-reseed {
cd ~/Code cd ~/Code
code-projects | while read project branch; do code-projects | while read project branch; do
git clone ssh://git@$GIT_SERVER:$GIT_PORT/$GIT_USER/$project --branch $branch --recurse-submodules git clone ssh://git@$GIT_SERVER:$GIT_PORT/$GIT_USER/$project --branch $branch --recurse-submodules
done done
} }
alias reseed-code="code-reseed" alias reseed-code="code-reseed"
function check-code { function check-code {
cd ~/Code cd ~/Code
ls | while read project; do ls | while read project; do
echo -e "\nChecking $project..." echo -e "\nChecking $project..."
cd $project cd $project
if [[ -d .git ]]; then if [[ -d .git ]]; then
git pull git pull
git push git push
else else
echo "* Not a valid git project, skipping." echo "* Not a valid git project, skipping."
fi fi
cd .. cd ..
done done
} }
alias code-check="check-code" alias code-check="check-code"
@@ -117,9 +117,9 @@ function commit {
echo 'USAGE: commit "My commit message."' >&2 echo 'USAGE: commit "My commit message."' >&2
return 1 return 1
fi fi
if [[ "$1" == "-m" ]]; then if [[ "$1" == "-m" ]]; then
message="$2" message="$2"
fi fi
git add . && git commit -m "$message" && git push git add . && git commit -m "$message" && git push
} }
@@ -140,56 +140,56 @@ alias termux-reload="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.
# Change a branch to point at another. # Change a branch to point at another.
function load-branch { function load-branch {
rcvr="$1" # branch which we want to modify rcvr="$1" # branch which we want to modify
base="$2" # branch with the changes we want base="$2" # branch with the changes we want
if [[ "$rcvr" == "main" ]]; then if [[ "$rcvr" == "main" ]]; then
echo "*** ERROR: Are you nuts, fool!? Not main! Do it manually! ***" echo "*** ERROR: Are you nuts, fool!? Not main! Do it manually! ***"
return 1 return 1
fi fi
if [[ -z "$base" ]]; then if [[ -z "$base" ]]; then
if [[ "$rcvr" == "prod" ]]; then if [[ "$rcvr" == "prod" ]]; then
base="stage" base="stage"
elif [[ "$rcvr" == "stage" ]]; then elif [[ "$rcvr" == "stage" ]]; then
base="dev" base="dev"
else else
echo "* Unsure which branch to use for '$rcvr'. Please specify." echo "* Unsure which branch to use for '$rcvr'. Please specify."
return 1 return 1
fi fi
echo "* Base was not specified, using '$base' for '$rcvr'." echo "* Base was not specified, using '$base' for '$rcvr'."
else else
echo "* Requested pointing '$rcvr' branch to '$base'." echo "* Requested pointing '$rcvr' branch to '$base'."
fi fi
echo -e "\n* Ensuring we are on base branch '$base'." && echo -e "\n* Ensuring we are on base branch '$base'." &&
git switch "$base" && git switch "$base" &&
echo -e "\n* Changing pointer for '$rcvr' to '$base'." && echo -e "\n* Changing pointer for '$rcvr' to '$base'." &&
git branch -f "$rcvr" "$base" && git branch -f "$rcvr" "$base" &&
#echo -e "\n* Switching to branch '$rcvr'." && #echo -e "\n* Switching to branch '$rcvr'." &&
#git switch "$rcvr" && #git switch "$rcvr" &&
echo -e "\n* Forcing push on branch '$rcvr'." && echo -e "\n* Forcing push on branch '$rcvr'." &&
git push --force --set-upstream origin "$rcvr" && git push --force --set-upstream origin "$rcvr" &&
echo -e "\n* Done! Displaying list of remote branches." && echo -e "\n* Done! Displaying list of remote branches." &&
git ls-remote --heads | sort git ls-remote --heads | sort
if [[ "$base" != "dev" ]]; then if [[ "$base" != "dev" ]]; then
echo -e "\n* Checking if a dev branch exists." echo -e "\n* Checking if a dev branch exists."
git ls-remote --exit-code --heads origin dev git ls-remote --exit-code --heads origin dev
dev_exists="$?" dev_exists="$?"
if [[ "$dev_exists" == 0 ]]; then if [[ "$dev_exists" == 0 ]]; then
echo -e "\n* Switching back to dev." echo -e "\n* Switching back to dev."
git switch dev git switch dev
elif [[ "$dev_exists" == 2 ]]; then elif [[ "$dev_exists" == 2 ]]; then
echo -e "\n* Switching back to main." echo -e "\n* Switching back to main."
git switch main git switch main
else else
echo "*** ERROR: Unknown status for dev_exists, '$dev_exists'. ***" echo "*** ERROR: Unknown status for dev_exists, '$dev_exists'. ***"
fi fi
fi fi
echo -e "\n* Verifying which branch we're on." echo -e "\n* Verifying which branch we're on."
git branch git branch
} }
alias load-prod="load-branch prod" alias load-prod="load-branch prod"
alias load-stage="load-branch stage" alias load-stage="load-branch stage"
@@ -465,15 +465,15 @@ alias pull-icon="pull-meme"
function init-video-contents { function init-video-contents {
if [[ -n "$1" ]]; then if [[ -n "$1" ]]; then
mkdir "$1" mkdir "$1"
cd "$1" cd "$1"
fi fi
touch README.md touch README.md
#touch title.md #touch title.md
#touch desc.md #touch desc.md
#touch tags.md #touch tags.md
mkdir -pv raw mkdir -pv raw
} }
alias init-video="init-video-contents" alias init-video="init-video-contents"
alias init-vid="init-video" alias init-vid="init-video"