rice is a modern command line interface to the R program. It replaces the use of the the default R console, in the sense which is similar to ipython
in the python
ecosystem. In fact, rice
is built on top of the same technology which ipython
uses.
rice is still under active development, any feedbacks will be welcome. Users should also use it at their own risks
- shell mode (hit
;
to enter and<backspace>
to leave) - lightweight, no compilation is required
- multiline editing
- syntax highlight
- auto completion
- auto matching parens/quotes.
- brackated paste mode
- cross platform, runs on Windows, macOS and Linux
- emacs/vi editing mode
- custom color scheme
- automiatically adjust to terminal width
- read more than 4096 bytes per line
Requirements:
- An installation of R (version 3.4.0 or above) is required to use rice, an R installation binary for your system can be downloaded from https://cran.r-project.org.
python
is also required to install rice. If your system doesn't come with a python distribution, it can be downloaded from https://conda.io/miniconda.html. Both version 2 and version 3 should work, though python 3 is recommended.pip
is optional but it makes the installation a bit easier.
# install released version
pip install -U rice
# or the development version
pip install -U git+https://github.com/randy3k/rice
# to run rice
rice
rice can be customized via options
in .Rprofile
file. This file is usually located in your user home directory.
options(
# color scheme see [here](https://help.farbox.com/pygments.html) for a list of supported color schemes, default is `"native"`
rice.color_scheme = "native",
# either `"emacs"` (default) or `"vi"`.
rice.editing_mode = "emacs",
# auto match brackets and quotes
rice.auto_match = FALSE,
# auto indentation for new line and curly braces
rice.auto_indentation = TRUE,
rice.tab_size = 4,
# pop up completion while typing
rice.complete_while_typing = TRUE,
# automatically adjust R buffer size based on terminal width
rice.auto_width = TRUE,
# insert new line between prompts
rice.insert_new_line = TRUE,
# when using history search (ctrl-r/ctrl-s in emacs mode), do not show duplicate results
rice.history_search_no_duplicates = FALSE,
# custom prompt for different modes
rice.prompt = "\033[0;34mr$>\033[0m ",
rice.shell_prompt = "\033[0;31m#!>\033[0m ",
rice.browse_prompt = "\033[0;33mBrowse[{}]>\033[0m ",
# supress the loading message for reticulate
rice.suppress_reticulate_message = FALSE
)
You could alias r
to rice
by putting
alias r="rice"
in ~/.bash_profile
such that r
would open rice
and R
would still open the tranditional R console.
(R
is still useful, e.g, running R CMD BUILD
.)
If rice cannot locate the R installation files automatically. You can either expose the R binary to the system PATH
variable or export the environment variable R_HOME
. For example,
$ export R_HOME=/usr/local/lib/R
$ rice
Note that it should be the path to R_HOME
, not the path to the R binary. The folder should contain a file called COPYING
.
If the above doesn't work, you may need to futher specify LD_LIBRARY_PATH
,
$ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`R RHOME`/lib"
$ rice
rice maintains its own history file .rice_history
and doesn't use the .Rhistory
file. A local .rice_history
is used if it is found in the launching directory. Otherwise, the global history file ~/.rice_history
would be used. To override the default behavior, you could launch rice
with the options: rice --local-history
, rice --global-history
or rice --no-history
.
rice only provides a frontend to the R program, the actual running eventloop is the same as that of the traditional R console. There is no performance sacrifice (or gain) while using this modern command line interface.
Put
let R_app = "rice"
let R_cmd = "R"
let R_hl_term = 0
let R_args = [] " if you had set any
let R_bracketed_paste = 1
in your vim config.
libreadline.so.6: undefined symbol: PC
If you are using conda and encounter this error, it is likely because the readline
from conda is bugged. Install it again via conda-forge
.
conda install -c conda-forge readline=6.2