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

35
shell/bashrc.sh Normal file
View File

@@ -0,0 +1,35 @@
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -f '/run/.toolboxenv' ]; then
export LOCATION="Toolbox: $(cat /run/.containerenv | grep name | cut -d '=' -f 2 | tr -d '"')"
else
export LOCATION="Host: $(hostname)"
fi
export HISTFILE="$HOME/.bash_history"
export PYTHON_HISTORY="$HOME/.python_history"
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# Basically this is here to support the nonsense I'm doing with toolbox alt-home
# locations. This determines the current path of the current script so that we
# don't need to hardcode paths
currdir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
for b in ${currdir}/.config/bashrc.d/*.sh; do source $b; done
for c in ${currdir}/.config/completions.d/*.completion; do source $c; done
unset currdir

View File

@@ -0,0 +1,6 @@
function _dev_completion() {
local cur=${COMP_WORDS[COMP_CWORD]};
COMPREPLY=( $(compgen -W "$(command ls $PROJECTS_PATH)" -- $cur) );
}
complete -F _dev_completion dev
complete -F _dev_completion gg

1
shell/inputrc Normal file
View File

@@ -0,0 +1 @@
set completion-ignore-case On

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

View File

@@ -0,0 +1 @@
#01568e

View File

@@ -0,0 +1 @@
#893937

49
shell/starship.toml Normal file
View File

@@ -0,0 +1,49 @@
add_newline = false
format = '[ ](bold fg:#000000 bg:#XXXXXX)${custom.toolbox}${custom.localhost}[](bold fg:#XXXXXX bg:#444444)$directory$python$git_branch$git_status$status$character'
[directory]
format = "[$read_only]($read_only_style)[$path ]($style)[](fg:#444444 bg:#000000)"
style = "fg:bright-white bg:#444444"
read_only = ' '
read_only_style = "bold fg:red bg:#444444"
truncation_symbol = ' '
home_symbol = '~'
[directory.substitutions]
'/' = '  '
'~ ' = ''
[character]
success_symbol = '[](bold fg:#000000)'
error_symbol = '[](bold fg:#6d0505)'
[status]
disabled = false
symbol = ''
pipestatus = true
style = "bold fg:bright-white bg:#6d0505"
format = '[](bold fg:#000000 bg:#6d0505)[ $status ]($style)'
[git_branch]
symbol = ''
format = '[](bold fg:#000000 bg:#44b240)[$symbol $branch]($style)[](bold bg:#000000 fg:#44b240)'
style = 'bold bg:#44b240 fg:black'
[git_status]
style = "bold fg:black bg:#f4862c"
format = '([](bold fg:#000000 bg:#f4862c)[$all_status$ahead_behind]($style)[](bold bg:#000000 fg:#f4862c))'
[python]
style = 'bold bg:#fcf52a fg:black'
symbol = ''
format = '([](bold fg:#000000 bg:#fcf52a)[$virtualenv]($style)[](bold bg:#000000 fg:#fcf52a))'
[custom.toolbox]
style = "bold bg:#XXXXXX fg:bright-white"
command = "echo -ne ' toolbox'"
when = '[ -f /run/.toolboxenv ]'
[custom.localhost]
style = "bold bg:#XXXXXX fg:bright-white"
command = 'echo -ne " $HOSTNAME"'
when = '[ ! -f /run/.toolboxenv ]'