@@ -98,9 +98,22 @@ function __vsc_cmd_clear --on-event fish_cancel
98
98
__vsc_esc D
99
99
end
100
100
101
+ # Preserve the user' s existing prompt, to wrap in our escape sequences.
102
+ function init_vscode_shell_integration
103
+ echo " $fish_prompt "
104
+ functions --copy fish_prompt __vsc_fish_prompt
105
+ end
106
+
101
107
# Sent whenever a new fish prompt is about to be displayed.
102
108
# Updates the current working directory.
103
109
function __vsc_update_cwd --on-event fish_prompt
110
+ if type -q init_vscode_shell_integration
111
+ if set -q fish_prompt
112
+ init_vscode_shell_integration
113
+ functions --erase init_vscode_shell_integration
114
+ end
115
+ end
116
+
104
117
__vsc_esc P Cwd=(__vsc_escape_value " $PWD " )
105
118
106
119
# If a command marker exists, remove it.
@@ -128,9 +141,6 @@ function __vsc_fish_has_mode_prompt -d "Returns true if fish_mode_prompt is defi
128
141
functions fish_mode_prompt | string match -rvq ' ^ *(#|function |end$|$)'
129
142
end
130
143
131
- # Preserve the user's existing prompt, to wrap in our escape sequences.
132
- functions --copy fish_prompt __vsc_fish_prompt
133
-
134
144
# Preserve and wrap fish_mode_prompt (which appears to the left of the regular
135
145
# prompt), but only if it's not defined as an empty function (which is the
136
146
# officially documented way to disable that feature).
@@ -143,14 +153,18 @@ if __vsc_fish_has_mode_prompt
143
153
end
144
154
145
155
function fish_prompt
146
- __vsc_fish_prompt
156
+ if set -q __vsc_fish_prompt
157
+ __vsc_fish_prompt
158
+ end
147
159
__vsc_fish_cmd_start
148
160
end
149
161
else
150
162
# No fish_mode_prompt, so put everything in fish_prompt.
151
163
function fish_prompt
152
164
__vsc_fish_prompt_start
153
- __vsc_fish_prompt
165
+ if set -q __vsc_fish_prompt
166
+ __vsc_fish_prompt
167
+ end
154
168
__vsc_fish_cmd_start
155
169
end
156
170
end
0 commit comments