Skip to content

Commit 2f7f264

Browse files
committed
✨ functions
1 parent 49e8207 commit 2f7f264

File tree

11 files changed

+376
-181
lines changed

11 files changed

+376
-181
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
cache/
2-
macos/Brewfile.lock.json
2+
macos/*.lock.json

Makefile

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
SHELL := /bin/bash
22
OS := $(shell uname -s)
3-
GIT := git
4-
HATCH := hatch
53

6-
.PHONY: help
7-
help:
8-
@echo "Usage: make [TARGET] ..."
9-
@echo ""
10-
@echo "Targets:"
11-
@echo " bootstrap Initialize the project by running the bootstrap script."
12-
@echo " deps Install dependencies for the project based on the OS."
13-
@echo " docs Serve the documentation locally."
14-
@echo " fmt Run pre-commit hooks on all files."
15-
@echo " help Show this help message."
16-
@echo " sync Update the project and its submodules."
4+
##@ dotfiles
175

186
.PHONY: bootstrap
19-
bootstrap:
7+
bootstrap: ## Initialize the project by running the bootstrap script.
208
$(SHELL) ./bootstrap/bootstrap.sh
219

2210
.PHONY: deps
23-
deps:
11+
deps: ## Install dependencies for the project based on the OS.
2412
ifeq ($(OS),Linux)
2513
$(SHELL) ./bin/aptfile ./linux/Aptfile
2614
else ifeq ($(OS),Darwin)
@@ -30,13 +18,31 @@ else
3018
endif
3119

3220
.PHONY: sync
33-
sync:
34-
$(GIT) pull --recurse-submodules --jobs=4
21+
sync: ## Update the project and its submodules.
22+
git pull --recurse-submodules --jobs=4
23+
24+
##@ development
3525

3626
.PHONY: fmt
37-
fmt:
27+
fmt: ## Run pre-commit hooks on all files.
3828
pre-commit run --all-files
3929

4030
.PHONY: docs
41-
docs:
42-
$(HATCH) run docs:serve --livereload
31+
docs: ## Serve the documentation locally.
32+
hatch run docs:serve --livereload
33+
34+
##@ general
35+
36+
.PHONY: version
37+
version: ## Show the version of the project.
38+
@echo "dotfiles $$(git describe --tags --abbrev=0)"
39+
40+
.DEFAULT_GOAL := help
41+
.PHONY: help
42+
help: ## Show this help message and exit.
43+
################################################
44+
# Auto-Generated Help:
45+
# - "##@" denotes a target category
46+
# - "##" denotes a specific target description
47+
###############################################
48+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

bin/now

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
#
4+
# See what 'read -t' returns on timeout.
5+
#
6+
# For that - read from stdout. Alternatively, it could read
7+
# from /dev/zero, but it's not available under Cygwin and
8+
# in other non-*nix environments.
9+
#
10+
# Also note, that while bash manual states that the return
11+
# code on a timeout is greater than 128, it doesn't hold
12+
# true with a number of bash implementations, most notably
13+
# including GNU bash that returns 1 instead.
14+
#
15+
read -t 1 <&1
16+
timeout=$?
17+
18+
#
19+
# loop forever
20+
#
21+
while true; do
22+
#
23+
# relay stdin to stdout
24+
#
25+
while true; do
26+
IFS= read -r -t 1 line
27+
rc=$?
28+
if [ $rc != 0 ]; then break; fi
29+
echo "$line"
30+
done
31+
#
32+
# exit status is greater than 128 if the timeout is exceeded
33+
#
34+
if [ $rc != $timeout ]; then break; fi
35+
36+
#
37+
# print the timestamp
38+
#
39+
now=$(date ${1:++"$1"})
40+
echo -ne "$now\r" >&2
41+
done

bootstrap/bootstrap.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,22 @@ function log_event() {
185185
LOGGING_TIMESTAMP="${BLUE}$(date +"%F %T,000")${NO_COLOR}"
186186
case "${1}" in
187187
"info")
188-
echo -e "${LOGGING_TIMESTAMP} ${GREEN}INFO: ${NO_COLOR}${2}"
188+
echo -e "${LOGGING_TIMESTAMP} ${GREEN}[ INFO]: ${NO_COLOR}${2}"
189189
;;
190190
"error")
191-
echo -e "${LOGGING_TIMESTAMP} ${RED}ERROR: ${NO_COLOR}${2}"
191+
echo -e "${LOGGING_TIMESTAMP} ${RED}[ ERROR]: ${NO_COLOR}${2}"
192192
;;
193193
"warning")
194-
echo -e "${LOGGING_TIMESTAMP} ${ORANGE}WARNING: ${NO_COLOR}${2}"
194+
echo -e "${LOGGING_TIMESTAMP} ${ORANGE}[ WARNING]: ${NO_COLOR}${2}"
195+
;;
196+
"debug")
197+
echo -e "${LOGGING_TIMESTAMP} ${PURPLE}[ DEBUG]: ${NO_COLOR}${2}"
198+
;;
199+
"critical")
200+
echo -e "${LOGGING_TIMESTAMP} ${RED}[CRITICAL]: ${NO_COLOR}${2}"
195201
;;
196202
*)
197-
echo -e "${LOGGING_TIMESTAMP} ${PURPLE}${1}: ${NO_COLOR}${2}"
203+
echo -e "${LOGGING_TIMESTAMP} ${GREEN}[ INFO]: ${NO_COLOR}${1}"
198204
;;
199205
esac
200206
}
@@ -267,12 +273,7 @@ function symlink_item() {
267273

268274
function symlink_shell() {
269275
symlink_item "${DOTFILES_DIR}/shell/.shell_aliases" "${HOME}/.shell_aliases"
270-
}
271-
272-
function symlink_mac() {
273-
if [[ $(uname) == "Darwin" ]]; then
274-
symlink_item "${DOTFILES_DIR}/shell/.mac_aliases" "${HOME}/.mac_aliases"
275-
fi
276+
symlink_item "${DOTFILES_DIR}/shell/.shell_functions" "${HOME}/.shell_functions"
276277
}
277278

278279
function symlink_zsh() {
@@ -306,6 +307,7 @@ function symlink_misc() {
306307

307308
function symlink_bin() {
308309
symlink_item "${DOTFILES_DIR}/bin/has" "/usr/local/bin/has"
310+
symlink_item "${DOTFILES_DIR}/bin/now" "/usr/local/bin/now"
309311
if [[ $(uname) == "Linux" ]]; then
310312
symlink_item "${DOTFILES_DIR}/bin/aptfile" "/usr/local/bin/aptfile"
311313
fi
@@ -318,7 +320,6 @@ function symlink_tools() {
318320

319321
function symlink_dotfiles() {
320322
symlink_shell
321-
symlink_mac
322323
symlink_zsh
323324
symlink_bash
324325
symlink_git

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ the steps below:
6767
ln -s ~/.dotfiles/shell/.profile ~/.profile
6868
# SHELL
6969
ln -s ~/.dotfiles/shell/.shell_aliases ~/.shell_aliases
70-
ln -s ~/.dotfiles/shell/.mac_aliases ~/.mac_aliases
70+
ln -s ~/.dotfiles/shell/.shell_functions ~/.shell_functions
7171
# PYENV
7272
ln -s ~/.dotfiles/bootstrap/pyenv ~/.pyenv
7373
# GIT

macos/Brewfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ tap "hashicorp/tap"
66
tap "homebrew/bundle"
77
tap "homebrew/cask-fonts"
88
tap "homebrew/services"
9+
tap "derailed/k9s"
910

1011
##########################################################
1112
####################### UTILITIES ########################
1213
##########################################################
1314

15+
brew "asdf"
1416
brew "awsume"
17+
brew "aws-sso-util"
18+
brew "ca-certificates"
19+
brew "checkov"
1520
brew "curl"
1621
brew "direnv"
1722
brew "ffmpeg"
@@ -26,14 +31,18 @@ brew "helm"
2631
brew "htop"
2732
brew "hugo"
2833
brew "jq"
34+
brew "k9s"
2935
brew "make"
3036
brew "neovim"
3137
brew "node"
3238
brew "openjdk"
3339
brew "pipx"
40+
brew "pre-commit"
3441
brew "ripgrep"
42+
brew "sops"
3543
brew "terraform"
3644
brew "terragrunt"
45+
brew "tmate"
3746
brew "thefuck"
3847
brew "tree"
3948
brew "wget"
@@ -50,8 +59,9 @@ cask "docker"
5059
cask "hammerspoon"
5160
cask "iterm2"
5261
cask "lens"
62+
cask "ngrok"
5363
cask "spotify"
54-
cask "syntax-highlight"
64+
cask "syntax-highlight", args: { no_quarantine: true }
5565
cask "vlc"
5666

5767
##########################################################

macos/XBrewfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
##########################################################
2+
######################### TAPS ###########################
3+
##########################################################
4+
5+
tap "homebrew/bundle"
6+
7+
##########################################################
8+
######################## PYTHON ##########################
9+
##########################################################
10+
11+
brew "python@3.8"
12+
brew "python@3.9"
13+
brew "python@3.10"
14+
brew "python@3.11"
15+
brew "python@3.12"

shell/.mac_aliases

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)