.profile: Cleanup and reorganize

This commit is contained in:
Salt 2018-12-19 23:15:32 -06:00
parent 849c023dca
commit ca72a7876e

View File

@ -20,64 +20,46 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# POSIX NOTICE
# This script should be fully POSIX-compliant
# If it is not, open a bug report at gitlab.com/rehashedsalt/home and I'll take
# care of it
## POSIX NOTICE
# This script, or at least the parts expected to be run by a standard sh
# implementation, should be fully POSIX-compliant. If it is not, open a bug
# report at gitlab.com/rehashedsalt/home and I'll take care of it.
# SHELLCHECK
## SHELLCHECK
# Not finding these sources is none of my concern; they're out of scope
# shellcheck disable=1091
# shellcheck disable=1090
# I'm well aware of when functions are defined vs used
# Those choices are deliberate
# shellcheck disable=2139
# shellcheck disable=2016
# Quit being pedantic
# shellcheck disable=1117
# Some variables will not be used here, but in the shell
# shellcheck disable=2034
# Quit being pedantic
# 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"
alias e='$EDITOR'
# Patch PATH
desiredpath="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/games:/usr/games:$HOME/.bin:$HOME/.local/bin"
# Here, we eliminate the parts of the environment-supplied PATH that we already
# plan on using
IFS=":"
for path in $desiredpath; do
PATH="${PATH#*$path}"
done
unset IFS
# We remove any prepending colons to make it appear neater
while [ "${PATH#:}" != "$PATH" ]; do
PATH="${PATH#:}"
done
# Then finally set up our path
PATH="$desiredpath:$PATH"
# Grab dircolors, if it exists
if command -v dircolors > /dev/null 2>&1; then
dircolorsfile="$HOME/.config/dircolors"
if [ -r "$dircolorsfile" ]; then
eval "$(dircolors "$dircolorsfile")"
else
eval "$(dircolors -b)"
fi
fi
# Grab bash_completion, if it exists
[ -f "/etc/profile.d/bash_completion.sh" ] && . "/etc/profile.d/bash_completion.sh"
# Source ~/.functions, if it exists
[ -r "$HOME/.functions" ] && [ "$_baseshell" != "sh" ] && . "$HOME/.functions"
# Grab pip completion, if it exists
if command -v pip > /dev/null 2>&1; then
case "$_baseshell" in
@ -100,6 +82,25 @@ if command -v pip > /dev/null 2>&1; then
esac
fi
# Grab dircolors, if it exists
if command -v dircolors > /dev/null 2>&1; then
dircolorsfile="$HOME/.config/dircolors"
if [ -r "$dircolorsfile" ]; then
eval "$(dircolors "$dircolorsfile")"
else
eval "$(dircolors -b)"
fi
fi
# Set up editor aliases
for editor in vim vi nano; do
if command -v "$editor" > /dev/null 2>&1; then
export EDITOR="$editor"
break
fi
done
alias e='$EDITOR'
# If emerge exists, add emerge aliases
if command -v emerge > /dev/null 2>&1 ; then
alias e-depclean='sudo emerge -a --depclean'
@ -119,7 +120,7 @@ if command -v instantmusic > /dev/null 2>&1; then
alias songp='instantmusic -s'
fi
# Alias for the dotfile setup
# Alias for my bare repo dotfile setup
if [ -d "$HOME/.dotfiles" ]; then
dotcmd='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
alias dot="$dotcmd"
@ -131,6 +132,7 @@ if [ -d "$HOME/.dotfiles" ]; then
printf 'Checking out masters...\n'; \
$dotcmd submodule -q foreach --recursive 'git checkout -q master && git pull' && \
$dotcmd status"
unset dotcmd
fi
# Aliases for common utilities
@ -153,15 +155,11 @@ else
alias ll="ls -Ahl $lsarguments"
fi
alias cp='cp -i'
# Miscellaneous aliases
alias cp='cp -i'
alias todo='$EDITOR "$HOME/Documents/todo"'
alias waitwhat='echo $?'
# Source ~/.functions, if it exists
[ -r "$HOME/.functions" ] && [ "$_baseshell" != "sh" ] && . "$HOME/.functions"
# Set up a default PS1
# This *should* work for all terminals. I know it works on ksh
_ps1() {