diff options
-rw-r--r-- | bash/bashrc.d/prompt.bash | 29 | ||||
-rw-r--r-- | ksh/kshrc.d/prompt.ksh | 30 | ||||
-rw-r--r-- | zsh/zshrc.d/prompt.zsh | 30 |
3 files changed, 60 insertions, 29 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) diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh index f319fdd8..efc5c4e3 100644 --- a/ksh/kshrc.d/prompt.ksh +++ b/ksh/kshrc.d/prompt.ksh @@ -18,10 +18,6 @@ function prompt { PS1=$PS1'${HOSTNAME%%.*}:' fi - # Add sub-commands; working directory with ~ abbreviation, VCS, job - # count, and previous command return value - PS1=$PS1'$(ret=$?;jobc=$(jobs -p|sed -n '\''$='\'');prompt pwd;prompt vcs;prompt job;prompt ret;:)' - # Add a helpful prefix if this shell appears to be exotic typeset ksh case $KSH_VERSION in @@ -34,12 +30,11 @@ function prompt { (*) PS1=$ksh:$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=$?;jobc=$(jobs -p|sed -n '\''$='\'');prompt pwd;prompt vcs;prompt job;prompt ret;:)' # Add prefix and suffix PS1='${PROMPT_PREFIX}'$PS1'${PROMPT_SUFFIX}' @@ -213,6 +208,21 @@ function 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 + ;; + # Abbreviated working directory pwd) case $PWD in 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 |