Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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