Skip to content

Commit

Permalink
Reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
markcaudill committed Jan 28, 2024
1 parent 8e692e1 commit 57f782e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 33 deletions.
40 changes: 38 additions & 2 deletions dot-bash_profile
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# shellcheck shell=bash
# shellcheck disable=SC1090
test -f ~/.bashrc && source ~/.bashrc

# From man 1 bash:
# When bash is invoked as an interactive login shell, or as a non-interactive
# shell with the --login option, it first reads and executes commands from the
# file /etc/profile, if that file exists. After reading that file, it looks
# for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads
# and executes commands from the first one that exists and is readable.

# PATH
POTENTIAL_PATHS=(
~/.krew/bin
~/.local/bin
~/bin
~/.cargo/bin
~/.pulumi/bin/
~linuxbrew/.linuxbrew/bin/
/snap/bin
/usr/local/go/bin
/cygdrive/c/Go/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/sbin
/bin
/sbin
/usr/games
/cygdrive/c/Program Files/Git/cmd
)
VALID_PATHS=
# Only add a path to PATH if it it exists and isn't already in PATH. VALID_PATHS is used as intermediary variable
for p in "${POTENTIAL_PATHS[@]}"; do
if [[ -d "${p}" ]]; then
if [[ ":${VALID_PATHS}:" != *":${p}:"* ]]; then
VALID_PATHS="${VALID_PATHS:+"${VALID_PATHS}:"}${p}"
fi
fi
done
export PATH="${VALID_PATHS}"
39 changes: 8 additions & 31 deletions dot-bashrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# shellcheck shell=bash

# From man 1 bash:
# When an interactive shell that is not a login shell is started, bash reads
# and executes commands from /etc/bash.bashrc and ~/.bashrc, if these
# files exist.

# shellcheck disable=SC1090
[[ -f ~/.bash_profile ]] && source ~/.bash_profile

#######################################
##
## Utility Functions
Expand Down Expand Up @@ -51,37 +59,6 @@ export CDPATH=".:~:~/src"
# General
export VISUAL=vim

# PATH
POTENTIAL_PATHS=(
~/.krew/bin
~/.local/bin
~/bin
~/.cargo/bin
~/.pulumi/bin/
~linuxbrew/.linuxbrew/bin/
/snap/bin
/usr/local/go/bin
/cygdrive/c/Go/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/sbin
/bin
/sbin
/usr/games
/cygdrive/c/Program Files/Git/cmd
)
VALID_PATHS=
# Only add a path to PATH if it it exists and isn't already in PATH. VALID_PATHS is used as intermediary variable
for p in "${POTENTIAL_PATHS[@]}"; do
if [[ -d "${p}" ]]; then
if [[ ":${VALID_PATHS}:" != *":${p}:"* ]]; then
debug "Adding ${p} to VALID_PATHS"
VALID_PATHS="${VALID_PATHS:+"${VALID_PATHS}:"}${p}"
fi
fi
done
export PATH="${VALID_PATHS}"

# Environment Activations

Expand Down

0 comments on commit 57f782e

Please sign in to comment.