emacsq.sh 867 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. DATE="$(date +%F_%H%M%S)"
  4. SCRIPT_NAME="${0##*/}"
  5. LOG_DIR="${HOME}/.local/share/logs"
  6. LOG_FILE="${LOG_DIR}/${SCRIPT_NAME%%.sh}_${DATE}.log"
  7. display_help() {
  8. error_message="$*"
  9. [[ -n ${error_message:} ]] && echo -e "Error: ${error_message}\n"
  10. cat <<EOF
  11. Description: Launch emacs -Q with littering enabled to not clutter emacs home
  12. Usage: ${SCRIPT_NAME} [optional arg/s] <mandatory arg/s>
  13. Dependencies: emacs no-littering
  14. Examples:
  15. - ${SCRIPT_NAME}
  16. EOF
  17. exit 2
  18. }
  19. message(){
  20. info="$*"
  21. echo "==== $(date +'%F_%H%M%S') ==== ${info} ====" | tee -a "$LOG_FILE"
  22. }
  23. LIB_DIR="${EMACS_CONFIG_DIR}/elpa"
  24. mapfile -t libs < <(find "$LIB_DIR" -maxdepth 1 -type d -regex '.*\(no-littering\|compat\).*')
  25. message "launching emacs with loaded libraries: ${libs[*]}"
  26. emacs -Q -L "${libs[0]}" -L "${libs[1]}" -l no-littering