From 546a3a211a0d59f14edbd97c1990476e84a46247 Mon Sep 17 00:00:00 2001 From: Raul Benencia Date: Sun, 24 May 2020 13:44:14 -0700 Subject: Add bin/ repo from home-bin/ repo --- bin/emacs-pkg-install | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 bin/emacs-pkg-install (limited to 'bin/emacs-pkg-install') 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` ..." + 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" -- cgit v1.2.3