organzie .profile and .bashrc

This commit is contained in:
Ryan Cavicchioni 2025-05-14 15:43:56 -05:00
parent 7bd940d717
commit 007db7e0ce
Signed by: ryanc
SSH Key Fingerprint: SHA256:KbXiwUnZnHFwFtt3Bytd+F3FN9pPHn1Z1cxMIE1TPbg
2 changed files with 83 additions and 1 deletions

81
.bashrc Normal file
View File

@ -0,0 +1,81 @@
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
function log() {
if [[ -v "$VERBOSE" ]]; then
echo "$1"
fi
}
function success() {
log "${1}"
}
function warn() {
log "⚠️ ${1}"
}
# Run systemd generators
if [[ -f /usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator ]]; then
set -o allexport
# shellcheck disable=1090
source <(/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)
set +o allexport
fi
# User specific environment
if ! [[ "$PATH" =~ $HOME/.local/bin:$HOME/bin: ]]; then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
# shellcheck disable=1090
. "$rc"
fi
done
fi
unset rc
# Environment variables
# history control
HISTSIZE=10000
HISTFILESIZE=$HISTSIZE
HISTCONTROL=ignorespace:ignoredups
shopt -s histappend
if command -v nvim > /dev/null; then
success "setting EDITOR to nvim"
export EDITOR=nvim
success "setting MANPAGER viewer to nvim"
export MANPAGER="nvim +Man!"
else
warn "nvim not found"
fi
# Tools
# fzf
if command -v fzf > /dev/null; then
eval "$(fzf "--$(basename "$SHELL")")"
success "set up fzf"
else
warn "fzf not found"
fi
# starship
if command -v starship > /dev/null; then
eval "$(starship init "$(basename "$SHELL")")"
success "set up starship"
else
warn "starship not found"
fi
# Aliases
alias nview="nvim -R"

View File

@ -2,6 +2,7 @@
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
# shellcheck disable=SC1090
. "$HOME/.bashrc"
fi
fi