From f9b1019f69fe6601517136acfdd13dec25c0ff6a Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sat, 11 Feb 2012 18:24:57 -0600 Subject: [PATCH] Split 20-flag into profile part (exports FLAG if wanted) and rc part (inserts FLAG into PS1 if it exists) to allow the flag to propagate to subshells properly --- bash-config/bash_profile.d/20-flag | 8 ++++---- bash-config/bashrc.d/20-flag | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 bash-config/bashrc.d/20-flag diff --git a/bash-config/bash_profile.d/20-flag b/bash-config/bash_profile.d/20-flag index 4138b68..469aef5 100644 --- a/bash-config/bash_profile.d/20-flag +++ b/bash-config/bash_profile.d/20-flag @@ -1,17 +1,17 @@ -# Add a machine-hostname-based color flag to the prompt +# Add a machine-hostname-based color flag to the environment _i || return # Find the flag binary flag_bin="%%LOCALBASE%%/bin/flag" [ -x "${flag_bin}" ] || flag_bin="$(which flag 2>/dev/null)" -[ -x "${flag_bin}" ] || return +[ -x "${flag_bin}" ] || return # Import flag, if wanted [ -f "${HOME}/.noflag" ] || FLAG="($(${flag_bin} -e))" -# Patch flag into prompt, if not already there -[ "${FLAG}" ] && echo "${PS1}" | grep -q "${FLAG}" || PS1="${FLAG}${PS1}" +# Push FLAG into environment for subshells +[ "${FLAG}" ] && export FLAG # Clean up environment unset flag_bin diff --git a/bash-config/bashrc.d/20-flag b/bash-config/bashrc.d/20-flag new file mode 100644 index 0000000..fc5f520 --- /dev/null +++ b/bash-config/bashrc.d/20-flag @@ -0,0 +1,2 @@ +# Patch flag into prompt, if not already there +[ "${FLAG}" ] && echo "${PS1}" | grep -q "${FLAG}" || PS1="${FLAG}${PS1}" -- 2.42.0