From 1ae92cfc2aca011a4314e5759f804e00447ffe5c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 19 May 2020 17:34:28 +0200 Subject: [PATCH] [bash] Fix bash profile initialization Removed automatic initializations of zsh functions. Fixed not calling correct folders for bash aliases, environment variables and profile settings. --- git/.config/sh/alias.d/git.sh | 12 ++++++----- home/.bash_profile | 25 +++++++++++++++++------ home/.bashrc | 23 +++++++++------------ sh/.config/sh/alias.d/enable-fasd-hook.sh | 8 ++++---- 4 files changed, 40 insertions(+), 28 deletions(-) diff --git a/git/.config/sh/alias.d/git.sh b/git/.config/sh/alias.d/git.sh index 9bf3e68..6122588 100644 --- a/git/.config/sh/alias.d/git.sh +++ b/git/.config/sh/alias.d/git.sh @@ -47,11 +47,13 @@ if exist git; then alias gst='git status' - autoload -Uz is-at-least - if is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')"; then - alias gsta='git stash push' - else - alias gsta='git stash save' + if [ "$0" = "/bin/zsh" ]; then + autoload -Uz is-at-least + if is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')"; then + alias gsta='git stash push' + else + alias gsta='git stash save' + fi fi alias gstp='git stash pop' alias gstl='git stash list' diff --git a/home/.bash_profile b/home/.bash_profile index 929d7dd..f724702 100644 --- a/home/.bash_profile +++ b/home/.bash_profile @@ -1,13 +1,26 @@ +#!/usr/bin/env bash # # ~/.bash_profile # +# shellcheck disable=SC1090 -if [ -d $XDG_CONFIG_HOME/shell/login.d ]; then - for file in $XDG_CONFIG_HOME/shell/login.d/*.sh; do - source $file - done +# load global sh env vars +[ -f "$XDG_CONFIG_HOME/sh/env" ] && source "$XDG_CONFIG_HOME/sh/env" +if [ -d "$XDG_CONFIG_HOME/sh/env.d" ]; then + for _env in "$XDG_CONFIG_HOME/sh/env.d"/*.sh; do + . "$_env" + done + unset _env fi -[[ -f ~/.bashrc ]] && . ~/.bashrc +# load profile files vars +[ -f "$XDG_CONFIG_HOME/sh/profile" ] && source "$XDG_CONFIG_HOME/sh/profile" +if [ -d "$XDG_CONFIG_HOME/sh/profile.d" ]; then + for _profile in "$XDG_CONFIG_HOME/sh/profile.d"/*.sh; do + . "$_profile" + done + unset _profile +fi -export PATH="$HOME/.cargo/bin:$PATH" +# shellcheck disable=SC1090 +[[ -f ~/.bashrc ]] && . ~/.bashrc diff --git a/home/.bashrc b/home/.bashrc index 4f22ee4..7b0c083 100644 --- a/home/.bashrc +++ b/home/.bashrc @@ -1,23 +1,20 @@ # # ~/.bashrc # +# shellcheck disable=SC1090 + +CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}" # If not running interactively, don't do anything [[ $- != *i* ]] && return -# Load files from rc.d -if [ -d $XDG_CONFIG_HOME/shell/rc.d ]; then - for file in $XDG_CONFIG_HOME/shell/rc.d/*.sh; do - source $file - done +[ -f "$CONFDIR/sh/alias" ] && source "$CONFDIR/sh/alias" +# load additional aliases +if [ -d "$CONFDIR/sh/alias.d" ]; then + for _alias in "$CONFDIR/sh/alias.d"/*.sh; do + . "$_alias" + done + unset _alias fi - -# Load files from bashrc.d -if [ -d $XDG_CONFIG_HOME/shell/bashrc.d ]; then - for file in $XDG_CONFIG_HOME/shell/bashrc.d/*.bash; do - source $file - done -fi - alias ls='ls --color=auto' PS1='[\u@\h \W]\$ ' diff --git a/sh/.config/sh/alias.d/enable-fasd-hook.sh b/sh/.config/sh/alias.d/enable-fasd-hook.sh index 7d915a2..4bd4798 100644 --- a/sh/.config/sh/alias.d/enable-fasd-hook.sh +++ b/sh/.config/sh/alias.d/enable-fasd-hook.sh @@ -1,10 +1,10 @@ #!/bin/sh # more usage instructions at https://github.com/clvv/fasd -eval "$(fasd --init posix-hook posix_alias bash-hook zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)" -# eval "$(fasd --init auto)" +# eval "$(fasd --init posix-hook posix_alias bash-hook zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install)" +type fasd >/dev/null 2>&1 && eval "$(fasd --init auto)" -alias a='fasd -a' # any -alias s='fasd -si' # show / search / select +alias a='fasd -a' # any +alias s='fasd -si' # show / search / select # alias d='fasd -d' # directory # alias f='fasd -f' # file # alias sd='fasd -sid' # interactive directory selection