This is a bit of a long shot, but I'm going to ask anyway. Kinda similar to what dired-at-point and find-file-at-point

When point is inside a .txt file on a line like this

ls -la /tmp/

When point is at the beginning of that line, is there something like shell-command-at-point where the shell command on that line is executed and the output is displayed in the echo area? The other way to do it is I guess to yank the line, M-| paste RET.

I think Org mode has this feature [[shell:ls -la /tmp/][example], but I'm looking for a general purpose solution.

1 Answer 1


You can use this with point anywhere on the line. If you really need a command that acts only on the rest of the line, starting at point, then substitute (point) for (line-beginning-position).

(defun foo (&optional output-buffer error-buffer)
  (let ((strg  (buffer-substring-no-properties (line-beginning-position) 
    (shell-command strg output-buffer error-buffer)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.