1. Alain Leufroy
  2. dotconfig

Commits

Alain Leufroy  committed 86109a3

[sh] improve editor script

  • Participants
  • Parent commits 2577440
  • Branches default

Comments (0)

Files changed (1)

File sh/aliases

View file
  • Ignore whitespace
             tmux select-window -t "$tmuxemacswindowname"
         fi
     fi
-    # try to interprete args (a.k.a. "path/to/file:5980: " as given by ``grep -n``)
-    line=$(echo $1 | sed 's/: *$//' | grep -E ':[0-9]+' | sed 's/^.*:\([0-9]\+\)/\1/')
+    # try to get x selection if no args given
+    if test "x" != "x$1"; then
+        inputfile="$1"
+    else
+        inputfile="$(xclip -o)"
+    fi
+    echo $inputfile
+    # try to interprete  (a.k.a. "path/to/file:5980: " as given by ``grep -n``)
+    line=$(echo $inputfile | sed 's/: *$//' | grep -E ':[0-9]+' | sed 's/^.*:\([0-9]\+\)/\1/')
     if test "x" != "x$line"; then
-        filepath=$(echo $1 | sed 's/:.*$//' )
-        /usr/bin/emacsclient -n +$line $filepath
+        filepath=$(echo $inputfile | sed 's/:.*$//' )
+        /usr/bin/emacsclient -aemacs -s$PROJECT -n +$line $filepath
     else
-        /usr/bin/emacsclient -n $@
+        /usr/bin/emacsclient -aemacs -s$PROJECT -n $@
     fi
 }