[英]create a keyboard shortcut to an R function on mac?
I would like to create a keyboard shortcut to run an R function in an existing R session. 我想创建一个键盘快捷方式来在现有的R会话中运行R函数。 How can I do this on a Mac?
我怎么能在Mac上这样做?
My first idea was to use 我的第一个想法是使用
% R --slave < foo.R %R --slave <foo.R
and create a keyboard-shortcut to a shell script with this command. 并使用此命令创建shell脚本的键盘快捷方式。
But this starts a new R session. 但是这会开始一个新的R会话。 Is there a way to send a command to an existing session from shell?
有没有办法从shell发送命令到现有会话?
I can think of two similar ways to do this; 我可以想到两种类似的方法来做到这一点; neither is necessarily elegant, but both get the job done.
既不一定优雅,但都能完成工作。
Run a tmux session which consists solely of an R session, and write a script that uses tmux send-keys
to send your command. 运行仅包含R会话的tmux会话,并编写一个使用
tmux send-keys
发送命令的脚本。
Similarly, you could set up a dedicated iTerm2 session to receive the keys. 同样,您可以设置专用的iTerm2会话来接收密钥。 If you were in iTerm2 already, you could set up a keyboard shortcut to send your command.
如果您已经在iTerm2中,则可以设置键盘快捷方式来发送命令。 Outside iTerm2, I think you're looking at some applescript.
在iTerm2之外,我想你正在看一些苹果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.