Skip to content

Instantly share code, notes, and snippets.

@cmattoon
Last active October 16, 2023 12:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmattoon/15ebc2eed8d14828166e to your computer and use it in GitHub Desktop.
Save cmattoon/15ebc2eed8d14828166e to your computer and use it in GitHub Desktop.
Easy install emacs web-mode
#!/bin/bash
## INSTALL:
##
## 1A) git clone <GIT_URL> web_mode_gist && cd web_mode_gist
## OR
## 1B) wget <RAW_URL>
## 2. chmod +x emacs-web-mode.sh
## 3. ./emacs-web-mode.sh
##
EMACS="${HOME}/.emacs"
EMACS_DIR="${HOME}/.emacs.d/"
ELISP_DIR="${HOME}/.emacs.d/includes"
touch $EMACS
output() {
echo -e "\033[32m${1}\033[0m"
}
if [ ! -d "${EMACS_DIR}" ]; then
output "Can't find directory ${EMACS_DIR}...Creating it now..."
mkdir -p "${EMACS_DIR}"
fi
if [ ! -d "${ELISP_DIR}" ]; then
output "Can't find directory ${ELISP_DIR}...Creating it now..."
mkdir -p "${ELISP_DIR}"
fi
wget https://raw.githubusercontent.com/fxbois/web-mode/master/web-mode.el -O "${ELISP_DIR}/web-mode.el"
output "Backing up ${EMACS} to ${EMACS}.bak"
cp "${EMACS}" "${EMACS}.bak"
echo "(setq-default indent-tabs-mode nil)" >> $EMACS # Use spaces, not tabs
echo "(setq standard-indent 4)" >> $EMACS ## 4 spaces per 'tab'
echo "(add-to-list 'load-path \"~/.emacs.d/includes/\")" >> $EMACS
echo "(require 'web-mode)" >> $EMACS
echo "(add-to-list 'auto-mode-alist '(\"\\\\.php\\\\'\" . web-mode))" >> $EMACS
echo "(add-to-list 'auto-mode-alist '(\"\\\\.tpl\\.\\\\.php\\\\'\" . web-mode))" >> $EMACS
echo "" >> $EMACS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment