31
31
help = 'specify script to run' )
32
32
parser .add_argument ('--backend' , '-b' , default = None ,
33
33
help = 'specify graphics frontend' )
34
+ parser .add_argument ('--color' , '-c' , default = 'neutral' ,
35
+ help = 'specify terminal color scheme (neutral, lightbg, nocolor, linux), linux is for dark mode' )
36
+ parser .add_argument ('--confirmexit' , '-x' , default = False ,
37
+ help = 'confirm exit' )
38
+ parser .add_argument ('--prompt' , '-p' , default = '>>> ' ,
39
+ help = 'input prompt' )
40
+ parser .add_argument ('--resultprefix' , '-r' , default = None ,
41
+ help = 'execution result prefix, include {} for execution count number' )
42
+ parser .add_argument ('--showassign' , '-a' , default = False ,
43
+ help = 'display the result of assignments' )
34
44
args = parser .parse_args ()
35
45
36
46
if args .backend is not None :
37
47
print (f"Using matplotlub backend { args .backend } " )
38
48
plt .use (args .backend )
39
49
40
- # load some models
50
+ # load some robot models
41
51
puma = models .DH .Puma560 ()
42
52
panda = models .DH .Panda ()
43
53
74
84
75
85
class MyPrompt (Prompts ):
76
86
def in_prompt_tokens (self , cli = None ):
77
- return [(Token .Prompt , '>>> ' )]
87
+ return [(Token .Prompt , args .prompt )]
88
+ def out_prompt_tokens (self , cli = None ):
89
+ if args .resultprefix is None :
90
+ # traditional behaviour
91
+ return [
92
+ (Token .OutPrompt , 'Out[' ),
93
+ (Token .OutPromptNum , str (self .shell .execution_count )),
94
+ (Token .OutPrompt , ']: ' ),
95
+ ]
96
+ else :
97
+ return [(Token .Prompt , args .resultprefix .format (self .shell .execution_count ))]
78
98
79
99
# set configuration options, there are lots, see
80
100
# https://ipython.readthedocs.io/en/stable/config/options/terminal.html
81
101
c = Config ()
82
- c .InteractiveShellEmbed .colors = "Linux"
83
- c .InteractiveShell .colors = 'Neutral'
84
- c .InteractiveShell .confirm_exit = False
102
+ c .InteractiveShellEmbed .colors = args .color
103
+ c .InteractiveShell .confirm_exit = args .confirmexit
85
104
# c.InteractiveShell.prompts_class = ClassicPrompts
86
105
c .InteractiveShell .prompts_class = MyPrompt
106
+ if showassign :
107
+ c .InteractiveShell .ast_node_interactivity = 'last_expr_or_assign'
87
108
88
109
IPython .embed (config = c )
0 commit comments