add ipython
This commit is contained in:
parent
36d242869b
commit
f88f4a003d
5
Makefile
5
Makefile
@ -80,6 +80,11 @@ bat:
|
||||
mkdir -p ~/.config/bat
|
||||
ln -s $(PWD)/sub/bat/config ~/.config/bat/config
|
||||
|
||||
ipython:
|
||||
test -d ~/.ipython || \
|
||||
mkdir -p ~/.ipython/profile_default
|
||||
ln -s $(PWD)/sub/ipython/ipython_config.py ~/.ipython/profile_default/ipython_config.py
|
||||
|
||||
font:
|
||||
mkdir -p ~/.local/share/fonts
|
||||
cd ~/.local/share/fonts
|
||||
|
||||
57
sub/ipython/ipython_config.py
Normal file
57
sub/ipython/ipython_config.py
Normal file
@ -0,0 +1,57 @@
|
||||
from IPython.terminal.prompts import Prompts, Token
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
import os
|
||||
from platform import python_version
|
||||
|
||||
|
||||
def get_branch():
|
||||
try:
|
||||
return " (" + (
|
||||
subprocess.check_output(
|
||||
"git branch --show-current", shell=True, stderr=subprocess.DEVNULL
|
||||
)
|
||||
.decode("utf-8")
|
||||
.replace("\n", "")
|
||||
) + ")"
|
||||
except BaseException:
|
||||
return ""
|
||||
|
||||
|
||||
class CustomPrompt(Prompts):
|
||||
|
||||
def in_prompt_tokens(self, cli=None):
|
||||
return [
|
||||
(Token, "\n┌──("),
|
||||
(Token.Name.Class, os.getlogin()),
|
||||
(Token.Prompt, "@"),
|
||||
(Token.Name.Class, "ipython v" + python_version()),
|
||||
(Token, ")-["),
|
||||
(Token.OutPrompt, os.getcwd()),
|
||||
(Token, "]"),
|
||||
(Token.Generic.Subheading, get_branch()),
|
||||
(Token, " "),
|
||||
(Token, "\n└─"),
|
||||
(
|
||||
Token.Prompt
|
||||
if self.shell.last_execution_succeeded
|
||||
else Token.Generic.Error,
|
||||
"λ ",
|
||||
),
|
||||
]
|
||||
|
||||
def out_prompt_tokens(self, cli=None):
|
||||
return [(Token.Prompt, ''), ]
|
||||
|
||||
def continuation_prompt_tokens(self, cli=None, width=None):
|
||||
return [(Token.Prompt, ''), ]
|
||||
|
||||
|
||||
c = get_config()
|
||||
|
||||
c.TerminalInteractiveShell.prompts_class = CustomPrompt
|
||||
c.TerminalInteractiveShell.separate_in = ''
|
||||
c.TerminalInteractiveShell.confirm_exit = False
|
||||
c.TerminalIPythonApp.display_banner = False
|
||||
|
||||
q = exit
|
||||
Loading…
x
Reference in New Issue
Block a user