punktdateien-bashrc/init.d/functions.sh

128 lines
3.8 KiB
Bash
Executable file

#!/usr/bin/env bash
function osu-oszimport() {
if [ ! -f "${HOME}/.cache/osu.AppImage" ]; then
echo "--> Could not find ~/.cache/osu.AppImage"
echo " Please download and start osu! using osu!boot first."
else
for file in *.osz; do
if [ "${file}" == "*.osz" ]; then
echo "--> No .osz file has been found"
else
echo "--> Importing ${file}"
~/.cache/osu.AppImage "${file}"
fi
done
fi
}
function godot-setup() {
(
set -eo pipefail
if [ ! -f "project.godot" ]; then
echo ":: Error: No project.godot file was found."
exit
fi
if [ -n "$HELP" ]; then
echo ":: Available environment variables:"
echo " \$CORE_BRANCH=<develop|stable>"
echo " \$INSTALL_SUI=<false|true>"
echo " \$INSTALL_VENUS=<false|true>"
echo ""
echo ":: Note: The first listed value is the default"
echo " for that specific environment variable."
exit
fi
if [ -z "$CORE_BRANCH" ]; then CORE_BRANCH=develop; fi
if [ -z "$INSTALL_SUI" ]; then INSTALL_SUI=false; fi
if [ -z "$INSTALL_VENUS" ]; then INSTALL_VENUS=false; fi
if [ ! -d ".git" ]; then
echo ":: Initializing git repository"
git init -b develop
fi
echo ":: Creating files"
wget -q --show-progress "https://www.gnu.org/licenses/agpl-3.0.txt" -O LICENSE
cat << EOF >> README.md
# New project
You need to fill this README.md out.
EOF
echo ":: Removing default icon"
rm -rf icon.png
echo ":: Creating directories"
mkdir -p src scenesrc assets/{images,sprites,music,sfx,fonts,themes} dist/submodules addons
echo ":: Installing CORE"
git submodule add https://git.staropensource.de/StarOpenSource/CORE-distrib-git.git dist/submodules/CORE
(
cd dist/submodules/CORE
git checkout "$CORE_BRANCH"
)
ln -s dist/submodules/CORE CORE
if [ "$INSTALL_SUI" == "true" ]; then
echo ":: Installing StarOpenSource UI"
git submodule add https://git.staropensource.de/StarOpenSource/SUI-distrib.git dist/submodules/SUI
ln -s ../dist/submodules/SUI addons/SUI
fi
if [ "$INSTALL_VENUS" == "true" ]; then
echo ":: Installing Venus"
git submodule add https://git.staropensource.de/StarOpenSource/venus.git dist/submodules/Venus
ln -s ../dist/submodules/Venus addons/venus
fi
)
}
function cleanhome() {
echo ":: Cleaning ~"
rm -rf "${HOME}/.dotnet" "${HOME}/.fltk" "${HOME}/.gradle" "${HOME}/.hyprland" \
"${HOME}/.java" "${HOME}/.npm" "${HOME}/.nuget" "${HOME}/.nvm" "${HOME}/.openjfx" \
"${HOME}/.pki" "${HOME}/.vnc" "${HOME}/.yarn" "${HOME}/go" "${HOME}/.lesshst" \
"${HOME}/.wget-hsts" "${HOME}/.yarnrc" "${HOME}/package-lock.json" "${HOME}/package.json" \
"${HOME}/node_modules" "${HOME}/.npmrc" "${HOME}/.gtkrc-2.0" "${HOME}/.electron-gyp" \
"${HOME}/.python_history" "${HOME}/.m2/repositories" "${HOME}/.mono" "${HOME}/.local/share/NuGet"
}
function extract(){
if [ -z "${1}" ]; then
echo ":: Error: No file given."
return 1
fi
if [ -f "${1}" ]; then
case "${1}" in
*.tar|*.tar.xz) tar xf "${1}" ;;
*.tar.bz2) tar xjf "${1}" ;;
*.tar.gz|*.tgz) tar xzf "${1}" ;;
*.tar.zst) unzstd "${1}" ;;
*.tbbz2) tar xjf "${1}" ;;
*.gz) gunzip "${1}" ;;
*.xz) xz -d "${1}" ;;
*.bz2) bunzip2 "${1}" ;;
*.rar) unrar x "${1}" ;;
*.zip|*.jar) unzip "${1}" ;;
*.7z) 7z x "${1}" ;;
*.Z) uncompress "${1}" ;;
*.deb) ar x "${1}" ;;
*)
echo ":: Error: Invalid archive"
return 1
;;
esac
elif [ -d "${1}" ]; then
## is it a bird? is it a dir?
echo ":: Error: Is a directory"
return 1
elif [ -a "${1}" ]; then
## if block device or something
echo ":: Error: jeremystartm's bashrc implementation of the extract command only supports files."
return 1
else
## not found
echo ":: Error: No such file or directory"
return 1
fi
}