feat: adds expectation that zsh exists, remove shell detection

docs: update install script mentions
This commit is contained in:
Marc 2023-12-16 00:43:31 -05:00
parent a5b44abdce
commit 9fcf9bb8c4
Signed by: marc
GPG key ID: 048E042F22B5DC79
2 changed files with 23 additions and 18 deletions

View file

@ -5,7 +5,7 @@ Environment tweaks for everyday happiness.
## Setup ## Setup
```bash ```bash
git clone git@github.com:mcataford/env.git <path-of-your-choosing> | . ./setup git clone git@github.com:mcataford/env.git <path-of-your-choosing> | . ./install.sh
``` ```
The setup script will look for pre-existing managed blocks and will not update the file if one is found. The setup script will look for pre-existing managed blocks and will not update the file if one is found.
@ -22,7 +22,7 @@ The package is structured as such:
``` ```
env/ env/
setup # Adds bootstrap block to your shell's config file. install.sh # Adds bootstrap block to your shell's config file.
shell_extras # Functions, aliases and exports for the shell. shell_extras # Functions, aliases and exports for the shell.
extras.vim # Common config for NVIM. extras.vim # Common config for NVIM.
``` ```

View file

@ -1,25 +1,26 @@
#!/bin/bash #!/bin/bash
set -e # 1. PRECONDITIONS
#
# Detects the current shell (bash, zsh, ...) and adds, if necessary, a managed
# block to its configuration to source extra files on shell-start.
# #
# zsh is expected to be set up.
BLOCK_DELIMITER_PATTERN="mcataford/env-managed-block" if [ -z "$(zshc --version 2> /dev/null)" ]; then
WORKING_PATH=$(git rev-parse --show-toplevel) echo "💥 Install zsh (https://www.zsh.org/) before installing environment."
SHELL_CONFIG_PATH="" return
# First, we need to know if we're dealing with ZSH or Bash.
if [[ -n $(echo $SHELL | grep zsh) ]]; then
SHELL_CONFIG_PATH="$HOME/.zshrc"
else
SHELL_CONFIG_PATH="$HOME/.bashrc"
fi fi
# A managed block is added to source the `shell_extras` file # 2. CONFIGURATION INJECTION
# in the shell configuration (either `.zshrc` or `.bashrc`).
# 2.1 Inject shell configuration.
#
# Adds a managed block to the shell configuration to
# source extra files on shell-start.
#
BLOCK_DELIMITER_PATTERN="mcataford/env"
WORKING_PATH=$(git rev-parse --show-toplevel)
SHELL_CONFIG_PATH="$HOME/.zshrc"
echo "Setting up shell configuration extras..." echo "Setting up shell configuration extras..."
if [[ -z $(cat $SHELL_CONFIG_PATH | grep $BLOCK_DELIMITER_PATTERN) ]]; then if [[ -z $(cat $SHELL_CONFIG_PATH | grep $BLOCK_DELIMITER_PATTERN) ]]; then
echo "# $BLOCK_DELIMITER_PATTERN\:start echo "# $BLOCK_DELIMITER_PATTERN\:start
@ -33,8 +34,12 @@ fi
EDITOR_CONFIG=$HOME/.config/nvim EDITOR_CONFIG=$HOME/.config/nvim
EDITOR_CONFIG_FILE=$EDITOR_CONFIG/init.vim EDITOR_CONFIG_FILE=$EDITOR_CONFIG/init.vim
# 2.2 Inject nvim configuration.
#
# Similarly, sourcing for `extras.vim` is added to the vim configuration # Similarly, sourcing for `extras.vim` is added to the vim configuration
# so plugins, bindings and whatnot are loaded on start. # so plugins, bindings and whatnot are loaded on start.
#
if [[ -f $EDITOR_CONFIG_FILE ]]; then if [[ -f $EDITOR_CONFIG_FILE ]]; then
echo "Setting up NVIM configuration extras..." echo "Setting up NVIM configuration extras..."
if [[ -z $(cat $EDITOR_CONFIG_FILE | grep $BLOCK_DELIMITER_PATTERN) ]]; then if [[ -z $(cat $EDITOR_CONFIG_FILE | grep $BLOCK_DELIMITER_PATTERN) ]]; then