Move bash config to shell subdir

This commit is contained in:
2025-11-13 13:52:25 -05:00
parent 60d5d88e96
commit 7ef57ef155
16 changed files with 9 additions and 9 deletions

View File

@@ -0,0 +1,3 @@
export rc="$HOME/.bashrc"
export rcr="$HOME/.config/bashrc.d"
export PROJECTS_PATH="$HOME/Projects"

View File

@@ -0,0 +1,18 @@
alias fuck='sudo $(history -p \!\!)'
alias cls='clear'
alias ls='/usr/bin/ls -lshF --color --group-directories-first --time-style=long-iso'
alias gmtime='/usr/bin/date -u --iso-8601=seconds'
alias date='/usr/bin/date --iso-8601=seconds'
alias whatismyip='curl https://icanhazip.com/'
alias uuid="python3 -c 'import uuid; print(uuid.uuid4());'"
alias epoch="python3 -c 'import time; print(time.time());'"
alias uptime="command uptime --pretty"
alias doc='cd ~/Documents'
alias dn='cd ~/Downloads'
alias pic='cd ~/Pictures'
alias prun="poetry run"
alias psync="poetry install --sync"
alias code='codium'
alias ssh='ssh -F ~/.ssh/config'
alias whereami='echo $LOCATION'
alias gg='dev'

View File

@@ -0,0 +1,3 @@
if direnv --version &>/dev/null; then
eval "$(direnv hook bash)";
fi

View File

@@ -0,0 +1,12 @@
cardstat() {
local workdir="${GNUPGHOME:-$HOME/.gnupg}"
if ! gpg --card-status &>/dev/null; then
systemctl restart pcscd;
fi
touch "${workdir}/unlock.txt";
gpg --sign "${workdir}/unlock.txt";
rm -f "${workdir}/unlock.txt.gpg";
rm -f "${workdir}/unlock.txt";
gpg --card-status;
}

View File

@@ -0,0 +1,8 @@
function random() {
if [[ $# -eq 0 ]]; then
num=32
else
num=$1
fi
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $num | head -n 1
}

View File

@@ -0,0 +1,11 @@
function set_window_title() {
if [[ "${PWD}" == $PROJECTS_PATH/* ]]; then
echo -ne "\033]0; Project: $(basename ${PWD}) \007"
else
echo -ne "\033]0; $LOCATION \007"
fi
}
starship_precmd_user_func="set_window_title"
eval "$(starship init bash)"

1
shell/scripts.d/10-up.sh Normal file
View File

@@ -0,0 +1 @@
function up() { cd $(eval printf '../'%.0s {1..$1}); }

55
shell/scripts.d/50-dev.sh Normal file
View File

@@ -0,0 +1,55 @@
DEVENV_IMAGE='localhost/toolbox-dev-env:latest'
function dev() {
if [ ${#} -lt 1 ]; then
echo "WARNING: Missing project name";
project=""
else
project="${1}"
fi
if [ -f '/run/.toolboxenv' ]; then
cd "${PROJECTS_PATH}/${project}";
if [ -f "${PWD}/ansible.cfg" ]; then
export ANSIBLE_CONFIG="${PWD}/ansible.cfg";
export ANSIBLE_COLLECTIONS_PATH="${PWD}/.ansible"
fi
if [ -f "${PWD}/pyproject.toml" ]; then
poetry_venv=$(poetry env info --path)
if [ ! -z "${poetry_venv}" ] && [ -f "${poetry_venv}/bin/activate" ]; then
source "${poetry_venv}/bin/activate";
fi
fi
else
if [ ! -d "${PROJECTS_PATH}/${project}" ]; then
echo "ERROR: Project path ${PROJECTS_PATH}/${project} does not exist";
return 1
fi
local slug=$(random 8)
local container_name="toolbox-${project:-generic}-${slug}"
toolbox create --image="${DEVENV_IMAGE}" "${container_name}" &>/dev/null || return 1
local current=$(pwd)
cd "${PROJECTS_PATH}/${project}"
echo ">>> Loading project: ${project}"
echo ">>> ${PWD}"
toolbox enter "${container_name}"
echo ">>> Exited: ${container_name}"
cd "${current}"
podman container stop "${container_name}" &>/dev/null
podman container rm --force "${container_name}" &>/dev/null
fi
}
if [ -f '/run/.toolboxenv' ]; then
if [[ "${PWD}" == $PROJECTS_PATH/* ]]; then
dev $(basename "${PWD}")
fi
fi

View File

@@ -0,0 +1,3 @@
if [ -f ~/.bashrc_local ]; then
source ~/.bashrc_local
fi