aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2022-03-26 17:30:52 +1300
committerTom Ryder <tom@sanctum.geek.nz>2022-03-26 17:30:52 +1300
commit2ee86a58b3642d6698e2405ae7394a02a72be74e (patch)
tree333fc938f402b8059c0d55d594b92b37509b3feb /bash/bashrc.d
parentInclude prompt prefix when using Torsocks (diff)
downloaddotfiles-2ee86a58b3642d6698e2405ae7394a02a72be74e.tar.gz
dotfiles-2ee86a58b3642d6698e2405ae7394a02a72be74e.zip
Update LD_PRELOAD checks to change dynamically
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/prompt.bash29
1 files changed, 20 insertions, 9 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index a2066386..86691a9c 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -21,21 +21,17 @@ prompt() {
fi
PS1=$PS1'\w'
- # Add sub-commands; VCS, job, and return status checks
- PS1=$PS1'$(ret=$?;prompt vcs;prompt job;prompt ret)'
-
# Add a helpful prefix if this shell appears to be exotic
case ${SHELL##*/} in
(bash) ;;
(*) PS1=bash:$PS1 ;;
esac
- # If torsocks is on, report that
- case $LD_PRELOAD in
- (*/libtorsocks.so:|*/libtorsocks.so)
- PS1='[Tor]'$PS1
- ;;
- esac
+ # Add sub-commands:
+ ## Preload libraries as prefix
+ PS1='$(prompt preload)'$PS1
+ ## VCS, job, and return status checks as suffixes
+ PS1=$PS1'$(ret=$?;prompt vcs;prompt job;prompt ret)'
# Add prefix and suffix
PS1='${PROMPT_PREFIX}'$PS1'${PROMPT_SUFFIX}'
@@ -99,6 +95,21 @@ prompt() {
fi
;;
+ # Analyze LD_PRELOAD to see if we should report anything loaded
+ preload)
+ printf '%s:' "$LD_PRELOAD" |
+ while read -d : -r ; do
+ case $REPLY in
+ (*/libip2unix.so)
+ printf '[IP2Unix]'
+ ;;
+ (*/libtorsocks.so)
+ printf '[Tor]'
+ ;;
+ esac
+ done
+ ;;
+
# Git prompt function
git)