From b0ee16d81f50028d2c79393d322e22a83dcc7051 Mon Sep 17 00:00:00 2001 From: Andrei Jiroh Halili Date: Fri, 6 Jan 2023 01:22:50 +0800 Subject: [PATCH] feat(bashrc): add global bashrc stuff Next, I'll import host-specifics then later this afternoon. Signed-off-by: Andrei Jiroh Halili --- .bash_login | 21 +++++++++++++++++++ .bashrc | 53 +++++++++++++++++++++++++++++++++++++++++++++++ .env | 42 +++++++++++++++++++++++++++++++++++++ .profile | 9 ++++++++ .trunk/.gitignore | 7 +++++++ .trunk/trunk.yaml | 12 +++++++++++ 6 files changed, 144 insertions(+) create mode 100644 .bash_login create mode 100644 .bashrc create mode 100644 .env create mode 100644 .profile create mode 100644 .trunk/.gitignore create mode 100644 .trunk/trunk.yaml diff --git a/.bash_login b/.bash_login new file mode 100644 index 0000000..55b7ef6 --- /dev/null +++ b/.bash_login @@ -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 \ No newline at end of file diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..fc44464 --- /dev/null +++ b/.bashrc @@ -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" diff --git a/.env b/.env new file mode 100644 index 0000000..d4b0d55 --- /dev/null +++ b/.env @@ -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 +########################################################################################## diff --git a/.profile b/.profile new file mode 100644 index 0000000..eb3e878 --- /dev/null +++ b/.profile @@ -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" diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 0000000..cf2f254 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,7 @@ +*out +*logs +*actions +*notifications +plugins +user_trunk.yaml +user.yaml diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 0000000..c85a141 --- /dev/null +++ b/.trunk/trunk.yaml @@ -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 \ No newline at end of file