RStudio終端操作

轉於:https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal#send

原文是英文版。

1. 簡介

RStudio終端提供從RStudio IDE內部訪問系統shell的功能。它支持xterm仿真,支持使用全屏終端應用程序以及具有行編輯和shell歷史記錄的常規命令行操作。

shell有許多潛在的用途,包括高級源代碼控制操作、長時間運行的作業的執行、遠程登錄、RStudio服務器的系統管理以及前面提到的全屏終端程序。

2. 入門

Shift+Alt+R新建

Code→Send to Terminal(Ctrl+Alt+Enter)將代碼發送到終端

在控制檯旁邊。

Shift+Alt+R新建終端窗口。

每個終端會話都是獨立的,有自己的系統外殼進程和緩衝區。通過(1)使用下拉菜單旁邊的箭頭,(2)在下拉菜單中單擊終端名稱,或(3)使用Previous/Next Terminal下拉菜單命令,在它們之間進行切換。下拉按鈕顯示當前選擇的終端會話的名稱(以下截圖中的“Terminal3”):

在RStudio編輯器中編輯文件時,可以通過Ctrl+Alt+Enter將任何選擇(如果沒有選中任何內容,則當前行)發送到活動終端。如果將單行發送到終端,光標將自動前進到下一行,允許單步執行。

比如,可以在終端中執行python語句。

如果正在編輯shell文件(*.sh),可以使用Ctrl+Enter單步執行,運行工具欄按鈕也是如此。

3. 關閉

要關閉終端會話,可以使用終端下拉菜單中的Close Terminal命令,單擊終端窗格工具欄右側的[x],或者在shell本身中鍵入exit。

如果終端當前處於繁忙狀態,[x]將更改爲stop按鈕。點擊stop按鈕將觸發中斷當前終端命令,向終端發送一箇中斷;這可能會關閉當前正在運行的程序(當接收到中斷時,程序本身決定要做什麼),但是不會關閉Terminal。

4. 編輯

將Terminal Shell的內容放在文本文檔中便於編輯和複用,

5. 命令和快捷鍵

Command Shortcut Drop-down Tools/Terminal Description
Clear Terminal
Buffer

Ctrl+Shift+L

(also Ctrl+L
when terminal
has focus)

Yes Yes Clears full terminal buffer
Close Terminal   Yes Yes Close current terminal
session
Copy Terminal to
Editor
  Yes Yes Send terminal buffer to
a new editor document
Move Focus to
Terminal
Shift+Alt+T No Yes
(also on
View menu)
Move keyboard focus to
Terminal pane
New Terminal Shift+Alt+R Yes Yes Create new terminal
session
Next Terminal Ctrl+Alt+F12 Yes Yes Move forward through
terminal session list
Previous Terminal Ctrl+Alt+F11 Yes Yes Move backwards through terminal session list
Rename Terminal   Yes

Yes

Rename current terminal session
Send Selection to
Terminal

Ctrl+Alt+Enter

(also Ctrl+Enter
when editing a
.sh file)

No No
(on Code menu)
Send text from editor to current terminal
Terminal
Diagnostics
  No Yes Use when requested by RStudio support
Open Shell    

No

(on Tools and Version Control menus)

On Server, same as Move Focus to Terminal,
on Desktop IDE, opens
native terminal app
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章