aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2025-11-01 21:25:17 -0400
committerEugene Triguba <hello@eugenetriguba.com>2025-11-01 21:25:17 -0400
commitfe351483777c8d053d9f8b584278a4c2b162db0e (patch)
tree15af9419e315bfad090c940be4a61625bf785876
parentMove /usr/local/bin farther up the path (diff)
downloaddotfiles-fe351483777c8d053d9f8b584278a4c2b162db0e.zip
Update install scripts for macos and linux and use sh
-rw-r--r--.editorconfig9
-rw-r--r--.shellcheckrc1
-rwxr-xr-xinstall.sh107
-rw-r--r--nvim/.config/nvim/lazy-lock.json36
-rw-r--r--shlib/bootstrap.sh29
-rw-r--r--shlib/homebrew.sh20
-rw-r--r--shlib/log.sh47
-rw-r--r--shlib/os.sh15
-rw-r--r--shlib/prompt.sh23
-rw-r--r--shlib/tmux.sh30
10 files changed, 215 insertions, 102 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..fea827c
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*.sh]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = space
+indent_size = 2
diff --git a/.shellcheckrc b/.shellcheckrc
new file mode 100644
index 0000000..be2cf38
--- /dev/null
+++ b/.shellcheckrc
@@ -0,0 +1 @@
+source-path=shlib
diff --git a/install.sh b/install.sh
index 4c1033f..96b8fa8 100755
--- a/install.sh
+++ b/install.sh
@@ -1,23 +1,27 @@
#!/bin/sh
-#
-# Install the Homebrew Brewfile and setup symbolic links to the
-# dotfiles.
set -e
+. "$(dirname "$0")/shlib/bootstrap.sh"
+. "$(dirname "$0")/shlib/log.sh"
+. "$(dirname "$0")/shlib/os.sh"
+. "$(dirname "$0")/shlib/tmux.sh"
+
main() {
- if ! command -v brew >/dev/null 2>&1; then
- if prompt_for_confirmation "Homebrew not found. Would you like to install Homebrew?"; then
- install_homebrew
- else
- echo "Exiting, can't continue without Homebrew installed."
- exit 0
+ if os_is_macos; then
+ if ! bootstrap_macos; then
+ log_error "Failed to bootstrap install script"
+ exit 1
+ fi
+ elif os_is_linux; then
+ if ! bootstrap_linux; then
+ log_error "Failed to bootstrap install script"
+ exit 1
fi
+ else
+ log_error "Unexpected OS: $(os_print)"
+ exit 1
fi
- echo "Found homebrew installation. Installing Brewfile.."
- (cd homebrew && brew bundle)
- echo "Brewfile successfully installed. Moving to linking dotfiles.."
-
stow executables
stow nvim
stow zsh
@@ -30,81 +34,16 @@ main() {
stow msmtp
stow atuin
stow lazygit
- echo "Successfully linked all dotfiles."
+ log_success "Successfully linked all dotfiles."
mkdir -p ~/Mail/Gmail/INBOX ~/Mail/iCloud/INBOX ~/bin/ ~/src/
- sudo ln -sf "$HOME/bin/get-password" /usr/local/bin/get-password
- sudo ln -sf "$(which op)" /usr/local/bin/op
-
- echo "Initializing TPM (Tmux Plugin Manager)..."
- setup_tpm
-
- echo "Setup complete!"
-}
-
-# Prompt the user for confirmation on an action.
-#
-# Args:
-# $1: The question to prompt for. Answer choices
-# will be added onto the end.
-#
-# Returns:
-# 0 on yes. 1 on no.
-prompt_for_confirmation() {
- printf "%s [y/n]: " "$1"
- read -r answer
- if [ "$answer" != "${answer#[Yy]}" ]; then
- return 0
- else
- return 1
- fi
-}
-# Installs homebrew and verifies the installation.
-#
-# If the install was not successful, exits with a
-# 1 status code.
-install_homebrew() {
- /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
- # shellcheck disable=SC2016
- echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >>"$HOME/.zprofile"
- eval "$(/opt/homebrew/bin/brew shellenv)"
-
- if ! command -v brew >/dev/null 2>&1; then
- echo "Failed to install homebrew"
+ log_info "Initializing TPM (Tmux Plugin Manager)..."
+ if ! tmux_setup_tpm; then
+ log_error "Failed to setup tpm"
exit 1
fi
+ log_success "Setup complete!"
}
-setup_tpm() {
- tpm_dir="$HOME/.config/tpm/plugins/tpm"
- if [ ! -d "$tpm_dir" ]; then
- echo "Cloning TPM..."
- git clone https://github.com/tmux-plugins/tpm "$tpm_dir"
- else
- echo "TPM already exists, updating..."
- (cd "$tpm_dir" && git pull)
- fi
-
- if command -v tmux >/dev/null 2>&1; then
- echo "Installing tmux plugins..."
- # Start a tmux server in the background and install plugins
- tmux start-server
- tmux new-session -d -s tpm_install
- tmux send-keys -t tpm_install "$tpm_dir/scripts/install_plugins.sh" Enter
-
- # Wait a moment for plugins to install
- sleep 3
-
- # Kill the temporary session
- tmux kill-session -t tpm_install 2>/dev/null || true
-
- echo "TPM plugins installed successfully."
- else
- echo "Warning: tmux not found. TPM cloned but plugins not installed."
- echo "Run 'tmux' and then press 'prefix + I' to install plugins manually."
- fi
-}
-
-main
+main "$@"
diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json
index 1d8720f..e9d4a25 100644
--- a/nvim/.config/nvim/lazy-lock.json
+++ b/nvim/.config/nvim/lazy-lock.json
@@ -3,40 +3,40 @@
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
"barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" },
"blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" },
- "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" },
- "conform.nvim": { "branch": "master", "commit": "fbcb4fa7f34bfea9be702ffff481a8e336ebf6ed" },
+ "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" },
+ "conform.nvim": { "branch": "master", "commit": "2dae54343f3c3fe31b3058188684dcd903e9d00f" },
"copilot.lua": { "branch": "master", "commit": "92e08cd472653beaece28ad9c8508a851a613358" },
- "fidget.nvim": { "branch": "main", "commit": "3f5475949679953af6d78654db29b944fa826e6a" },
+ "fidget.nvim": { "branch": "main", "commit": "2cb5edb2dd6700a958a446b20bb2be04d318da9d" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
- "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" },
+ "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" },
"harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
- "lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" },
- "lazydev.nvim": { "branch": "main", "commit": "e28ce52fc7ff79fcb76f0e79ee6fb6182fca90b9" },
- "lazygit.nvim": { "branch": "main", "commit": "2305deed25bc61b866d5d39189e9105a45cf1cfb" },
+ "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
+ "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
+ "lazygit.nvim": { "branch": "main", "commit": "3c524ebec6072568064235c407195e9f9fd0cb8a" },
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
- "mason-lspconfig.nvim": { "branch": "main", "commit": "6bdb14f230de0904229ec367b410fb817e59b072" },
+ "mason-lspconfig.nvim": { "branch": "main", "commit": "1ec4da522fa49dcecee8d190efda273464dd2192" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" },
- "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
- "mini.icons": { "branch": "main", "commit": "284798619aed9f4c1ac1b9417b9a5e3b4b85ef3a" },
- "mini.nvim": { "branch": "main", "commit": "6a224ddd28b4b21a488d6d87e1c2643a029caaa4" },
+ "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" },
+ "mini.icons": { "branch": "main", "commit": "b8f6fa6f5a3fd0c56936252edcd691184e5aac0c" },
+ "mini.nvim": { "branch": "main", "commit": "5d938b3a078a7eeae23ba9f04f180066ab8bd9ef" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-dap": { "branch": "master", "commit": "881f7dc17c0b4204a1d844732f95539575350e5b" },
"nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" },
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
- "nvim-lint": { "branch": "master", "commit": "9da1fb942dd0668d5182f9c8dee801b9c190e2bb" },
- "nvim-lspconfig": { "branch": "master", "commit": "ac98db2f9f06a56498ec890a96928774eae412c3" },
+ "nvim-lint": { "branch": "master", "commit": "7ef127aaede2a4d5ad8df8321e2eb4e567f29594" },
+ "nvim-lspconfig": { "branch": "master", "commit": "34c9ecfdcc19d579f51c072300a71445fbec9da8" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
- "nvim-treesitter-context": { "branch": "master", "commit": "41847d3dafb5004464708a3db06b14f12bde548a" },
- "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" },
- "oil.nvim": { "branch": "master", "commit": "919e155fdf38e9148cdb5304faaaf53c20d703ea" },
+ "nvim-treesitter-context": { "branch": "master", "commit": "dca8726fea2c14e1ce6adbaa76a04816fbfaff61" },
+ "nvim-web-devicons": { "branch": "master", "commit": "c2599a81ecabaae07c49ff9b45dcd032a8d90f1a" },
+ "oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
- "tokyonight.nvim": { "branch": "main", "commit": "d14614cbfc63b6037bfccd48bb982d2ad2003352" },
+ "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
"trouble.nvim": { "branch": "main", "commit": "c098362fe603d3922095e7db595961e020bdf2d0" },
"vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" },
- "which-key.nvim": { "branch": "main", "commit": "b4177e3eaf15fe5eb8357ebac2286d488be1ed00" }
+ "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
}
diff --git a/shlib/bootstrap.sh b/shlib/bootstrap.sh
new file mode 100644
index 0000000..b2d6bb9
--- /dev/null
+++ b/shlib/bootstrap.sh
@@ -0,0 +1,29 @@
+# shellcheck shell=sh
+[ -n "${DOTFILES_BOOTSTRAP_LOADED}" ] && return
+readonly DOTFILES_BOOTSTRAP_LOADED=1
+
+. "$(dirname "$0")/shlib/homebrew.sh"
+. "$(dirname "$0")/shlib/log.sh"
+. "$(dirname "$0")/shlib/prompt.sh"
+
+bootstrap_macos() {
+ if ! homebrew_is_installed; then
+ if prompt_for_confirmation "Homebrew not found. Would you like to install Homebrew?"; then
+ homebrew_install
+ else
+ log_error "Cannot continue without homebrew installed."
+ return 1
+ fi
+ fi
+
+ log_info "Found homebrew installation. Installing Brewfile.."
+ (cd homebrew && brew bundle)
+ log_info "Brewfile successfully installed. Moving to linking dotfiles.."
+
+ sudo ln -sf "$HOME/bin/get-password" /usr/local/bin/get-password
+ sudo ln -sf "$(which op)" /usr/local/bin/op
+}
+
+bootstrap_linux() {
+ return 0
+}
diff --git a/shlib/homebrew.sh b/shlib/homebrew.sh
new file mode 100644
index 0000000..a00ad73
--- /dev/null
+++ b/shlib/homebrew.sh
@@ -0,0 +1,20 @@
+# shellcheck shell=sh
+[ -n "${DOTFILES_HOMEBREW_LOADED}" ] && return
+readonly DOTFILES_HOMEBREW_LOADED=1
+
+homebrew_is_installed() {
+ command -v brew >/dev/null 2>&1
+}
+
+# Installs homebrew and verifies the installation.
+#
+# If the install was not successful, exits with a
+# 1 status code.
+homebrew_install() {
+ /usr/bin/env bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+ eval "$(/opt/homebrew/bin/brew shellenv)"
+ if ! command -v brew >/dev/null 2>&1; then
+ echo "Failed to install homebrew"
+ return 1
+ fi
+}
diff --git a/shlib/log.sh b/shlib/log.sh
new file mode 100644
index 0000000..3fcf758
--- /dev/null
+++ b/shlib/log.sh
@@ -0,0 +1,47 @@
+# shellcheck shell=bash
+[[ -n "${DOTFILES_LOG_LOADED:-}" ]] && return
+readonly DOTFILES_LOG_LOADED=1
+
+log_info() {
+ echo "[INFO] $*" >&2
+}
+
+log_error() {
+ echo "[ERROR] $*" >&2
+}
+
+log_warn() {
+ echo "[WARN] $*" >&2
+}
+
+log_success() {
+ echo "[SUCCESS] $*" >&2
+}
+
+log_debug() {
+ [[ "${DEBUG:-}" == "true" ]] && echo "[DEBUG] $*" >&2
+}
+
+log_newline() {
+ echo "" >&2
+}
+
+log_header() {
+ echo "=== $* ===" >&2
+}
+
+log_step() {
+ echo "→ $*" >&2
+}
+
+log_substep() {
+ echo " • $*" >&2
+}
+
+log_progress() {
+ printf "." >&2
+}
+
+log_progress_end() {
+ echo "" >&2
+}
diff --git a/shlib/os.sh b/shlib/os.sh
new file mode 100644
index 0000000..1ac4f04
--- /dev/null
+++ b/shlib/os.sh
@@ -0,0 +1,15 @@
+# shellcheck shell=sh
+[ -n "${DOTFILES_OS_LOADED}" ] && return
+readonly DOTFILES_OS_LOADED=1
+
+os_print() {
+ uname
+}
+
+os_is_macos() {
+ [ "$(os_print)" = "Darwin" ]
+}
+
+os_is_linux() {
+ [ "$(os_print)" = "Linux" ]
+}
diff --git a/shlib/prompt.sh b/shlib/prompt.sh
new file mode 100644
index 0000000..6a63db0
--- /dev/null
+++ b/shlib/prompt.sh
@@ -0,0 +1,23 @@
+# shellcheck shell=sh
+[ -n "${DOTFILES_PROMPT_LOADED}" ] && return
+readonly DOTFILES_PROMPT_LOADED=1
+
+# Prompt the user for confirmation on an action.
+#
+# Args:
+# $1: The question to prompt for. Answer choices
+# will be added onto the end.
+#
+# Returns:
+# 0 on yes. 1 on no.
+prompt_for_confirmation() {
+ (
+ printf "%s [y/n]: " "$1"
+ read -r answer
+ if [ "$answer" != "${answer#[Yy]}" ]; then
+ return 0
+ else
+ return 1
+ fi
+ )
+}
diff --git a/shlib/tmux.sh b/shlib/tmux.sh
new file mode 100644
index 0000000..c8870f5
--- /dev/null
+++ b/shlib/tmux.sh
@@ -0,0 +1,30 @@
+# shellcheck shell=sh
+[ -n "${DOTFILES_TMUX_LOADED}" ] && return
+readonly DOTFILES_TMUX_LOADED=1
+
+. "$(dirname "$0")/shlib/log.sh"
+
+tmux_setup_tpm() {
+ (
+ tpm_dir="$HOME/.config/tpm/plugins/tpm"
+ if [ ! -d "$tpm_dir" ]; then
+ log_info "Cloning TPM..."
+ if ! git clone https://github.com/tmux-plugins/tpm "$tpm_dir"; then
+ log_error "Failed to clone tpm to $tpm_dir"
+ return 1
+ fi
+ else
+ log_info "TPM already exists, updating..."
+ (cd "$tpm_dir" && git pull)
+ fi
+
+ if command -v tmux >/dev/null 2>&1; then
+ log_info "Installing tmux plugins..."
+ "$tpm_dir/scripts/install_plugins.sh"
+ log_info "TPM plugins installed successfully."
+ else
+ log_warn "tmux not found. TPM cloned but plugins not installed."
+ log_warn "Run 'tmux' and then press 'prefix + I' to install plugins manually."
+ fi
+ )
+}