feat: adds expectation that zsh exists, remove shell detection
docs: update install script mentions
This commit is contained in:
parent
a5b44abdce
commit
9fcf9bb8c4
2 changed files with 23 additions and 18 deletions
|
@ -5,7 +5,7 @@ Environment tweaks for everyday happiness.
|
|||
## Setup
|
||||
|
||||
```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.
|
||||
|
@ -22,7 +22,7 @@ The package is structured as such:
|
|||
|
||||
```
|
||||
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.
|
||||
extras.vim # Common config for NVIM.
|
||||
```
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
#
|
||||
# Detects the current shell (bash, zsh, ...) and adds, if necessary, a managed
|
||||
# block to its configuration to source extra files on shell-start.
|
||||
# 1. PRECONDITIONS
|
||||
#
|
||||
# zsh is expected to be set up.
|
||||
|
||||
BLOCK_DELIMITER_PATTERN="mcataford/env-managed-block"
|
||||
WORKING_PATH=$(git rev-parse --show-toplevel)
|
||||
SHELL_CONFIG_PATH=""
|
||||
|
||||
# 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"
|
||||
if [ -z "$(zshc --version 2> /dev/null)" ]; then
|
||||
echo "💥 Install zsh (https://www.zsh.org/) before installing environment."
|
||||
return
|
||||
fi
|
||||
|
||||
# A managed block is added to source the `shell_extras` file
|
||||
# in the shell configuration (either `.zshrc` or `.bashrc`).
|
||||
# 2. CONFIGURATION INJECTION
|
||||
|
||||
# 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..."
|
||||
if [[ -z $(cat $SHELL_CONFIG_PATH | grep $BLOCK_DELIMITER_PATTERN) ]]; then
|
||||
echo "# $BLOCK_DELIMITER_PATTERN\:start
|
||||
|
@ -33,8 +34,12 @@ fi
|
|||
EDITOR_CONFIG=$HOME/.config/nvim
|
||||
EDITOR_CONFIG_FILE=$EDITOR_CONFIG/init.vim
|
||||
|
||||
# 2.2 Inject nvim configuration.
|
||||
#
|
||||
# Similarly, sourcing for `extras.vim` is added to the vim configuration
|
||||
# so plugins, bindings and whatnot are loaded on start.
|
||||
#
|
||||
|
||||
if [[ -f $EDITOR_CONFIG_FILE ]]; then
|
||||
echo "Setting up NVIM configuration extras..."
|
||||
if [[ -z $(cat $EDITOR_CONFIG_FILE | grep $BLOCK_DELIMITER_PATTERN) ]]; then
|
Loading…
Reference in a new issue