Skip to content

Commit

Permalink
Merge pull request #33 from edheltzel/feature/xdg
Browse files Browse the repository at this point in the history
Feature/xdg
  • Loading branch information
edheltzel authored Feb 6, 2024
2 parents 06bf8b0 + 1f2b5c5 commit 6ce8dfa
Show file tree
Hide file tree
Showing 138 changed files with 4,140 additions and 6,118 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"tigrc",
"tldr",
"tmol",
"Unstowing",
"zoxide"
],
}
59 changes: 48 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,69 @@
STOW_PACKAGES := dots git fish nvim config warp vscode
STOW_PACKAGES := dots git fish nvim config local warp vscode
YELLOW := \033[33m
GREEN := \033[32m
WHITE := \033[37m
CLR := \033[0m

.PHONY: all
all: help
.PHONY: default
default: help

.PHONY: help
help: ## Show this help message (default)
@awk 'BEGIN {FS = ":.*?## "}; \
/^[^\t][a-zA-Z0-9_-]+:.*?##/ \
{ printf "\033[36m%-24s\033[0m %s\n", $$1, $$2 } \
/^##/ { printf "\033[33m%s\033[0m\n", substr($$0, 4) }' $(MAKEFILE_LIST)
{ printf "\033[36m%-24s$(CLR) %s\n", $$1, $$2 } \
/^##/ { printf "$(YELLOW)%s$(CLR)\n", substr($$0, 4) }' $(MAKEFILE_LIST)

.PHONY: stow
stow: ## Symlink all dotfiles managed by Stow
.PHONY: install
install: ## Bootsraps a new machine
@echo "$(YELLOW)Running bootstrap to provision the system...$(CLR)"
@./install.sh
@echo "$(GREEN)System provisioning complete!$(CLR)"


.PHONY: run
run: ## Symlink all dotfiles w/Stow
@for pkg in $(STOW_PACKAGES); do \
stow $$pkg; \
done
@echo "Dotfiles stowed successfully"

.PHONY: stow
stow: ## Add individual packages w/Stow
@if [ -z "${pkg}" ]; then \
echo "Error: Please specify a package to stow. \n$(YELLOW)ie: $(YELLOW)make stow pkg=<pacakgeName>$(CLR) \n$(WHITE)Available packages:$(CLR) $(STOW_PACKAGES)"; \
exit 1; \
fi
@if [[ ! " ${STOW_PACKAGES} " =~ " ${pkg} " ]]; then \
echo "Error: Package '${pkg}' not found in STOW_PACKAGES: $(STOW_PACKAGES)"; \
exit 1; \
fi
stow ${pkg}
@echo "${pkg} was added"

.PHONY: unstow
unstow: ## Remove all dotfiles managed by Stow
unstow: ## Remove individual packages w/Stow
@if [ -z "${pkg}" ]; then \
echo "Error: Please specify a package to unstow. \n$(YELLOW)ie: $(YELLOW)make unstow pkg=<pacakgeName>$(CLR) \n$(WHITE)Available packages:$(CLR) $(STOW_PACKAGES)"; \
exit 1; \
fi
@if [[ ! " ${STOW_PACKAGES} " =~ " ${pkg} " ]]; then \
echo "Error: Package '${pkg}' not found in STOW_PACKAGES: $(STOW_PACKAGES)"; \
exit 1; \
fi
stow --delete ${pkg}
@echo "${pkg} was removed"

.PHONY: delete
delete: ## Delete all dotfiles w/Stow
@for pkg in $(STOW_PACKAGES); do \
stow --delete $$pkg; \
done
@echo "Dotfiles zapped! ⚡️"
@echo "$(WHITE)Dotfiles zapped! ⚡️"

.PHONY: update
update: ## Update dotfiles & remove broken symlinks managed by Stow
update: ## Sync & clean dead symlinks w/Stow
@for pkg in $(STOW_PACKAGES); do \
stow --restow $$pkg; \
done
@echo "Dotfiles updated successfully"
@echo "$(GREEN)Dotfiles updated successfully$(CLR)"
275 changes: 160 additions & 115 deletions README.md

Large diffs are not rendered by default.

77 changes: 39 additions & 38 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
#!/bin/bash
#!/usr/bin/env bash

# Define variables
DOTFILES_REPO="https://github.com/edheltzel/dotfiles.git"
PROJECTS_DIR="$HOME/Developer"
DOTFILES_DIR="$HOME/.dotfiles"
# Define the source and target locations
SOURCE="https://github.com/edheltzel/dotfiles"
TARBALL="$SOURCE/tarball/main"
TARGET="$HOME/.dotfiles"
TAR_CMD="tar -xzv -C \"$TARGET\" --strip-components=1 --exclude='{.gitignore}'"

# Define functions for prompts, banners, and errors
print_prompt() {
echo -e "\033[1m$1\033[0m"
# Function to check if a command is executable
is_executable() {
type "$1" > /dev/null 2>&1
}

function print_banner() {
local message="$1"
echo -e "${YELLOW}====================================================${NC}"
echo -e "${YELLOW} NOTE: $message${NC}"
echo -e "${YELLOW}====================================================${NC}"
}

print_error() {
local message="$1"
echo -e "${YELLOW}====================================================${NC}"
echo -e "${YELLOW} ERROR: $message${NC}"
echo -e "${YELLOW}====================================================${NC}"
}

##

# Create the Developer directory if it does not exist
if [ ! -d "$PROJECTS_DIR" ]; then
mkdir "$PROJECTS_DIR"
# Determine the download command based on available tools
if is_executable "git"; then
CMD="git clone $SOURCE $TARGET"
elif is_executable "curl"; then
CMD="curl -#L $TARBALL | $TAR_CMD"
elif is_executable "wget"; then
CMD="wget --no-check-certificate -O - $TARBALL | $TAR_CMD"
fi

# Clone the dotfiles repository
if ! git clone $DOTFILES_REPO $DOTFILES_DIR &> /dev/null; then
print_error "Failed to clone dotfiles repository. Please check your internet connection and try again."
# Execute the download command or abort if no tools are available
if [ -z "$CMD" ]; then
echo "No git, curl, or wget available. Aborting."
else
echo "Installing dotfiles..."
mkdir -p "$TARGET"
eval "$CMD"

# Check if install.sh exists
if [ -f "$TARGET/install.sh" ]; then
# Prompt the user for confirmation before proceeding
read -p "Do you want to continue with the installation? [y/N] " -n 1 -r
echo # Move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Running install script..."
bash "$TARGET/install.sh"
else
echo "Installation aborted by user."
exit 1
fi
else
echo "Error: install.sh not found in the dotfiles repository."
exit 1
fi
fi

# Run the installation script in the dotfiles directory
if ! bash $DOTFILES_DIR/install.sh &> /dev/null; then
print_error "Failed to install dotfiles. Please check the installation script and try again."
exit 1
fi

print_banner "You should restart your computer at this point for all the changes to take effect."
7 changes: 7 additions & 0 deletions config/.config/gh/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ pager:
# Aliases allow you to create nicknames for gh commands
aliases:
co: pr checkout
diff: pr diff
merge: pr merge
close: issue close
add: issue create --title
todo: issue create -a @me --title
mine: issue list -a @me

# The path to a unix socket through which send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport.
http_unix_socket:
# What web browser gh should use when opening URLs. If blank, will refer to environment.
Expand Down
Loading

0 comments on commit 6ce8dfa

Please sign in to comment.