aboutsummaryrefslogtreecommitdiff
path: root/bin/emacs-pkg-install
diff options
context:
space:
mode:
authorRaul Benencia <rul@kalgan.cc>2020-05-24 13:44:14 -0700
committerRaul Benencia <rul@kalgan.cc>2020-05-24 13:47:59 -0700
commit546a3a211a0d59f14edbd97c1990476e84a46247 (patch)
treec5709cc4a8f7b0f39e1cb023f0f6b03bf749272e /bin/emacs-pkg-install
parent3589f3e66769e87831e9f31fb3493064dd3ce73e (diff)
Add bin/ repo from home-bin/ repo
Diffstat (limited to 'bin/emacs-pkg-install')
-rwxr-xr-xbin/emacs-pkg-install45
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/emacs-pkg-install b/bin/emacs-pkg-install
new file mode 100755
index 0000000..93b747f
--- /dev/null
+++ b/bin/emacs-pkg-install
@@ -0,0 +1,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"
nihil fit ex nihilo