Complete reimplementation to support cross platform usage without namespaces
This commit is contained in:
3
scripts.d/00-directories.sh
Normal file
3
scripts.d/00-directories.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
export rc="$HOME/.bashrc"
|
||||
export rcr="$HOME/.config/bashrc.d"
|
||||
export PROJECTS_PATH="$HOME/Projects"
|
||||
17
scripts.d/01-aliases.sh
Normal file
17
scripts.d/01-aliases.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
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'
|
||||
3
scripts.d/02-direnv.sh
Normal file
3
scripts.d/02-direnv.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
if direnv --version &>/dev/null; then
|
||||
eval "$(direnv hook bash)";
|
||||
fi
|
||||
12
scripts.d/10-cardstat.sh
Normal file
12
scripts.d/10-cardstat.sh
Normal 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;
|
||||
}
|
||||
6
scripts.d/10-powerline.sh
Normal file
6
scripts.d/10-powerline.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
if [ -f `which powerline-daemon` ]; then
|
||||
powerline-daemon -q
|
||||
POWERLINE_BASH_CONTINUATION=1
|
||||
POWERLINE_BASH_SELECT=1
|
||||
. /usr/share/powerline/bash/powerline.sh
|
||||
fi
|
||||
8
scripts.d/10-random.sh
Normal file
8
scripts.d/10-random.sh
Normal 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
|
||||
}
|
||||
1
scripts.d/10-up.sh
Normal file
1
scripts.d/10-up.sh
Normal file
@@ -0,0 +1 @@
|
||||
function up() { cd $(eval printf '../'%.0s {1..$1}); }
|
||||
54
scripts.d/50-dev.sh
Normal file
54
scripts.d/50-dev.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
DEVENV_IMAGE='localhost/toolbox-dev-env:latest'
|
||||
|
||||
function dev() {
|
||||
if [ ${#} -lt 1 ]; then
|
||||
echo "WARNING: Missing project name";
|
||||
project=""
|
||||
else
|
||||
project="${2}"
|
||||
fi
|
||||
|
||||
if [ -f '/run/.toolboxenv' ]; then
|
||||
cd "${PROJECTS_DIR}/${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}" ]; 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: ${namespace}"
|
||||
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
|
||||
Reference in New Issue
Block a user