37 lines
1.1 KiB
Bash
37 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
#
|
|
# Detects the current shell (bash, zsh, ...) and adds, if necessary, a managed
|
|
# block to its configuration to source extra files on shell-start.
|
|
#
|
|
|
|
BLOCK_DELIMITER_PATTERN="mcataford/env-managed-block"
|
|
|
|
SHELL_CONFIG_PATH=""
|
|
|
|
if [[ -n $(echo $SHELL | grep zsh) ]]; then
|
|
SHELL_CONFIG_PATH="$HOME/.zshrc"
|
|
else
|
|
SHELL_CONFIG_PATH="$HOME/.bashrc"
|
|
fi
|
|
|
|
if [[ -z $(cat $SHELL_CONFIG_PATH | grep $BLOCK_DELIMITER_PATTERN) ]]; then
|
|
echo "# $BLOCK_DELIMITER_PATTERN:start
|
|
for f in ~/.env_goodies/source/*; do source $f; done
|
|
# $BLOCK_DELIMITER_PATTERN:end" >> $SHELL_CONFIG_PATH
|
|
fi
|
|
|
|
EDITOR_CONFIG=$HOME/.config/nvim
|
|
EDITOR_CONFIG_FILE=$EDITOR_CONFIG/init.vim
|
|
|
|
if [[ -f $EDITOR_CONFIG_FILE ]]; then
|
|
if [[ -z $(cat $EDITOR_CONFIG_FILE | grep $BLOCK_DELIMITER_PATTERN) ]]; then
|
|
echo "\" $BLOCK_DELIMITER_PATTERN:start
|
|
source $HOME/.env_goodies/extras.vim
|
|
\" $BLOCK_DELIMITER_PATTERN:end\n\n" >> $EDITOR_CONFIG_FILE.new
|
|
cat $EDITOR_CONFIG_FILE >> $EDITOR_CONFIG_FILE.new
|
|
|
|
mv $EDITOR_CONFIG_FILE $EDITOR_CONFIG_FILE.old
|
|
mv $EDITOR_CONFIG_FILE.new $EDITOR_CONFIG_FILE
|
|
fi
|
|
fi
|