So in my rifle.conf I have
ext org, has emacs, terminal, flag f = emacs "$@"
However it opens the file with the GUI version of emacs? How do I open it with 'emacs -nw filename'?
CodePudding user response:
I tried what Tom had said but I found that there were too many steps to open my org file. I wanted to be able to just press enter on an orgfile within ranger and have it open emacs -nw file.org, within the tmux pane running ranger.
The following solved my dilemma:
!mime ^text, label editor, ext org = emacs -nw -- "$@"
CodePudding user response:
Edit: Interesting dig - after a look at OPs solution above: It turns out ranger does indeed open a terminal program 'on top of itself', so to speak.
The culprit in OPs first attempt is the flag f
, in fact the minimal
ext org = emacs -nw "$@"
works like a charm.
Old attempts:
As far as I read the docs, you cannot open a file with a program running in the same terminal as ranger itself is running in (I may be wrong, though).
Following the documentation I exported TERMCMD
, since I'm using tmux with TERM=screen-256color
, ranger
cannot infer the terminal to use from that:
# just a test, I don't use xterm
export TERMCMD=xterm
And simply added the t
flag and -nw
to the command in rifle.conf
:
❯ cat ~/.config/ranger/rifle.conf
ext org, has emacs, terminal, flag tf = emacs -nw "$@"
Hitting r
in ranger
0 | emacs -nw "$@"
:open_with 0
This opens a new xterm, starting a new emacs editing the file in question. You can simply press the Return
key while on the file in question with this setup; using r
would show all available options.
If you are living in the terminal and don't want to start another graphical terminal, I suggest using something like tmux - you can use tmux commands to open files, in this case like so
ext org, has emacs, terminal, flag f = tmux splitw -h emacs -nw "$@"
splitting the current pane (with ranger running), launching a new pane to the right of the current one and starting emacs there. The pane will be closed when you quit emacs. I'd probably start an emacsserver and use emacsclient -nw
in this scenario.