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


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?

  • You should ask this on StackOverflow. – user45853 Sep 30 '13 at 18:40
  • Sorry, but, I thought this is not a programming question, rather it's mainly an issue of configuration! – Vahid Mirjalili Oct 18 '13 at 20:07
  • 1
    You should check the .* files like .profile and .bashrc in that workstation and check how the job is done. – Braiam Oct 19 '13 at 16:03
  • @Braiam They're called dotfiles. :D – user45853 Oct 26 '13 at 15:52

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.

  • 1
    Thanks for the info, however for R, I have this ability on one workstation at work but don't have this feature on my laptop. Both systems are Ubuntu 12.04 – Vahid Mirjalili Sep 30 '13 at 18:33

A quick way would be to add the following lines to a script called .pythonstartup.py and put it in your home directory:

import rlcompleter, readline

Then add the following line to your .bashrc:

export PYTHONSTARTUP="/home/YOUR_USERNAME/.pythonstartup.py"
  • Note 1: The .bashrc file is usually located in your home directory (~).
  • Note 2: Replace YOUR_USERNAME with your actual username.

Then, all you have to do is source it so the changes take effect right away:

source ~/.bashrc

Or just open a new terminal.

  • This answer was very useful! I used it and updated my bashrc! However, I was trying to do something else! – Vahid Mirjalili Oct 22 '14 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.