Skip to content

Commit 4e1d8ea

Browse files
committed
Add JuliaModePrompt
1 parent 03a093e commit 4e1d8ea

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ First launch of IPython may be slow.
3333
* IPython (7.0 or above is recommended)
3434

3535

36+
## Configuration
37+
38+
### Julia-mode like prompt
39+
40+
If you want IPython prompt to look like a part of Julia prompt, then add
41+
the following snippet in `~/.ipython/profile_default/ipython_config.py`:
42+
43+
```python
44+
try:
45+
from ipython_jl.tools import JuliaModePrompt
46+
except ImportError:
47+
pass
48+
else:
49+
c.TerminalInteractiveShell.prompts_class = JuliaModePrompt
50+
```
51+
52+
Then the prompt would then look like `ipy 1>` instead of `In [1]:`.
53+
It also removes `Out[1]`. Note that above setting does not change
54+
your normal IPython prompts.
55+
56+
3657
[travis-img]: https://travis-ci.org/tkf/IPython.jl.svg?branch=master
3758
[travis-url]: https://travis-ci.org/tkf/IPython.jl
3859
[coveralls-img]: https://coveralls.io/repos/tkf/IPython.jl/badge.svg?branch=master&service=github

src/ipython_jl/tools.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from IPython.terminal.prompts import Prompts, Token
2+
3+
4+
class JuliaModePrompt(Prompts):
5+
6+
def in_prompt_tokens(self):
7+
return [
8+
(Token.Prompt, "ipy "),
9+
(Token.PromptNum, str(self.shell.execution_count)),
10+
(Token.Prompt, "> "),
11+
]
12+
13+
def out_prompt_tokens(self):
14+
return []

0 commit comments

Comments
 (0)