.profile: Small improvements
I think Not really, actually
This commit is contained in:
parent
5dff2dca30
commit
9c4a950385
30
.profile
30
.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
|
||||
# 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)'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Clean up
|
||||
unset _baseshell
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user