summaryrefslogtreecommitdiff
path: root/config/files/.bashrc
diff options
context:
space:
mode:
Diffstat (limited to 'config/files/.bashrc')
-rw-r--r--config/files/.bashrc69
1 files changed, 69 insertions, 0 deletions
diff --git a/config/files/.bashrc b/config/files/.bashrc
new file mode 100644
index 0000000..81afcb8
--- /dev/null
+++ b/config/files/.bashrc
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+export ASDF_DATA_DIR="/opt/asdf"
+export PATH="${ASDF_DATA_DIR}/shims:${ASDF_DATA_DIR}/bin:/opt/gitlab/.local/bin:${PATH}"
+export HOME="/opt/gitlab"
+
+alias nuget='mono /usr/local/bin/nuget.exe'
+set -o vi
+
+
+function inflate() {
+ local file=$1
+ local to_dir=$2
+ if [ -f "$file" ]; then
+ tar --use-compress-program zstd -xf "$file" -C "$to_dir"
+ rm "$file"
+ fi
+}
+
+update_java_home() {
+ local java_path
+ java_path="$(asdf which java)"
+ if [[ -n "${java_path}" ]]; then
+ export JAVA_HOME
+ JAVA_HOME="$(dirname "$(dirname "$(realpath "${java_path}")")")"
+ fi
+}
+
+function switch_to_exact() {
+ local tool=$1
+ local version=$2
+
+ asdf shell "$tool" "$version"
+ if [[ "$tool" = "java" ]]; then
+ update_java_home
+ fi
+}
+
+function switch_to() {
+ local tool=$1
+ local major_version=$2
+ local version
+ version="$(grep "$tool" "/opt/gitlab/.tool-versions"| tr ' ' '\n' | grep "^$major_version")"
+
+ switch_to_exact "$tool" "$version"
+}
+
+function major_version_from() {
+ echo "$1" | cut -d'.' -f1
+}
+
+function enable_dev_mode() {
+ unset HISTFILESIZE
+ unset HISTSIZE
+ export EDITOR=vim
+ export LOG_LEVEL=debug
+ set -o vi
+ apt-get update -y
+ apt-get install -y --no-install-recommends vim less shellcheck
+}
+
+inflate /opt/asdf.tar.zst /opt
+inflate /usr/lib/gcc.tar.zst /usr/lib
+inflate /usr/lib/rustlib.tar.zst /usr/lib
+
+# shellcheck source=/dev/null
+. "$ASDF_DATA_DIR/asdf.sh"
+# shellcheck source=/dev/null
+. "$ASDF_DATA_DIR/completions/asdf.bash"