feat: update helper

This commit is contained in:
Marc 2022-11-04 13:37:25 -04:00
parent aaea7d6a2a
commit 0d1480921e
3 changed files with 37 additions and 0 deletions

View file

@ -12,3 +12,17 @@ git clone git@github.com:mcataford/env.git ~/.env_goodies | . ./setup
Since `~/.env_goodies` is a cloned repository, pulling new changes should update everything. You may need to `source`
the shell configuration file again for new goodies to apply.
## Structure
The package is structured as such:
```
env/
setup # Adds bootstrap block to your shell's config file.
source/
... # Anything here is sourced on shell-start
```
Adding files to `source/` will add code that gets executed on shell-start. Files are discovered by globbing in the
bootstrap block added by `setup` and do not need to be registered anywhere.

5
setup
View file

@ -1,5 +1,10 @@
#!/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.
#
SHELL_CONFIG_PATH=""
if [[ -n $(echo $SHELL | grep zsh) ]]; then

18
source/autoupdate Normal file
View file

@ -0,0 +1,18 @@
function env_autoupdate {
SHELL_CONFIG_PATH=""
if [[ -n $(echo $SHELL | grep zsh) ]]; then
SHELL_CONFIG_PATH="$HOME/.zshrc"
else
SHELL_CONFIG_PATH="$HOME/.bashrc"
fi
{
cd ~/.env_goodies
git pull
source $SHELL_CONFIG_PATH
cd -
}
}