gpt4 book ai didi

r - 如何将 TextMate2 中选定的文本(或一行)发送到在终端上运行的 R

转载 作者:行者123 更新时间:2023-12-04 15:01:29 25 4
gpt4 key购买 nike

如您所知,TextMate 的第 2 版即将推出,目前的开发版本非常有前途:https://github.com/textmate/textmate/blob/master/README.md

就我而言,我在终端(MacOSX Mountain Lion)中使用 R 并使用 TextMate2 开发我的代码。在之前版本的 TextMate (1.5.11) 中,我使用以下技巧将选定的文本或行发送到我的终端窗口:

-> 见 How can I send selected text (or a line) in TextMate to R running on Terminal

这个技巧对我来说非常有效,但我不知道如何使用 TextMate2 获得类似的行为。

任何的想法?我预先感谢您的宝贵帮助。

最佳答案

实际上基于之前的答案( How can I send selected text (or a line) in TextMate to R running on Terminal ),我使用以下代码在 TextMate 2 中创建了自己的 Bundle:

#!/bin/bash

source "$TM_SUPPORT_PATH/lib/bash_init.sh" # might not be necessary

# input is selection or document
rawText="$(cat | sed 's/ / /g;')"

osascript -e 'on run(theCode)' \
-e ' tell application "Terminal"' \
-e ' do script theCode in window 1' \
-e ' end tell' \
-e 'end run' -- "$rawText"

open "txmt://open?line=$(($TM_LINE_NUMBER+1))&column=1000000" &

请参阅下面的屏幕截图。

code and options for the new bundle
唯一的问题是,当您选择一段文本时,光标会跳到文档的第一行,这是一种非常烦人的行为。将“输入”从“行”更改为“选择”并不能解决问题。

有什么想法吗?

关于r - 如何将 TextMate2 中选定的文本(或一行)发送到在终端上运行的 R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13684920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com