r
Repeat the last command
TLDR
Start a REPL (interactive shell)
Start R in vanilla mode (i.e. a blank session that doesn't save the workspace at the end)
Execute a file
Execute an R expression and then exit
Run R with a debugger
Check R packages from package sources
Display version
SYNOPSIS
r [string]
PARAMETERS
string
If a `string` is provided, the `r` command will usually re-execute the last command starting with that string. If no `string` is provided, the last command will be executed.
DESCRIPTION
The `r` command, often an alias or function in shell environments like Bash, facilitates re-execution of previously run commands. It's primarily a convenience feature, saving time and effort by avoiding the need to retype or recall complex commands with numerous arguments. The specific behavior of `r` depends on its definition within the shell's configuration (e.g., `.bashrc`, `.zshrc`). A typical implementation uses shell history to access the last executed command, allowing users to run it again with minimal input. Some versions may allow modifications to the last command, enhancing its utility. It dramatically increases user productivity by streamlining repetitive tasks or quickly correcting minor errors in previous executions. Without `r` users will need to access shell history using other methods. The use of shell features like history expansion offers similar functionality, but `r` provides a more concise and intuitive approach.
The r can be modified as needed, to fit different users needs, making this a handy tool to use.
CAVEATS
The behavior of `r` is highly dependent on its definition within the shell's configuration files. Its functionality might differ slightly or be entirely absent depending on the setup. In some shells `r` is not defined by default, and you'll need to manually create the alias or function. Not all shells implements command aliases in the same way.
EXAMPLES
- To re-execute the last command: `r`
- To re-execute the last command that started with `git`: `r git`
CUSTOMIZATION
The `r` command is often implemented as an alias or function within your shell's configuration file (e.g., `.bashrc`, `.zshrc`). You can customize its behavior by modifying this alias or function. For example:
Alias example: `alias r='!!'`
This can be modified to fit your personal preferences.
HISTORY
The use of `r` as a command recall mechanism likely evolved alongside the development of interactive shells. It's based on the common need to rerun or modify previously entered commands. The specific implementation of `r` varies, reflecting different approaches to command history management and user convenience. Its use became widespread as users needed to work more and more in the shell.