feat(bashrc): add global bashrc stuff

Next, I'll import host-specifics then later this afternoon.

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@gmail.com>
This commit is contained in:
Andrei Jiroh Halili 2023-01-06 01:22:50 +08:00
parent ec76f58b37
commit b0ee16d81f
No known key found for this signature in database
GPG key ID: 67BFC91B3DA12BE8
6 changed files with 144 additions and 0 deletions

21
.bash_login Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
export HOST_SPECIFIC_BASHRC_PATH="$HOME/.config/$HOSTNAME.bashrc"
# Stage 0: Source dotenv stuff from homedir
source "$HOME/.env"
if [[ -f "$HOME/.env.local" ]]; then
source "$HOME/.env.local"
export LOCAL_DOTENV_LOADED=true
fi
# Stage 1: Load global bashrc
if [[ -f "$HOME/.bashrc" ]]; then
source "$HOME/.bashrc"
fi
# Stage 2: Machine specifcs
if [[ -f $HOST_SPECIFIC_BASHRC ]]; then
source "$HOST_SPECIFIC_BASHRC_PATH"
export HOST_SPECIFIC_BASHRC_LOADED=true
fi

53
.bashrc Normal file
View file

@ -0,0 +1,53 @@
#!/usr/bin/env bash
# This is my meta bashrc file, with oh-my-posh instead of zsh-specific
# oh-my-zsh, although I still use zsh as my default shell. Sorry for a
# lot of personal commentary and links hellscape here, it's there for
# in-code docs and for future me to not dig through 'git log' hell.
# SPDX-License-Identifier: TBD
## Stage 0: Init keychain + GPG_TTY for pinentry hellscapes in TUI. ##
## This stage also initalizes oh-my-posh here. ##
if [[ $TERMUX ]]; then
export SSH_AGENT_=todo
else
eval $(keychain --agents gpg,ssh --eval)
fi
export GPG_TTY=$(tty)
# Tip: I don't want to f**k things up on POSIX-based stuff, I might try
# using
if command -v oh-my-posh >>/dev/null; then
eval "$(oh-my-posh init bash)"
fi
## Stage 1: Init custom vars and shortcuts before anything else ##
# Dotfiles stuff, maybe should be on ~/.env?
export DOTFILES_HOME="$HOME/.dotfiles"
export DOTFILES_BIN="$DOTFILES_HOME/bin"
# gopath should be on ~/.local/share/go to not fuck up with local install
# at ~/go if exists
export GOPATH="$HOME/.local/share/go"
# Shut up, VS Code (not the OSS distributions off github:microsoft/vscode).
# Don't let me pay for JetBrains IDEs or go nuts with nvim (or emacs, since
# I'm both a bit neutral and off the rails at Vim vs Emacs debate). Also RIP
# to my first editor after Notepad that started my web dev + Linux journey,
# Atom (https://github.com/atom).
export EDITOR=nano
# For compartibility reasons and not to fuck things up on ~/go/bin.
# Custom path might be also on ~/.env too?
export PATH="$DOTFILES_BIN:$HOME/go/bin:$HOME/.local/bin:$GOPATH/bin:$PATH"
# It would be nice if I would work on self-hosted reimplementation of
# proxy.golang.org, but in meanwhile, you need to fuck off Google on this.
# (Fucking Facebook and Microsoft off your lives are also hard too ICYMI.)
# Context: https://git.sr.ht/~sircmpwn/dotfiles/tree/master/item/.profile#L13-15
# and https://drewdevault.com/2021/08/06/goproxy-breaks-go.html
export GOPROXY=direct GOSUMDB=off
## Stage 2: Source literally everything else ##
if [[ -d "$HOME/.bashbox" ]]; then
source "$HOME/.bashbox/env"
fi
export HOMEBREW_HOME=${HOMEBREW_HOME:-"/home/linuxbrew/.linuxbrew"}
test -d "$HOMEBREW_HOME" && eval "$($HOMEBREW_HOME/bin/brew shellenv)"
[[ -r "$HOMEBREW_HOME/etc/profile.d/bash_completion.sh" ]] && . "$HOMEBREW_HOME/etc/profile.d/bash_completion.sh"

42
.env Normal file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env sh
# SPDX-License-Identifier: MIT AND MPL-2.0
#
# This is POSIX sh-compartible shell script to sourced for both shortcuts
# to daily commands I use and then some.
#
# PLEASE DO NOT LEAK ANY SECRETS, INCLUDING DOPPLER CLI TOKENS AND TAILSCALE_AUTHKEYS
# IN THIS BLOODY FILE!
#
# https://packaging.ubuntu.com/html/getting-set-up.html#configure-your-shell
export DEBFULLNAME="Andrei Jiroh Halili"
# Temporary Gmail address for devel stuff, even through my longer email one is, well,
# on my public GPG key btw, so YOLO it.
export DEBEMAIL="ajhalili2006@gmail.com"
##########################################################################################
# Code snippets from https://git.sr.ht/~sircmpwn/dotfiles/tree/db5945a4/item/.env
##########################################################################################
if ls --version 2>&1 | grep -i gnu >/dev/null
then
alias ls='ls --color=auto '
elif ls --version 2>&1 | grep -i busybox >/dev/null
then
alias ls='ls --color=auto '
fi
alias recent='ls -ltch'
# Add optmizations for multicore builds
if [ $(uname) = "Linux" ]
then
nproc=$(grep '^processor' /proc/cpuinfo | wc -l)
if [ $nproc -gt 4 ]
then
# Reserve two cores
nproc=$((nproc - 2))
fi
export MAKEFLAGS="-j$nproc"
export SAMUFLAGS="-j$nproc"
fi
##########################################################################################

9
.profile Normal file
View file

@ -0,0 +1,9 @@
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
source "$HOME/.env"

7
.trunk/.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
*out
*logs
*actions
*notifications
plugins
user_trunk.yaml
user.yaml

12
.trunk/trunk.yaml Normal file
View file

@ -0,0 +1,12 @@
version: 0.1
cli:
version: 1.3.1
plugins:
sources:
- id: trunk
ref: v0.0.8
uri: https://github.com/trunk-io/plugins
lint:
enabled:
- shfmt@3.5.0
- shellcheck@0.7.2