iPython Prompt Customisation

It might look silly but I really don’t like IPython prompt so much !! As for capabilities of IPython, it’s just really amazing. So how?

Here you can learn, how you can convert IPython prompt look like Python standard prompt.

from IPython terminal run following commands without # in the start.

>>> #%config PromptManager.out_template = “”
>>> #%config PromptManager.in_template = “ip >>> ”
>>> #%config TerminalInteractiveShell.separate_in = ”

# To copy paste - use below
%config PromptManager.in_template = "ip >>> "
%config PromptManager.out_template = ""
%config TerminalInteractiveShell.separate_in = ''

You can also add these into you IPython profile just like we do for bash and other. Once you setup there I think you know what happens.

In case you want special color for your prompt, kindly check the second link in sources mention at the bottom of this post.

Advantages

  • makes you feel comfortables about IPython which is what Python is all about.
  • no unnecessary waste of space.
  • removes tracker like showing numbers for input command and output command.

Sources:

 

Examples:

Here is me, trying lots of combos

ip >>> %config PromptManager.in_template = "{color.Normal}ip >>> "
ip >>> %config PromptManager.in_template = "{color.Red}ip >>> "
ip >>> %config PromptManager.in_template = "{color.Black}ip >>> "
ip >>> %config PromptManager.in_template = "{color.Green}ip >>> "
ip >>> %config PromptManager.in_template = "{color.Yellow}ip >>> "
ip >>> %config PromptManager.in_template = "{color.BlinkYellow}ip >>> "
ip >>> %config PromptManager.in_template = "{color.BlinkLightGray}ip >>> "
ip >>> print 1
1
ip >>>

use color.Normal, to get standard dark green.

 

Troubleshooting:

In case you type error in color name, then error like below will come. To provide an example, I tried color.BlinkLightGray1, which is not in the predefined list for IPython prompt and below is the error I received.

AttributeError: InputTermColors instance has no attribute 'BlinkLightGray1'

Solution: After this error is thrown, you will still in IPython prompt. So now, click up arrow to get your previous command and then correct it and enter.

 

Adios:

wow, it’s pretty amazing when I try these things in terminal. Good Luck 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s