Ubuntu – Command completion in R and python

bashcommand linepythonr

In bash terminal, I could configure the command completion by inserting these lines to the /etc/inputrc file:

$if Bash
    # Search history back and forward using page-up and page-down
    "\e[5~": history-search-backward
    "\e[6~": history-search-forward

    "\e[A": history-search-backward    # arrow up
    "\e[B": history-search-forward     # arrow down

    # Completion
    set match-hidden-files off
    set page-completions off
    set completion-query-items 350
    set show-all-if-ambiguous on

$endif

I wonder if there is anyway to use this feature in programs such as R and python interactive environments?

On a workstation for R, somehow I have this ability, so wonder how can I configure that for my laptop as well. The R version is:

R version 3.0.1 (2013-05-16) -- "Good Sport"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

So, I am sure that it is possible, but does anyone know how to set it up?

Best Answer

You cannot use bash completion in another interactive session - you're not interacting with bash at that point.

The default python interpreter provides no autocomplete function, but you can get an improved interpreter like IPython (sudo apt-get install ipython) which provides a range of history and autocomplete functions.

The default R interpreter provides some autocompletion. I'm not sure if you can get a better command line interpreter, but a GUI like RStudio (not in repositories, download deb package from their site) provides better interactivity.