Skip to content

Commit

Permalink
fix: properly initialize dots (closes #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Sep 2, 2021
1 parent 0d61b3a commit 7835a70
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## v0.6.1 (2021-09-02)

* Separates `dots_check_shell` from `dots_init_message`
* Adds `dots_check_shell` to `dots_init` and properly exits of the shell is not supported
* Overwrites the contents of `$SHELL_CONFIG_FILE` instead of removing and appending to it in `dots_reset_terminal_config` (closes #2)

## v0.6.0 (2021-09-01)

* Swaps the order in `dots_sync` to `pull` first and `push` second instead of the previous order which was reversed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Dots makes no assumptions when as to how or where your dotfiles should be instal
* Optionally prints info about your Dots on each shell start:

```
################### Dots v0.5.2 ###################
################### Dots v0.6.1 ###################
Shell: /bin/zsh
Hostname: MacBook-Pro-Justin
Powered by Justintime50's Dotfiles
Expand Down
11 changes: 6 additions & 5 deletions src/dots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DOTFILES_DIR="$HOME/.dotfiles"
SHOW_INIT_MESSAGE="true" # Leave this empty if you don't want to show the init messages (eg: SHOW_INIT_MESSAGE=)

# Dots required variables (do not edit)
DOTS_VERSION="v0.6.0"
DOTS_VERSION="v0.6.1"
HOSTNAME=$(hostname) # Required for macOS
DOTS_SCRIPT="$DOTFILES_DIR/dots/src/dots.sh"
DOTS_CONFIG_FILE="$DOTFILES_DIR/dots-config.sh"
Expand All @@ -26,12 +26,14 @@ dots_get_dotfiles_status() {
# Ensures the shell being used is supported, warns if not
dots_check_shell() {
if [ "$SHELL" != "/bin/zsh" ] && [ "$SHELL" != "/bin/bash" ] ; then
echo "Dots doesn't support $SHELL."
echo "Dots doesn't support $SHELL." && exit 1
fi
}

# Anything that Dots needs upon initialization goes here
dots_init() {
dots_check_shell

if [ "$SHELL" = "/bin/zsh" ] ; then
SHELL_CONFIG_FILE="$HOME/.zshrc"
elif [ "$SHELL" = "/bin/bash" ] ; then
Expand All @@ -42,7 +44,6 @@ dots_init() {
# Print Dotfiles message on each shell start (will be initialized from core shell file)
dots_init_message() {
echo "################### Dots $DOTS_VERSION ###################"
dots_check_shell
echo "Shell: $SHELL"
echo "Hostname: $HOSTNAME"
echo "Powered by $DOTFILES_GITHUB_USER's Dotfiles"
Expand Down Expand Up @@ -76,7 +77,7 @@ dots_pull() {

# Resets the .zshrc/.bash_profile files to only contain Dots and the config
dots_reset_terminal_config() {
rm "$SHELL_CONFIG_FILE"
dots_init # We initialize Dots here to properly set $SHELL_CONFIG_FILE

if [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/bin/bash" ] ; then
{
Expand All @@ -90,7 +91,7 @@ dots_reset_terminal_config() {
fi
echo "";
echo "# Dotfiles Config";
} >> "$SHELL_CONFIG_FILE"
} > "$SHELL_CONFIG_FILE"
fi
}

Expand Down

0 comments on commit 7835a70

Please sign in to comment.