Skip to content

Commit

Permalink
fix: rename env vars and clarify instructions for better experience
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Feb 6, 2022
1 parent 4c24f0e commit ec5eb44
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## v1.1.0 (2022-02-06)

* Renames the `DOTS_SHOW_INIT_MESSAGE` to `DOTS_DISABLE_INIT_MESSAGE` to more accurately represent what's happening since the init message is always on by default
* Clarifies instructions to setup a custom dotfiles during installation
* Various small tweaks internally

## v1.0.0 (2021-11-21)

* Refactored variables for easier installation (now requiring no parameters to the install script), better reuse of code, and correctly namespaced items
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ Dots will override your current Dotfiles, namely `~/.zshrc` for `zsh`, `~/.bash_

To install Dots, simply drop it into your current Dotfiles project:

* If installing Dots into your current Dotfiles project, follow step `1a`.
* If installing your Dotfiles on a new machine (assumes Dots is already in your Dotfiles project), follow step `1b`.
* Regardless of which part of step 1 you follow, run steps 2.
* If installing Dots into your current Dotfiles project, follow step `1a`
* If installing your Dotfiles on a new machine (assumes Dots is already in your Dotfiles project), follow step `1b`
* Regardless of which part of step 1 you follow, run steps 2
* Optionally set env vars in step 3

```bash
# 1a) Add Dots as a git submodule in your Dotfiles project
Expand All @@ -57,6 +58,9 @@ git -C "$HOME/.dotfiles" submodule init && git -C "$HOME/.dotfiles" submodule up
# 2) Install Dots
# Installation assumes your dotfiles are are stored at `~/.dotfiles`; if not, alter the `DOTFILES_DIR` variable in `install.sh`
$HOME/.dotfiles/dots/src/install.sh

# 3) Optionally set the dotfiles directory (defaults to ~/.dotfiles when not set explicitly)
echo 'export DOTFILES_DIR=my/custom/path' >> ~/.zshrc
```

## Usage
Expand Down Expand Up @@ -94,11 +98,11 @@ dots_update

**Dots Shell Initialization Message**

If you would like to not show the Dots message on shell start, simply make the `DOTS_SHOW_INIT_MESSAGE` variable found in `dots.sh` empty.
If you would like to disable the Dots message on shell start, simply set the `DOTS_DISABLE_INIT_MESSAGE` env var in your shell profile.

## Configuration

The only thing Dots requires for configuration is a file in the root of your Dotfiles project titled `dots-config.sh` with two functions. Much like a database migration file, we provide a list of instructions (up and down) to install or clean our Dotfiles. A simple example is shown below:
The only thing Dots requires for configuration is a file in the root of your Dotfiles project titled `dots-config.sh` with two functions. Inspired by database migration syntax, we provide a list of instructions (up and down) to install or clean our Dotfiles. A simple example is shown below:

### Basic Configuration

Expand Down
23 changes: 11 additions & 12 deletions src/dots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

# User configurable variables
DOTFILES_DIR="$HOME/.dotfiles" # Cannot be `~/.dots` as we will use this for internal Dots usage
DOTS_SHOW_INIT_MESSAGE="true" # Leave this empty if you don't want to show the init messages (eg: DOTS_SHOW_INIT_MESSAGE=)
DOTS_CONFIG_FILE="$DOTFILES_DIR/dots-config.sh"

# Dots required variables (do not edit)
DOTS_VERSION="v1.0.0"
DOTS_VERSION="v1.1.0"
HOSTNAME="$(hostname)" # Required for macOS as it's not set automatically like it is on Linux
DOTS_DIR="$HOME/.dots"
DOTS_DOTFILES_DIR="$DOTFILES_DIR/dots/src"
DOTS_SCRIPT_FILE="$DOTS_DOTFILES_DIR/dots.sh"
DOTS_CONFIG_FILE="$DOTFILES_DIR/dots-config.sh"
DOTS_HOME_DIR="$HOME/.dots"
DOTS_DIR="$DOTFILES_DIR/dots/src"
DOTS_SCRIPT_FILE="$DOTS_DIR/dots.sh"

### CHECKERS ###

Expand Down Expand Up @@ -64,10 +63,10 @@ _dots_get_dotfiles_status() {
_dots_init() {
if _dots_check_shell; then
# Source anything that's required for the installer and dots such as `_dots_set_shell_config_file`
. "$DOTS_DOTFILES_DIR/shared.sh"
. "$DOTS_DIR/shared.sh"
_dots_set_shell_config_file # Sourced from `shared.sh`

mkdir -p "$DOTS_DIR"
mkdir -p "$DOTS_HOME_DIR"
else
return 1
fi
Expand All @@ -93,7 +92,7 @@ _dots_reset_terminal_config() {
echo ". $DOTS_SCRIPT_FILE"
echo ". $DOTS_CONFIG_FILE"
echo "_dots_init"
if [ "$DOTS_SHOW_INIT_MESSAGE" ]; then
if [ ! "$DOTS_DISABLE_INIT_MESSAGE" ]; then
echo "_dots_init_message"
fi
echo ""
Expand All @@ -109,7 +108,7 @@ _dots_log_install_step() {
set -x
dots_config_up
set +x
} 2>"$DOTS_DIR/install.log"
} 2>"$DOTS_HOME_DIR/install.log"
}

# Save the clean steps to a log
Expand All @@ -119,7 +118,7 @@ _dots_log_clean_step() {
set -x
dots_config_down
set +x
} 2>"$DOTS_DIR/clean.log"
} 2>"$DOTS_HOME_DIR/clean.log"
}

### INTERFACES ###
Expand Down Expand Up @@ -190,7 +189,7 @@ dots_source() {

# List the dotfiles that were installed
dots_list() {
cat "$DOTS_DIR/install.log"
cat "$DOTS_HOME_DIR/install.log"
}

# Update the Dots submodule in the `DOTFILES_DIR`
Expand Down
9 changes: 5 additions & 4 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
# shellcheck disable=SC1090,SC1091

DOTFILES_DIR="$HOME/.dotfiles"
DOTS_DOTFILES_DIR="$DOTFILES_DIR/dots/src"
DOTS_DIR="$DOTFILES_DIR/dots/src"
DOTS_CONFIG_FILE="$DOTFILES_DIR/dots-config.sh"

main() {
# Sets SHELL_CONFIG_FILE for our use
. "$DOTS_DOTFILES_DIR/shared.sh"
. "$DOTS_DIR/shared.sh"
_dots_set_shell_config_file # Sourced from `shared.sh`

# Add Dots as a sourced script to your current shell config (running this install script will overwrite your shell config file)
echo ". $DOTS_DOTFILES_DIR/dots.sh" >>"$SHELL_CONFIG_FILE"
echo ". $DOTFILES_DIR/dots-config.sh" >>"$SHELL_CONFIG_FILE"
echo ". $DOTS_DIR/dots.sh" >>"$SHELL_CONFIG_FILE"
echo ". $DOTS_CONFIG_FILE" >>"$SHELL_CONFIG_FILE"

# Source the SHELL_CONFIG_FILE so we can call `dots_sync`
. "$SHELL_CONFIG_FILE"
Expand Down

0 comments on commit ec5eb44

Please sign in to comment.