Seperate bashrc into seperate shell scripts

This commit is contained in:
JeremyStar™ 2024-06-03 01:14:49 +02:00
parent daadecd14d
commit 5293300a3d
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
13 changed files with 260 additions and 110 deletions

View file

@ -1,111 +1,2 @@
#!/bin/bash
# shellcheck disable=SC1091
export WINEDEBUG=-all
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
source "/usr/share/icons-in-terminal/icons_bash.sh"
source /usr/share/nvm/init-nvm.sh
export PNPM_HOME="/home/jeremystartm/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
source "${HOME}/.jstmbash/init.source"
eval "$(starship init bash)"
alias "fireplace=$(which fireplace) -f 60 -t 13"
alias "quote=fortune -s linux debian|cowsay"
alias "besseretests=godot --headless -d -v -s --path . addons/besseretests/src/cmd.gd"
alias "besseretests-gui=godot -d -v -s --path . addons/besseretests/src/cmd.gd"
alias "rm=rm -ri"
alias "finfo=sudo cpupower frequency-info"
alias "fset=sudo cpupower frequency-set -g"
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
)
}
export "RUSTFLAGS=-Z threads=$(nproc)"
export "EDITOR=nano"
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" "${HOME}/.mono" "${HOME}/.local/share/NuGet"
}
quote
env "BASHRC=true" dotfiles-updatechecker
source ${HOME}/.bashrc.d/startup.sh

7
bash/bashrc.d/config.sh Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
CONFIG_FLOW_CONTROL=0
CONFIG_AUTOSAVE_HISTORY=1
CONFIG_CUSTOM_PROMPT=1
CONFIG_EDITOR=nano
CONFIG_REPLACE_PKGMGR_ORIGINAL=pacman
CONFIG_REPLACE_PKGMGR_REPLACEMENT=paru

25
bash/bashrc.d/init.d/aliases.sh Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# shellcheck disable=SC2139
# StarOpenSource Development
alias "besseretests=godot --headless -d -v -s --path . addons/besseretests/src/cmd.gd"
alias "besseretests-gui=godot -d -v -s --path . addons/besseretests/src/cmd.gd"
# Safety
alias "rm=rm -ri"
# CPU Governor
alias "finfo=sudo cpupower frequency-info"
alias "fset=sudo cpupower frequency-set -g"
# Fun ;)
alias "fireplace=$(which fireplace) -f 60 -t 13"
alias "quote=fortune -s linux debian|cowsay"
# Replacements
alias "ls=$(which eza) ${ARGS_EZA}"
alias "dir=$(which eza) ${ARGS_EZA}"
alias "eza=$(which eza) ${ARGS_EZA}"
alias "more=$(which moar) ${ARGS_MOAR}"
alias "less=$(which moar) ${ARGS_MOAR}"
alias "moar=$(which moar) ${ARGS_MOAR}"

128
bash/bashrc.d/init.d/functions.sh Executable file
View file

@ -0,0 +1,128 @@
#!/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" "${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
}

View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Arguments for some programs
export "ARGS_EZA=--long --binary --mounts --no-git --color=always --color-scale=size --color-scale-mode=fixed --no-quotes --smart-group --almost-all --sort name"
export "ARGS_MOAR=-colors 16M -statusbar bold --style dracula"
# General
export "PAGER=$(which moar) ${ARGS_MOAR}"
# Wine
export "WINEDEBUG=-all"
# Rust
export "RUSTFLAGS=-Z threads=$(nproc)"
# PNPM
export PNPM_HOME="/home/jeremystartm/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
source "/usr/share/icons-in-terminal/icons_bash.sh"

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
source /usr/share/nvm/init-nvm.sh

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
eval "$(starship init bash)"

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
env "BASHRC=true" dotfiles-updatechecker

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
quote

63
bash/bashrc.d/startup.sh Executable file
View file

@ -0,0 +1,63 @@
#!/usr/bin/env bash
# shellcheck disable=SC2154
cd "${HOME:?}/.bashrc.d" || (
echo ":: Can't cd into ${HOME:?}/.bashrc.d"
exit 1
)
# Create new configuration file
[[ ! -f "config.sh" ]] && cat << EOF >> config.sh
#!/usr/bin/env bash
CONFIG_FLOW_CONTROL=0
CONFIG_AUTOSAVE_HISTORY=1
CONFIG_CUSTOM_PROMPT=1
CONFIG_EDITOR=nano
CONFIG_REPLACE_PKGMGR_ORIGINAL=pacman
CONFIG_REPLACE_PKGMGR_REPLACEMENT=paru
EOF
# Load configuration file
source "config.sh"
# Initialize basic stuff
[[ -f "init.d/variables.sh" ]] && source "init.d/variables.sh"
[[ -f "init.d/aliases.sh" ]] && source "init.d/aliases.sh"
[[ -f "init.d/functions.sh" ]] && source "init.d/functions.sh"
# Process configuration changes
# -> Flow control
[[ "${CONFIG_FLOW_CONTROl}" == "0" ]] && stty -ixon
[[ "${CONFIG_FLOW_CONTROL}" == "1" ]] && stty ixon
# -> Autosave history
[[ "${CONFIG_AUTOSAVE_HISTORY}" == "1" ]] && export "PROMPT_COMMAND=history -a"
# -> Custom prompt
if [[ "${CONFIG_CUSTOM_PROMPT}" == "1" ]]; then
export "PS1=\[\033[38;5;33m\][\[$(tput sgr0)\]\[\033[38;5;38m\]\u\[$(tput sgr0)\]\[\033[38;5;33m\]@\[$(tput sgr0)\]\[\033[38;5;38m\]\H\[$(tput sgr0)\]\[\033[38;5;33m\]:\[$(tput sgr0)\]\[\033[38;5;38m\]\W\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;214m\]\$?\[$(tput sgr0)\]\[\033[38;5;33m\]]\\$\[$(tput sgr0)\] "
export "PS2=\[\033[38;5;196m\][incomplete]: \033[0;10m"
export "PS4=\${0}:\${LINENO}+ "
fi
# -> Editor
export "EDITOR=${CONFIG_EDITOR}"
# -> Package manager replacement
if [ -n "${CONFIG_REPLACE_PKGMGR_ORIGINAL}" ] && [ -n "${CONFIG_REPLACE_PKGMGR_REPLACEMENT}" ]; then
# shellcheck disable=SC2139
alias "${CONFIG_REPLACE_PKGMGR_ORIGINAL}=${CONFIG_REPLACE_PKGMGR_REPLACEMENT}"
fi
# Initialize shell programs
for file in programs.d/*; do
# shellcheck disable=SC1090
source "${file}"
done
# Run startup scripts
for file in startup.d/*; do
# shellcheck disable=SC1090
source "${file}"
done

View file

@ -45,6 +45,7 @@ link "repositories/jstmbash" ".jstmbash"
# bash
link "bash/bashrc" ".bashrc"
link "bash/bashrc.d" ".bashrc.d"
link "bash/bin/launch-menu" ".local/bin/launch-menu"
link "bash/jobrunner/daemon.sh" ".local/bin/jobrunner"
link "bash/jobrunner/runjob.sh" ".local/bin/jobrunner-runjob"