diff --git a/base/bashrc b/base/bashrc index 30ebd75..d40e063 100755 --- a/base/bashrc +++ b/base/bashrc @@ -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 diff --git a/base/zshrc b/base/zshrc index f8b421a..538d15c 100755 --- a/base/zshrc +++ b/base/zshrc @@ -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" diff --git a/config/exports b/config/exports index d2e90ec..b3c0d51 100755 --- a/config/exports +++ b/config/exports @@ -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" diff --git a/config/exports-apps b/config/exports-apps index f81e5cc..7b33acd 100755 --- a/config/exports-apps +++ b/config/exports-apps @@ -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" diff --git a/config/exports-shell b/config/exports-shell index 57dac34..88d90cc 100755 --- a/config/exports-shell +++ b/config/exports-shell @@ -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 diff --git a/local/bin/dfm b/local/bin/dfm index d895c21..c27535a 100755 --- a/local/bin/dfm +++ b/local/bin/dfm @@ -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 " diff --git a/scripts/install-cargo-packages.sh b/scripts/install-cargo-packages.sh index fde21fe..582a439 100755 --- a/scripts/install-cargo-packages.sh +++ b/scripts/install-cargo-packages.sh @@ -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" diff --git a/scripts/shared.sh b/scripts/shared.sh index 0336cc9..9d19e97 100755 --- a/scripts/shared.sh +++ b/scripts/shared.sh @@ -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() {