0
* MyHeader
My links:

Working:
[[elisp:(term "xterm")]]

**Not working**
[[elisp:(term "xterm visidata /tmp/foo.csv")]]
  1. [X] Open xterm from org mode link
  2. [ ] Open xterm from org mode link with arguments

How can I append arguments to the terminal command?

3
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Aug 1, 2021 at 16:58
  • What about src_screen{echo "hello"} or src_bash{<something>}?
    – mankoff
    Aug 2, 2021 at 3:51
  • @mankoff I need a new frame/window opened with the cli-app launched. Offtopic: Searching emacs "src_screen" returned three (irrelevant) results :)
    – jjk
    Aug 2, 2021 at 7:59

1 Answer 1

1

I don't think term does what you think it does: if you want to open an external xterm window running visidata /tmp/foo.csv, then you want to run the elisp expression:

(shell-command "xterm -e visidata /tmp/foo.csv &")

so your link should look like [[elisp:(shell-command "xterm -e visidata /tmp/foo.csv &")]].

EDIT: as the commenters indicate, the command needs to be run asynchronously, otherwise emacs waits for the command to finish and will not do anything else. That can be done, as the OP indicates in their comment, with start-process, but it can also be done, perhaps more simply, with shell-command, by adding an & at the end of the command (see the edited code above), which is how you run a shell command in the background. C-h f shell-command has all the details.

2
  • 1
    Got infinite executing Emacs-Lisp code block.... Though you lead me to this working line: (start-process "" nil "/usr/bin/xterm" "-e" "visidata" "/tmp/foo.csv")
    – jjk
    Aug 2, 2021 at 20:12
  • 1
    I can confirm what @412p9wej mentioned: Using shell-command on an Org Mode link results in Emacs freezing, while using start-process does open a terminal window. I tried this with the following links: [[elisp:(shell-command "st")]] and [[elisp:(start-process "st" nil "st")]].
    – rdrg109
    Aug 2, 2021 at 21:08

Your Answer

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

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