blob: 93b747fbce6de3fc047e6cdb85c5b93d07418c6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/bash
# Gotten from: https://gist.github.com/padawanphysicist/d6299870de4ef8ad892f
#
# I wrapped the code constructed in
#
# http://hacks-galore.org/aleix/blog/archives/2013/01/08/install-emacs-packages-from-command-line
#
# in a single bash script, so I would a single code snippet.
#
# Elisp script is created as a temporary file, to be removed after installing
# the package
elisp_script_name=$(mktemp /tmp/emacs-pkg-install-el.XXXXXX)
elisp_code="
;;
;; Install package from command line. Example:
;;
;; $ emacs --batch --expr \"(define pkg-to-install 'smex)\" -l emacs-pkg-install.el
;;
(require 'package)
(package-initialize)
(add-to-list 'package-archives
'(\"melpa\" . \"http://melpa.milkbox.net/packages/\") t)
;;(add-to-list 'package-archives
;; '(\"marmalade\" . \"http://marmalade-repo.org/packages/\") t)
;; Fix HTTP1/1.1 problems
(setq url-http-attempt-keepalives nil)
(package-refresh-contents)
(package-install pkg-to-install)"
echo "$elisp_code" > $elisp_script_name
if [ $# -lt 1 ]
then
echo "Usage: `basename $0` <package 1> <package 2> ..."
exit 1
fi
for pkg_name in $@; do
emacs --batch --eval "(defconst pkg-to-install '$pkg_name)" -l $elisp_script_name
done
# Remove tmp file
rm "$elisp_script_name"
|