fix(shell): fixed zsh/bash config loading

This commit is contained in:
2023-09-28 17:53:09 +03:00
parent 0aff4784b1
commit fbdd2c7448
8 changed files with 52 additions and 62 deletions

View File

@@ -4,34 +4,12 @@
# Defaults
export DOTFILES="$HOME/.dotfiles"
export DOTFILES_SHARED_LOADED=""
export DOTFILES_CURRENT_SHELL="bash"
# shellcheck source=scripts/shared.sh
source "$DOTFILES/scripts/shared.sh"
path_prepend "$DOTFILES/local/bin"
# Run x-load-configs in your terminal to reload the files.
function x-load-configs()
{
# Load the shell dotfiles, and then some:
for file in $DOTFILES/config/{exports,alias,functions}; do
HOST="$(hostname -s)"
# global (exports|alias|functions) file for all hosts
# shellcheck source=../config/exports
[ -r "$file" ] && source "$file"
# global secret file, git ignored
# shellcheck source=../config/exports-secret
[ -r "$file-secret" ] && source "$file-secret"
# host specific (exports|alias|functions) file
# shellcheck source=../config/exports
[ -r "$file-$HOST" ] && source "$file-$HOST"
# host specific (exports|alias|functions) file, git ignored
# shellcheck source=../config/exports
[ -r "$file-$HOST-secret" ] && source "$file-$HOST-secret"
done
}
x-load-configs
# Import ssh keys in keychain
ssh-add -A 2> /dev/null
# shellcheck source=../config/fzf/fzf.bash
[ -f "${DOTFILES}/config/fzf/fzf.bash" ] \
&& source "${DOTFILES}/config/fzf/fzf.bash"
ssh-add -A 2>/dev/null

View File

@@ -3,32 +3,13 @@
# Defaults
export DOTFILES="$HOME/.dotfiles"
export DOTFILES_SHARED_LOADED=""
export DOTFILES_CURRENT_SHELL="zsh"
# shellcheck source=scripts/shared.sh
source "$DOTFILES/scripts/shared.sh"
path_prepend "$DOTFILES/local/bin"
export COMPLETION_WAITING_DOTS=true
# Run x-load-configs in your terminal to reload the files.
function x-load-configs()
{
# Load the shell dotfiles, and then some:
for file in $DOTFILES/config/{exports,alias,functions}; do
HOST="$(hostname -s)"
# global (exports|alias|functions) file for all hosts
# shellcheck source=../config/exports
[ -r "$file" ] && source "$file"
# global secret file, git ignored
# shellcheck source=../config/exports-secret
[ -r "$file-secret" ] && source "$file-secret"
# host specific (exports|alias|functions) file
# shellcheck source=../config/exports
[ -r "$file-$HOST" ] && source "$file-$HOST"
# host specific (exports|alias|functions) file, git ignored
# shellcheck source=../config/exports
[ -r "$file-$HOST-secret" ] && source "$file-$HOST-secret"
done
}
x-load-configs
export ZSH_CUSTOM_COMPLETION_PATH="$XDG_CONFIG_HOME/zsh/completion"

View File

@@ -4,7 +4,7 @@
export DOTFILES="$HOME/.dotfiles"
source "$DOTFILES/scripts/shared.sh"
path_append "$DOTFILES/local/bin"
path_prepend "$DOTFILES/local/bin"
# Explicitly set XDG folders
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -21,7 +21,7 @@ path_append "/opt/homebrew/bin"
have brew && eval "$(brew shellenv)"
path_append "/usr/local/bin"
path_append "$XDG_BIN_HOME"
path_prepend "$XDG_BIN_HOME"
source "$DOTFILES/config/exports-shell"
source "$DOTFILES/config/exports-apps"

View File

@@ -2,7 +2,7 @@
# shellcheck shell=bash
# shellcheck enable=external-sources
# shellcheck disable=1091,2139
# vim: filetype=zsh
# vim: filetype=bash
export DOTFILES="$HOME/.dotfiles"
source "$DOTFILES/scripts/shared.sh"
@@ -74,8 +74,10 @@ have node && {
# op (1Password cli) is present
export OP_CACHE="$XDG_STATE_HOME/1password"
have op && {
eval "$(op completion zsh)"
compdef _op op
[ "$DOTFILES_CURRENT_SHELL" = "zsh" ] && {
eval "$(op completion zsh)"
compdef _op op
}
}
# Python
@@ -99,7 +101,10 @@ export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
export RBENV_ROOT="$XDG_STATE_HOME/rbenv"
x-dc "$RBENV_ROOT"
have gem && path_append "${GEM_HOME}/bin"
have rbenv && eval "$(rbenv init - zsh)"
have rbenv && {
[ "$DOTFILES_CURRENT_SHELL" = "zsh" ] && eval "$(rbenv init - zsh)"
[ "$DOTFILES_CURRENT_SHELL" = "bash" ] && eval "$(rbenv init - bash)"
}
# Rust / cargo
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"

View File

@@ -44,16 +44,11 @@ export GREP_OPTIONS="--color=auto"
# update the values of LINES and COLUMNS.
hash shopt 2> /dev/null && shopt -s checkwinsize
# Load iterm2 shell integration
# https://iterm2.com/documentation-shell-integration.html
[[ -f "$XDG_BIN_HOME/iterm2_shell_integration.zsh" ]] \
&& source "$XDG_BIN_HOME/iterm2_shell_integration.zsh"
# Set dircolors based on the file, if it exists
have dircolors && eval $(dircolors "$XDG_CONFIG_HOME/dircolors")
# If we are using zsh, color our dir lists and such
if [ "$SHELL" = "$(which zsh)" ]; then
if [ "$DOTFILES_CURRENT_SHELL" = "zsh" ]; then
autoload -U colors zsh/terminfo compinit
colors
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
@@ -67,10 +62,16 @@ if [ "$SHELL" = "$(which zsh)" ]; then
# fzf
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh ] \
&& source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh
# Load iterm2 shell integration
# https://iterm2.com/documentation-shell-integration.html
[[ -f "$XDG_BIN_HOME/iterm2_shell_integration.zsh" ]] \
&& source "$XDG_BIN_HOME/iterm2_shell_integration.zsh"
fi
# If we are using bash
if [ "$SHELL" = "$(which bash)" ]; then
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] \
&& source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash
if [ "$DOTFILES_CURRENT_SHELL" = "bash" ]; then
# shellcheck source=../config/fzf/fzf.bash
[ -f "${DOTFILES}/config/fzf/fzf.bash" ] &&
source "${DOTFILES}/config/fzf/fzf.bash"
fi

View File

@@ -21,6 +21,9 @@ export DOTFILES_SHARED_LOADED=""
# shellcheck source=./../../scripts/shared.sh
source "$SHARED_SCRIPT"
# Loads configs for better installation experience
x-load-configs
function section_install
{
USAGE_PREFIX="$SCRIPT install <command>"

View File

@@ -2,7 +2,6 @@
# Install cargo/rust packages.
#
# shellcheck source=shared.sh
DOTFILES_SHARED_LOADED=""
source "$HOME/.dotfiles/scripts/shared.sh"
! have cargo && {
@@ -10,6 +9,8 @@ source "$HOME/.dotfiles/scripts/shared.sh"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path
}
source "$CARGO_HOME/env"
packages=(
# a subprocess caching utility
"bkt"

View File

@@ -8,6 +8,27 @@
source "$DOTFILES/local/bin/msgr"
# Run x-load-configs in your terminal to reload the files.
function x-load-configs()
{
# Load the shell dotfiles, and then some:
for file in $DOTFILES/config/{exports,alias,functions}; do
HOST="$(hostname -s)"
# global (exports|alias|functions) file for all hosts
# shellcheck source=../config/exports
[ -r "$file" ] && source "$file"
# global secret file, git ignored
# shellcheck source=../config/exports-secret
[ -r "$file-secret" ] && source "$file-secret"
# host specific (exports|alias|functions) file
# shellcheck source=../config/exports
[ -r "$file-$HOST" ] && source "$file-$HOST"
# host specific (exports|alias|functions) file, git ignored
# shellcheck source=../config/exports
[ -r "$file-$HOST-secret" ] && source "$file-$HOST-secret"
done
}
# -- Menu builder -- #
function menu_section()
{