fix(shell): change how shell detection works

This commit is contained in:
2023-09-29 15:52:16 +03:00
parent dfb7a51786
commit 4b45c89a90
6 changed files with 34 additions and 29 deletions

View File

@@ -4,7 +4,6 @@
# 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"

View File

@@ -3,7 +3,6 @@
# Defaults
export DOTFILES="$HOME/.dotfiles"
export DOTFILES_CURRENT_SHELL="zsh"
# shellcheck source=scripts/shared.sh
source "$DOTFILES/scripts/shared.sh"
path_prepend "$DOTFILES/local/bin"

View File

@@ -4,7 +4,7 @@
# shellcheck disable=1091,2139
# vim: filetype=bash
export DOTFILES="$HOME/.dotfiles"
: "${DOTFILES:=$HOME/.dotfiles}"
source "$DOTFILES/scripts/shared.sh"
# Antigen configuration

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck disable=1091,2046
# vim: filetype=zsh
# vim: filetype=bash
export DOTFILES="$HOME/.dotfiles"
source "$DOTFILES/scripts/shared.sh"
@@ -48,25 +48,27 @@ hash shopt 2> /dev/null && shopt -s checkwinsize
have dircolors && eval $(dircolors "$XDG_CONFIG_HOME/dircolors")
# If we are using zsh, color our dir lists and such
if [ "$DOTFILES_CURRENT_SHELL" = "zsh" ]; then
autoload -U colors zsh/terminfo compinit
colors
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
if [ "$DOTFILES_CURRENT_SHELL" = "-zsh" ]; then
[[ $ZSH_VERSION != "" ]] && {
autoload -U colors zsh/terminfo compinit
colors
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
x-dc "$XDG_CACHE_HOME/zsh"
x-dc "$XDG_STATE_HOME/zsh"
export HISTFILE="$XDG_STATE_HOME/zsh/history"
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
zstyle ':completion:*' list-colors "$LS_COLORS"
x-dc "$XDG_CACHE_HOME/zsh"
x-dc "$XDG_STATE_HOME/zsh"
export HISTFILE="$XDG_STATE_HOME/zsh/history"
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
zstyle ':completion:*' list-colors "$LS_COLORS"
# fzf
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh ] \
&& source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh
# 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"
# 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

View File

@@ -3,20 +3,21 @@
# Copyright (c) 2023 Ismo Vuorinen. All Rights Reserved.
: "${DOTFILES:=$HOME/.dotfiles}"
source "$DOTFILES/scripts/shared.sh"
# Load the shell dotfiles, and then some:
for file in $DOTFILES/config/{exports,alias,functions}; do
for FILENAME in $DOTFILES/config/{exports,alias,functions}; do
HOST="$(hostname -s)"
# global (exports|alias|functions) file for all hosts
# global (exports|alias|functions) FILENAME for all hosts
# shellcheck source=../config/exports
[ -r "$file" ] && source "$file"
# global secret file, git ignored
[ -r "$FILENAME" ] && source "$FILENAME"
# global secret FILENAME, git ignored
# shellcheck source=../config/exports-secret
[ -r "$file-secret" ] && source "$file-secret"
# host specific (exports|alias|functions) file
[ -r "$FILENAME-secret" ] && source "$FILENAME-secret"
# host specific (exports|alias|functions) FILENAME
# shellcheck source=../config/exports
[ -r "$file-$HOST" ] && source "$file-$HOST"
# host specific (exports|alias|functions) file, git ignored
[ -r "$FILENAME-$HOST" ] && source "$FILENAME-$HOST"
# host specific (exports|alias|functions) FILENAME, git ignored
# shellcheck source=../config/exports
[ -r "$file-$HOST-secret" ] && source "$file-$HOST-secret"
[ -r "$FILENAME-$HOST-secret" ] && source "$FILENAME-$HOST-secret"
done

View File

@@ -5,6 +5,10 @@
# Helper env variables. Use like this: VERBOSE=1 ./script.sh
: "${VERBOSE:=0}"
: "${DOTFILES:=$HOME/.dotfiles}"
DOTFILES_CURRENT_SHELL=$(ps -p $$ -oargs=)
export DOTFILES_CURRENT_SHELL
source "$DOTFILES/local/bin/msgr"