From 9c4a95038521b1ac940c6fbc51bbf72f8793e09d Mon Sep 17 00:00:00 2001 From: Salt Date: Tue, 27 Nov 2018 23:24:17 -0600 Subject: [PATCH] .profile: Small improvements I think Not really, actually --- .profile | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.profile b/.profile index 1430417a..df8bfd90 100755 --- a/.profile +++ b/.profile @@ -39,6 +39,9 @@ # shellcheck disable=1117 # Environment variables +# First, what shell are we? +_baseshell="$(basename "$0")" + # Use Vim if we have it export EDITOR="vi" command -v vim > /dev/null 2>&1 && export EDITOR="vim" @@ -65,7 +68,7 @@ PATH="$desiredpath:$PATH" # Grab pip completion, if it exists if command -v pip > /dev/null 2>&1; then - case "$(basename "$SHELL")" in + case "$_baseshell" in *bash) if ! [ -f "$HOME/.pip-completion-bash" ]; then pip completion --bash > "$HOME/.pip-completion-bash" @@ -171,10 +174,10 @@ _ps1() { *bash) prefix="${prefix}${fg_yellow}" ;; - ksh) + /bin/ksh) prefix="${prefix}${fg_green}" ;; - sh) + /bin/sh) prefix="${prefix}${fg_grey}" ;; *) @@ -191,15 +194,24 @@ _ps1() { if ! [ "$exitcode" = "0" ]; then fail="${fg_bold}${fg_red}?" fi - # printf is used here less for its C-like arguments and more becasue - # POSIX echo doesn't have an option to not print a newline. - # Hence this warning is disabled # shellcheck disable=2059 printf "[${prefix}${cpwd}${r}]${fail}${r}${fg_green}\$${r} " } -if ! [ "$ZSH_NAME" ]; then - # I've got a different ZSH theme - export PS1='$(_ps1)' -fi +# And export our PS1 +case "$_baseshell" in + zsh) + # Don't do this on ZSH + # I have a custom theme for that + ;; + sh) + export PS1='' + ;; + *) + export PS1='$(_ps1)' + ;; +esac + +# Clean up +unset _baseshell