From e08678ffea4ce787d727de56072bbb2227da47d7 Mon Sep 17 00:00:00 2001 From: John Mertz Date: Mon, 12 Dec 2022 14:29:13 -0500 Subject: [PATCH] Prepare to split out Distrobox and Host configs --- bash/bash_aliases | 7 +++++-- bash/bash_aliases.distrobox | 2 ++ bash/bash_aliases.host | 2 ++ bash/bash_login | 8 +++----- bash/bash_login.distrobox | 0 bash/bash_login.host | 0 bash/bash_logout | 6 ++++++ bash/bash_logout.distrobox | 0 bash/bash_logout.host | 0 bash/bash_profile | 6 ++++++ bash/bash_profile.distrobox | 0 bash/bash_profile.host | 0 bash/bashrc | 8 +++----- bash/bashrc.distrobox | 0 bash/bashrc.host | 0 bash/path | 6 ++++++ bash/path.distrobox | 0 bash/path.host | 0 18 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 bash/bash_aliases.distrobox create mode 100644 bash/bash_aliases.host create mode 100644 bash/bash_login.distrobox create mode 100644 bash/bash_login.host create mode 100644 bash/bash_logout.distrobox create mode 100644 bash/bash_logout.host create mode 100644 bash/bash_profile.distrobox create mode 100644 bash/bash_profile.host create mode 100644 bash/bashrc.distrobox create mode 100644 bash/bashrc.host create mode 100644 bash/path.distrobox create mode 100644 bash/path.host diff --git a/bash/bash_aliases b/bash/bash_aliases index d3adfeffc..2ea3b529c 100644 --- a/bash/bash_aliases +++ b/bash/bash_aliases @@ -51,5 +51,8 @@ alias mpv="flatpak run io.mpv.Mpv" # Detect if I'm in a toolbox alias istoolbox='[ -f "/run/.toolboxenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv' -# Script to restore toolbox after it was replaced with distrobox and removed the default 'toolbox' name -alias toolbox="$HOME/scripts/toolbox.sh" +if [ $(istoolbox) ]; then + source $HOME/.dotfiles/bash/bash_aliases.distrobox +else + source $HOME/.dotfiles/bash/bash_aliases.host +fi diff --git a/bash/bash_aliases.distrobox b/bash/bash_aliases.distrobox new file mode 100644 index 000000000..22ecae3b0 --- /dev/null +++ b/bash/bash_aliases.distrobox @@ -0,0 +1,2 @@ +# Already in a toolbox +alias toolbox="echo You are already in a toolbox" diff --git a/bash/bash_aliases.host b/bash/bash_aliases.host new file mode 100644 index 000000000..c7ce7140c --- /dev/null +++ b/bash/bash_aliases.host @@ -0,0 +1,2 @@ +# Script to restore toolbox after it was replaced with distrobox and removed the default 'toolbox' name +alias toolbox="$HOME/scripts/toolbox.sh" diff --git a/bash/bash_login b/bash/bash_login index af3d0412c..b1856637e 100644 --- a/bash/bash_login +++ b/bash/bash_login @@ -42,10 +42,8 @@ if [ ! -e ${HOME}/.spool/last_login_gui ]; then echo "Use 'startsway' or 'starti3' to launch a GUI" fi -# Distrobox only -if [ -f "/run/.containerenv" ]; then - : -# Host only +if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then + source $HOME/.dotfiles/bash/bash_login.distrobox else - : + source $HOME/.dotfiles/bash/bash_login.host fi diff --git a/bash/bash_login.distrobox b/bash/bash_login.distrobox new file mode 100644 index 000000000..e69de29bb diff --git a/bash/bash_login.host b/bash/bash_login.host new file mode 100644 index 000000000..e69de29bb diff --git a/bash/bash_logout b/bash/bash_logout index ee06f98d6..6b42c20bf 100644 --- a/bash/bash_logout +++ b/bash/bash_logout @@ -11,3 +11,9 @@ fi if [ "$SHLVL" = 1 ]; then [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q fi + +if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then + source $HOME/.dotfiles/bash/bash_logout.distrobox +else + source $HOME/.dotfiles/bash/bash_logout.host +fi diff --git a/bash/bash_logout.distrobox b/bash/bash_logout.distrobox new file mode 100644 index 000000000..e69de29bb diff --git a/bash/bash_logout.host b/bash/bash_logout.host new file mode 100644 index 000000000..e69de29bb diff --git a/bash/bash_profile b/bash/bash_profile index b398c9c68..0a196003f 100644 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -15,3 +15,9 @@ PERL5LIB="${HOME}/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; PERL_LOCAL_LIB_ROOT="${HOME}/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; PERL_MB_OPT="--install_base \"${HOME}/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=${HOME}/perl5"; export PERL_MM_OPT; + +if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then + source $HOME/.dotfiles/bash/bash_profile.distrobox +else + source $HOME/.dotfiles/bash/bash_profile.host +fi diff --git a/bash/bash_profile.distrobox b/bash/bash_profile.distrobox new file mode 100644 index 000000000..e69de29bb diff --git a/bash/bash_profile.host b/bash/bash_profile.host new file mode 100644 index 000000000..e69de29bb diff --git a/bash/bashrc b/bash/bashrc index 63ebd9a92..bb2b9b473 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -104,10 +104,8 @@ if [ -z $SSH_AGENT_PID ]; then fi fi -# Distrobox only -if [ -f "/run/.containerenv" ]; then - : -# Host only +if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then + source $HOME/.dotfiles/bash/bashrc.distrobox else - : + source $HOME/.dotfiles/bash/bashrc.host fi diff --git a/bash/bashrc.distrobox b/bash/bashrc.distrobox new file mode 100644 index 000000000..e69de29bb diff --git a/bash/bashrc.host b/bash/bashrc.host new file mode 100644 index 000000000..e69de29bb diff --git a/bash/path b/bash/path index 3fa1eb232..ec7e8900e 100644 --- a/bash/path +++ b/bash/path @@ -30,5 +30,11 @@ fi # Perl PATH="${HOME}/perl5/bin:$PATH" +if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then + source $HOME/.dotfiles/bash/path.distrobox +else + source $HOME/.dotfiles/bash/path.host +fi + # Export PATH export PATH="$PATH" diff --git a/bash/path.distrobox b/bash/path.distrobox new file mode 100644 index 000000000..e69de29bb diff --git a/bash/path.host b/bash/path.host new file mode 100644 index 000000000..e69de29bb