aboutsummaryrefslogtreecommitdiff
path: root/zsh
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 /zsh
parentInclude prompt prefix when using Torsocks (diff)
downloaddotfiles-2ee86a58b3642d6698e2405ae7394a02a72be74e.tar.gz
dotfiles-2ee86a58b3642d6698e2405ae7394a02a72be74e.zip
Update LD_PRELOAD checks to change dynamically
Diffstat (limited to 'zsh')
-rw-r--r--zsh/zshrc.d/prompt.zsh30
1 files changed, 20 insertions, 10 deletions
diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh
index 8fe9ffc7..317aba56 100644
--- a/zsh/zshrc.d/prompt.zsh
+++ b/zsh/zshrc.d/prompt.zsh
@@ -15,21 +15,17 @@ prompt() {
fi
PS1=$PS1'%~'
- # 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
(zsh) ;;
(*) PS1=zsh:$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}'
@@ -60,7 +56,21 @@ prompt() {
fi
;;
- # Git prompt function
+ # 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)
# Wrap as compound command; we don't want to see output from any of