115 字
1 分钟
VSCode Terminal Prompt 换行问题
问题
在 VSCode 内打开 Terminal:
- 输入会在 prompt 下一行
- 但是在
source ~/.config/fish/config.fish
后,输入会紧跟 prompt - 仅在 VSCode 出现该问题
如下:
~/p/flutter_server_box main! >
source $FIC
~/p/flutter_server_box main! > code $FIC
~/p/flutter_server_box main! >
原因
echo -e
会在 VSCode Terminal 中异常换行
function fish_prompt
echo -e "$_hydro_color_pwd$_hydro_pwd$hydro_color_normal $_hydro_color_git$$_hydro_git$hydro_color_normal$_hydro_color_duration$_hydro_cmd_duration$hydro_color_normal$_hydro_status$hydro_color_normal "
end
解决
将 echo -e
替换为 printf
,使用更加精确的格式化输出
function fish_prompt
printf '%s%s%s %s%s%s%s%s%s%s%s ' \
"$_hydro_color_pwd" "$_hydro_pwd" "$hydro_color_normal" \
"$_hydro_color_git" "$$_hydro_git" "$hydro_color_normal" \
"$_hydro_color_duration" "$_hydro_cmd_duration" "$hydro_color_normal" \
"$_hydro_status" "$hydro_color_normal"
end
VSCode Terminal Prompt 换行问题
https://blog.lpkt.cn/posts/term-vscode-newline/