Skip to content

Commit 8e7e80b

Browse files
committed
ZSH Integration
* created `shell.d` for shared resources in `bash` and `zsh` * added a `zshrc`
1 parent b62f878 commit 8e7e80b

21 files changed

+149
-65
lines changed

bash.d/00-system-defaults.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

bash.d/04-bash-completion.sh renamed to bash.d/02-bash-completion.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ COMPLETION_SCRIPTS="
66
/opt/local/etc/bash_completion
77
/opt/local/etc/profile.d/bash_completion.sh
88
/etc/bash_completion.d/git
9-
$HOMEBREW_PREFIX/etc/bash_completion
10-
$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh
119
"
1210

1311
for file in $COMPLETION_SCRIPTS; do

bash.d/03-homebrew.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ if [ -n "$brew_install_dir" ] && [ -x "$brew_install_dir/bin/brew" ]; then
1111
path_inject "$brew_install_dir/bin"
1212
eval "$($brew_install_dir/bin/brew shellenv)"
1313

14-
# Inject gnubins therein
15-
for path in $brew_install_dir/opt/*/libexec/gnubin; do
16-
path_inject "$path"
17-
done
14+
# Completions
15+
hbcomp="$brew_install_dir/etc/profile.d/bash_completion.sh"
16+
[ -r "$hbcomp" ] && . "$hbcomp"
1817

19-
for p in "bash_completion.sh" "z.sh"; do
20-
profile="$brew_install_dir/etc/profile.d/$p"
21-
[[ -r "$profile" ]] && . "$profile"
18+
# Inject gnubins therein
19+
for dir in $brew_install_dir/opt/*/libexec/gnubin; do
20+
path_inject "$dir"
2221
done
2322

2423
# Load Latest PgSQL paths

bash.d/10-prompt.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function prompt_extra() {
77
addition="${bldblk}(${host_color}${addition}${bldblk})$txtrst";
88
fi;
99

10-
if [ -z $PROMPT_EXTRA ]; then
10+
if [ -z "${PROMPT_EXTRA+x}" ]; then
1111
PROMPT_EXTRA=$addition;
1212
else
1313
PROMPT_EXTRA="$PROMPT_EXTRA$addition"
@@ -27,7 +27,7 @@ function before_prompt() {
2727

2828
printf "$bldblk[$host_color%s$bldblk] $(get_user_color)%s" "$(date '+%H:%M:%S')" "$PWD"
2929

30-
if [ "$VCPROMPT" != "disable" ]; then
30+
if [ "${VCPROMPT+x}" != "disable" ]; then
3131
if git status &> /dev/null; then
3232
rev=$(git rev-parse --short HEAD)
3333
branch=$(git branch 2> /dev/null | grep '^*' | colrm 1 2)
@@ -48,7 +48,7 @@ function before_prompt() {
4848
fi
4949
fi
5050

51-
[ ! -z $PROMPT_EXTRA ] && printf " $PROMPT_EXTRA";
51+
[ ! -z "${PROMPT_EXTRA+x}" ] && printf " $PROMPT_EXTRA";
5252

5353
[ $retval -ne 0 ] && printf " $bldred[*${txtred}${retval}${bldred}*]$txtrst";
5454

bash.d/30-zoxide.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
if hash zoxide &> /dev/null; then
2-
eval "$(zoxide init bash)"
3-
4-
alias cd=z
2+
eval "$(zoxide init --cmd=cd bash)"
53
fi

bash.d/40-k8s.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# Load completions
44
for cmd in 'kubectl' 'minikube'; do
55
if hash "$cmd" &> /dev/null; then
6-
source <($cmd completion $(basename "$SHELL"))
6+
source <($cmd completion $(basename "${shell_name}"))
77
fi
88
done

bashrc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,27 @@ case $- in *i*) INTERACTIVE=1;; esac
99

1010
if [ $INTERACTIVE -eq 1 ]; then
1111
# Interactive session, load ALL THE THINGS!
12+
for rc in ~/.shell.d/*.sh; do
13+
file=$(basename "$rc")
14+
[[ $file == 99* ]] && continue
15+
(( $DEBUG )) && echo "rc loading '$rc'";
16+
source $rc;
17+
done;
1218
for rc in ~/.bash.d/*.sh; do
1319
(( $DEBUG )) && echo "rc loading '$rc'";
1420
source $rc;
1521
done;
22+
for rc in ~/.shell.d/9*.sh; do
23+
(( $DEBUG )) && echo "rc loading '$rc'";
24+
source $rc;
25+
done;
1626
(( $DEBUG )) && echo "Loaded fully interactive."
1727
else
1828
# Non-interactive, sparse load
19-
source ~/.bash.d/00-system-defaults.sh
20-
source ~/.bash.d/00-variables.sh
21-
source ~/.bash.d/01-functions.sh
22-
source ~/.bash.d/02-base-paths.sh
23-
source ~/.bash.d/99-aliases.sh
29+
for rc in ~/.shell.d/{0,9}*.sh; do
30+
(( $DEBUG )) && echo "rc loading '$rc'";
31+
source $rc;
32+
done;
2433
fi;
2534

2635
# Clear any bad RC's

gitconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
tool = vimdiff
1313
[alias]
1414
br = branch
15-
ci = commit
15+
ci = "commit -v"
1616
co = checkout
1717
cp = commit -p
1818
lp = log --format=\"%h - %an, %ar : %s\"

shell.d/00-system-defaults.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Pull in the system-wide defaults
2+
export shell_name=$(basename "$SHELL")
3+
sysShellRC=("/opt/local/etc/${shell_name}rc" "/usr/local/etc/${shell_name}rc" "/etc/${shell_name}/rc")
4+
5+
## Fix ulimit
6+
if command -v ulimit &> /dev/null; then
7+
minimum_ulimit=8192;
8+
if [ "$(ulimit -n)" -lt "$minimum_ulimit" ]; then
9+
ulimit -n "$minimum_ulimit"
10+
fi
11+
fi
12+
13+
for shellrc in "${sysShellRC[@]}"; do
14+
if [ -f "$shellrc" ]; then
15+
. "$shellrc"
16+
(( $DEBUG )) && echo "Loaded system settings: $shellrc"
17+
break;
18+
fi
19+
done

bash.d/00-variables.sh renamed to shell.d/00-variables.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ export EDITOR LANG LC_TIME HOSTOS PLATFORM
1414
unset USERNAME
1515
unset LS_COLORS
1616

17-
if [ -f "$HOME/.bash_variables" ]; then
18-
. "$HOME/.bash_variables"
19-
fi
17+
for vars in "$HOME/.shell_variables" "$HOME/.${shell_name}_variables"; do
18+
[ -f "$vars" ] && . "$vars"
19+
done

0 commit comments

Comments
 (0)