hamacs/initialize
2026-06-22 21:36:07 -07:00

156 lines
5 KiB
Bash
Executable file

#!/usr/bin/env bash
# ----------------------------------------------------------------------
# INITIALIZE the HAMACS SYSTEM
# ----------------------------------------------------------------------
# shellcheck disable=SC2164
HAMACS_DIR=$(cd "$(dirname "$0")"; pwd)
HAMACS_DEST=$HOME/.emacs.d
cd "$HAMACS_DIR"
mkdir -p "$HAMACS_DEST"
for LINK in snippets templates elisp
do
echo "Symlinking $HAMACS_DEST/$LINK to $HAMACS_DIR/$LINK ..."
rm -rf "${HAMACS_DEST:-~}/$LINK"
ln -s "$HAMACS_DIR/$LINK" "$HAMACS_DEST"
done
echo Download the public keys:
gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40
cat > "$HAMACS_DEST/early-init.el" <<EOF
;;; early-init.el --- Hamacs Early Init -*- lexical-binding: t; -*-
;;
;; ▄████████ ▄▄▄▄███▄▄▄▄ ▄████████ ▄████████ ▄████████
;; ███ ███ ▄██▀▀▀███▀▀▀██▄ ███ ███ ███ ███ ███ ███
;; ███ █▀ ███ ███ ███ ███ ███ ███ █▀ ███ █▀
;; ▄███▄▄▄ ███ ███ ███ ███ ███ ███ ███
;; ▀▀███▀▀▀ ███ ███ ███▀███████████ ███ ▀███████████
;; ███ █▄ ███ ███ ███ ███ ███ ███ █▄ ███
;; ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄█ ███
;; ██████████ ▀█ ███ █▀ ███ █▀ ████████▀ ▄████████▀
;;
;;; Commentary:
;;
;; This is my early Emacs configuration file. See init.el for the real
;; boot process. Since we are using Quela, we need to
;; stop the normal package process.
;;
;;; Code:
;; Need the package system near the front:
(require 'package)
;; We'll be using Quelpa. So, we don't want duplicated package loading:
(setq package-enable-at-startup nil)
;; While I would rather program my configurations, sometimes the Emacs
;; menu system is _good enough_, but I want it in its own file:
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
;; Let's build the \`exec-path' from the _real_ shell path:
EOF
IFS=":" read -r -a PATH_ARRAY <<< "${PATH}"
for P in "${PATH_ARRAY[@]}"
do
echo "(add-to-list 'exec-path \"${P}\")" >> "$HAMACS_DEST/early-init.el"
done
cat >> "$HAMACS_DEST/early-init.el" <<EOF
;; Local Variables:
;; no-byte-compile: t
;; no-native-compile: t
;; no-update-autoloads: t
;; End:
;;; early-init.el ends here
EOF
echo "Created $HAMACS_DEST/early-init.el"
cat > "$HAMACS_DEST/init.el" <<EOF
;;; init.el --- Hamacs Init -*- lexical-binding: t; -*-
;;
;; :::::::::: :::: :::: ::: :::::::: ::::::::
;; :+: +:+:+: :+:+:+ :+: :+: :+: :+: :+: :+:
;; +:+ +:+ +:+:+ +:+ +:+ +:+ +:+ +:+
;; +#++:++# +#+ +:+ +#+ +#++:++#++: +#+ +#++:++#++
;; +#+ +#+ +#+ +#+ +#+ +#+ +#+
;; #+# #+# #+# #+# #+# #+# #+# #+# #+#
;; ########## ### ### ### ### ######## ########
;;
;;; Commentary:
;;
;; This is my Emacs Bootloader. Simply put, I initialize the package
;; management system, and then tangle my literate files. This simple
;; idea came from https://github.com/susamn/dotfiles
;;
;;; Code:
(defvar hamacs-source-dir "$HAMACS_DIR" "Where we be.")
;; Bug fixes for ORG (there always seems to be something):
(defvar native-comp-deferred-compilation-deny-list nil)
(add-to-list 'load-path (expand-file-name "elisp" user-emacs-directory))
(defun seq-empty-p (lst)
(= 0 (seq-length lst)))
;; Allow the installation of unsigned packages, but verify the
;; signature if possible:
(setq package-check-signature 'allow-unsigned)
;; While using Straight with direct Github repos,
;; adding Melpa and others isn't a bad idea:
(require 'use-package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives
'("elpa-dev" . "https://elpa.gnu.org/devel/"))
(setq use-package-always-ensure t)
(package-initialize)
;; Install Quelpa https://github.com/quelpa/quelpa
(unless (package-installed-p 'quelpa)
(with-temp-buffer
(url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el")
(eval-buffer)
(quelpa-self-upgrade)))
(require 'quelpa)
;; Configure Quelpa with use-package https://github.com/quelpa/quelpa-use-package
(quelpa
'(quelpa-use-package
:fetcher git
:url "https://github.com/quelpa/quelpa-use-package.git"))
(require 'quelpa-use-package)
(setq use-package-ensure-function 'quelpa)
;; Let's rock:
(org-babel-load-file "$HAMACS_DIR/bootstrap.org")
(provide 'init)
;;; init.el ends here
EOF
echo "Created $HAMACS_DEST/init.el"