2021-03-01 03:47:07 +03:00
|
|
|
function fish_prompt
|
2022-02-06 02:14:21 +03:00
|
|
|
end # In case this file gets loaded non-interactively, e.g by conda
|
2021-04-10 18:56:38 +03:00
|
|
|
status is-interactive || exit
|
|
|
|
|
|
|
|
_tide_remove_unusable_items
|
2021-08-22 01:05:08 +03:00
|
|
|
_tide_cache_variables
|
2022-01-05 22:25:32 +03:00
|
|
|
source (functions --details _tide_pwd)
|
2021-04-10 18:56:38 +03:00
|
|
|
|
2022-01-06 00:50:08 +03:00
|
|
|
set -l prompt_var _tide_prompt_$fish_pid
|
2022-01-11 01:47:32 +03:00
|
|
|
set -U $prompt_var # Set var here so if we erase $prompt_var, bg job won't set a uvar
|
2021-04-10 18:56:38 +03:00
|
|
|
|
2022-03-14 18:43:24 +03:00
|
|
|
set_color normal | read -l color_normal
|
|
|
|
status fish-path | read -l fish_path
|
2022-01-14 09:10:33 +03:00
|
|
|
|
2021-12-22 01:32:17 +03:00
|
|
|
# _tide_repaint prevents us from creating a second background job
|
2022-02-21 18:19:18 +03:00
|
|
|
function _tide_refresh_prompt --on-variable $prompt_var --on-variable COLUMNS
|
2021-12-22 01:32:17 +03:00
|
|
|
set -g _tide_repaint
|
|
|
|
commandline -f repaint
|
2021-04-10 18:56:38 +03:00
|
|
|
end
|
|
|
|
|
2022-01-09 01:05:44 +03:00
|
|
|
if contains newline $_tide_left_items # two line prompt initialization
|
2022-01-06 00:50:08 +03:00
|
|
|
test "$tide_prompt_add_newline_before" = true && set -l add_newline '\n'
|
2022-01-05 02:04:39 +03:00
|
|
|
|
2022-01-11 01:47:32 +03:00
|
|
|
set_color $tide_prompt_color_frame_and_connection -b normal | read -l prompt_and_frame_color
|
2022-01-05 02:04:39 +03:00
|
|
|
|
|
|
|
set -l column_offset 5
|
|
|
|
test "$tide_left_prompt_frame_enabled" = true &&
|
2022-01-11 01:47:32 +03:00
|
|
|
set -l top_left_frame "$prompt_and_frame_color╭─" &&
|
|
|
|
set -l bot_left_frame "$prompt_and_frame_color╰─" &&
|
2022-01-05 02:04:39 +03:00
|
|
|
set column_offset (math $column_offset-2)
|
|
|
|
test "$tide_right_prompt_frame_enabled" = true &&
|
2022-01-11 01:47:32 +03:00
|
|
|
set -l top_right_frame "$prompt_and_frame_color─╮" &&
|
|
|
|
set -l bot_right_frame "$prompt_and_frame_color─╯" &&
|
2022-01-05 02:04:39 +03:00
|
|
|
set column_offset (math $column_offset-2)
|
|
|
|
|
2022-01-04 00:03:28 +03:00
|
|
|
eval "
|
2021-12-09 20:03:36 +03:00
|
|
|
function fish_prompt
|
2021-12-08 20:09:13 +03:00
|
|
|
_tide_status=\$status _tide_pipestatus=\$pipestatus if not set -e _tide_repaint
|
2021-12-22 01:32:17 +03:00
|
|
|
jobs -q && set -lx _tide_jobs
|
2022-03-10 01:12:55 +03:00
|
|
|
$fish_path -c \"set _tide_pipestatus \$_tide_pipestatus
|
2022-01-06 00:50:08 +03:00
|
|
|
CMD_DURATION=\$CMD_DURATION fish_bind_mode=\$fish_bind_mode set $prompt_var (_tide_2_line_prompt)\" &
|
2021-06-28 19:43:25 +03:00
|
|
|
builtin disown
|
2021-04-10 18:56:38 +03:00
|
|
|
|
2021-12-08 20:09:13 +03:00
|
|
|
command kill \$_tide_last_pid 2>/dev/null
|
2022-01-09 22:28:42 +03:00
|
|
|
set -g _tide_last_pid \$last_pid
|
2021-04-10 18:56:38 +03:00
|
|
|
end
|
2022-01-04 00:03:28 +03:00
|
|
|
|
2022-01-12 21:24:41 +03:00
|
|
|
math \$COLUMNS-(string length -V \"\$$prompt_var[1][1]\$$prompt_var[1][3]\")+$column_offset | read -lx dist_btwn_sides
|
2022-01-04 00:03:28 +03:00
|
|
|
|
2022-01-11 01:47:32 +03:00
|
|
|
echo -ns $add_newline'$top_left_frame'(string replace @PWD@ (_tide_pwd) \"\$$prompt_var[1][1]\")'$prompt_and_frame_color'
|
2022-01-26 20:35:35 +03:00
|
|
|
string repeat -Nm(math max 0, \$dist_btwn_sides-\$_tide_pwd_len) '$tide_prompt_icon_connection'
|
2022-03-10 00:40:20 +03:00
|
|
|
echo -ns \"\$$prompt_var[1][3]$top_right_frame\"\n\"$bot_left_frame\$$prompt_var[1][2]$color_normal \"
|
2022-01-09 01:05:44 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function fish_right_prompt
|
2022-01-14 09:10:33 +03:00
|
|
|
string unescape \"\$$prompt_var[1][4]$bot_right_frame$color_normal\"
|
2022-01-04 00:03:28 +03:00
|
|
|
end"
|
2022-01-09 01:05:44 +03:00
|
|
|
else # one line prompt initialization
|
2022-01-06 00:50:08 +03:00
|
|
|
test "$tide_prompt_add_newline_before" = true && set -l add_newline '\0'
|
2022-01-05 02:04:39 +03:00
|
|
|
|
|
|
|
math 5 -$tide_prompt_min_cols | read -l column_offset
|
2022-01-05 02:17:49 +03:00
|
|
|
test $column_offset -ge 0 && set column_offset "+$column_offset"
|
2022-01-05 02:04:39 +03:00
|
|
|
|
2022-01-04 00:03:28 +03:00
|
|
|
eval "
|
|
|
|
function fish_prompt
|
|
|
|
_tide_status=\$status _tide_pipestatus=\$pipestatus if not set -e _tide_repaint
|
|
|
|
jobs -q && set -lx _tide_jobs
|
2022-03-10 01:12:55 +03:00
|
|
|
$fish_path -c \"set _tide_pipestatus \$_tide_pipestatus
|
2022-01-06 00:50:08 +03:00
|
|
|
CMD_DURATION=\$CMD_DURATION fish_bind_mode=\$fish_bind_mode set $prompt_var (_tide_1_line_prompt)\" &
|
2022-01-04 00:03:28 +03:00
|
|
|
builtin disown
|
|
|
|
|
|
|
|
command kill \$_tide_last_pid 2>/dev/null
|
2022-01-09 22:28:42 +03:00
|
|
|
set -g _tide_last_pid \$last_pid
|
2022-01-04 00:03:28 +03:00
|
|
|
end
|
|
|
|
|
2022-01-12 21:24:41 +03:00
|
|
|
math \$COLUMNS-(string length -V \"\$$prompt_var[1][1]\$$prompt_var[1][2]\")$column_offset | read -lx dist_btwn_sides
|
2022-03-10 00:40:20 +03:00
|
|
|
string replace @PWD@ (_tide_pwd) $add_newline \$$prompt_var[1][1]'$color_normal '
|
2021-12-08 20:27:33 +03:00
|
|
|
end
|
2021-04-10 18:56:38 +03:00
|
|
|
|
2021-08-13 14:54:40 +03:00
|
|
|
function fish_right_prompt
|
2022-01-14 09:10:33 +03:00
|
|
|
string unescape \"\$$prompt_var[1][2]$color_normal\"
|
2022-01-09 01:05:44 +03:00
|
|
|
end"
|
2021-08-13 14:54:40 +03:00
|
|
|
end
|
|
|
|
|
2022-01-09 01:05:44 +03:00
|
|
|
eval "function _tide_on_fish_exit --on-event fish_exit
|
2022-01-06 00:50:08 +03:00
|
|
|
set -e $prompt_var
|
2021-12-09 20:03:36 +03:00
|
|
|
end"
|