FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vscode-python/python_files/pythonrc.py at main · zzalscv2/vscode-python · GitHub
zzalscv2
/
vscode-python
Public
forked from
microsoft/vscode-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vscode-python
/
python_files
/
pythonrc.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (62 loc) · 2.54 KB
Breadcrumbs
vscode-python
/
python_files
/
pythonrc.py
Copy path
File metadata and controls
80 lines (62 loc) · 2.54 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import
sys
if
sys
.
platform
!=
"win32"
:
import
readline
original_ps1
=
">>> "
class
repl_hooks
:
def
__init__
(
self
):
self
.
global_exit
=
None
self
.
failure_flag
=
False
self
.
original_excepthook
=
sys
.
excepthook
self
.
original_displayhook
=
sys
.
displayhook
sys
.
excepthook
=
self
.
my_excepthook
sys
.
displayhook
=
self
.
my_displayhook
def
my_displayhook
(
self
,
value
):
if
value
is
None
:
self
.
failure_flag
=
False
self
.
original_displayhook
(
value
)
def
my_excepthook
(
self
,
type
,
value
,
traceback
):
self
.
global_exit
=
value
self
.
failure_flag
=
True
self
.
original_excepthook
(
type
,
value
,
traceback
)
def
get_last_command
():
# Get the last history item
last_command
=
""
if
sys
.
platform
!=
"win32"
:
last_command
=
readline
.
get_history_item
(
readline
.
get_current_history_length
())
return
last_command
class
ps1
:
hooks
=
repl_hooks
()
sys
.
excepthook
=
hooks
.
my_excepthook
sys
.
displayhook
=
hooks
.
my_displayhook
# str will get called for every prompt with exit code to show success/failure
def
__str__
(
self
):
exit_code
=
0
if
self
.
hooks
.
failure_flag
:
exit_code
=
1
else
:
exit_code
=
0
self
.
hooks
.
failure_flag
=
False
# Guide following official VS Code doc for shell integration sequence:
result
=
""
# For non-windows allow recent_command history.
if
sys
.
platform
!=
"win32"
:
result
=
"{command_line}{command_finished}{prompt_started}{prompt}{command_start}{command_executed}"
.
format
(
command_line
=
"
\x1b
]633;E;"
+
str
(
get_last_command
())
+
"
\x07
"
,
command_finished
=
"
\x1b
]633;D;"
+
str
(
exit_code
)
+
"
\x07
"
,
prompt_started
=
"
\x1b
]633;A
\x07
"
,
prompt
=
original_ps1
,
command_start
=
"
\x1b
]633;B
\x07
"
,
command_executed
=
"
\x1b
]633;C
\x07
"
,
)
else
:
result
=
"{command_finished}{prompt_started}{prompt}{command_start}{command_executed}"
.
format
(
command_finished
=
"
\x1b
]633;D;"
+
str
(
exit_code
)
+
"
\x07
"
,
prompt_started
=
"
\x1b
]633;A
\x07
"
,
prompt
=
original_ps1
,
command_start
=
"
\x1b
]633;B
\x07
"
,
command_executed
=
"
\x1b
]633;C
\x07
"
,
)
# result = f"{chr(27)}]633;D;{exit_code}{chr(7)}{chr(27)}]633;A{chr(7)}{original_ps1}{chr(27)}]633;B{chr(7)}{chr(27)}]633;C{chr(7)}"
return
result
if
sys
.
platform
!=
"win32"
:
sys
.
ps1
=
ps1
()
Back
|
FazBrowse Home
|
New Git URL