Added edit command
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Mon, 15 Feb 2016 19:46:40 +0000 (20:46 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Mon, 15 Feb 2016 19:46:40 +0000 (20:46 +0100)
Makefile [new file with mode: 0644]
edit [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..3c5bb90
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+install:
+       install edit /bin
diff --git a/edit b/edit
new file mode 100644 (file)
index 0000000..d8e854b
--- /dev/null
+++ b/edit
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Edit files with emacsclient.
+[ "$*" ] || { echo "$0: No files given" > /dev/stderr ; exit 1; }
+if [ -n "$DISPLAY" ]
+then
+    xdotool key super+1
+    found=""
+    while [ -z "$found" ]
+    do
+       swarp 100 100
+       xprop WM_CLASS >/tmp/wmclass &
+       xdotool click 1
+       grep emacs < /tmp/wmclass > /dev/null && found=1 || xdotool key super+k
+    done 
+    pkill xprop
+    exec emacsclient --alternate-editor="" -c "$@"
+else
+    exec emacsclient --alternate-editor="" -t -c "$@"
+fi