comparison unixSoft/bin/em.sh @ 0:c30d68fbd368

Initial import from svn.
author Augie Fackler <durin42@gmail.com>
date Wed, 26 Nov 2008 10:56:09 -0600
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c30d68fbd368
1 #!/usr/bin/env bash
2
3 # desc:
4 # Allows stdin to be 'piped' to an emacs server.
5 #
6 # options:
7 # none
8 #
9 # usage:
10 # $ echo "hello there" | emacsclientw.sh
11 # $ cat ~/.emacs | emacsclientw.sh
12 # $ emacsclientw.sh ~/.emacs
13 #
14 # author:
15 # Phil Jackson (phil@shellarchive.co.uk)
16
17 unset DISPLAY
18
19 tmp_file="$(mktemp /tmp/emacs.tmp.XXXXX)"
20 lisp_to_accept_file="(~/unixSoft/emacs/fake-stdin-slurp.el \"${tmp_file}\")"
21
22 if [ ! -t 0 ]; then
23 cat > "${tmp_file}"
24
25 emacsclient -a emacs -e "${lisp_to_accept_file}" ${@}
26
27 if [ ${?} -ne 0 ]; then
28 echo "failed: your input was saved in '${tmp_file}'"
29 else
30 rm -f "${tmp_file}"
31 fi
32 else
33 # nothing from stdin
34 emacsclient -n -a emacs ${@}
35 fi