tide/functions/fish_prompt.fish

46 lines
1.3 KiB
Fish
Raw Normal View History

2021-03-01 03:47:07 +03:00
if not status is-interactive # Avoid loading fish_prompt while not interactive
function fish_prompt
end
2021-03-01 03:47:07 +03:00
exit # Skips the rest of the file
end
2021-03-01 03:47:07 +03:00
_tide_detect_os
2020-11-25 20:41:40 +03:00
2021-03-01 03:47:07 +03:00
# Set things that wont change
set -g _tide_left_prompt_display_var _tide_left_prompt_display_$fish_pid
2020-12-08 02:15:29 +03:00
2021-03-01 03:47:07 +03:00
set -gx _tide_fish_pid $fish_pid
2020-12-08 02:15:29 +03:00
2021-03-01 03:47:07 +03:00
function fish_prompt
set -lx _tide_last_pipestatus $pipestatus
2020-11-25 22:54:17 +03:00
2021-03-01 03:47:07 +03:00
if not set -e _tide_repainting
set -lx _tide_jobs_number (jobs --pid | count)
2021-03-01 03:47:07 +03:00
fish --command "
set CMD_DURATION $CMD_DURATION
set COLUMNS $COLUMNS
set fish_bind_mode $fish_bind_mode
set fish_term24bit $fish_term24bit
2020-11-25 01:21:22 +03:00
2021-03-01 03:47:07 +03:00
command kill $_tide_last_pid 2>/dev/null
2021-03-02 20:52:58 +03:00
set -U _tide_left_prompt_display_$fish_pid (_tide_prompt)" &
2021-03-01 03:47:07 +03:00
set -g _tide_last_pid (jobs --last --pid)
builtin disown $_tide_last_pid
end
2021-03-01 03:47:07 +03:00
string unescape $$_tide_left_prompt_display_var
end
2020-11-21 01:04:04 +03:00
2021-03-01 03:47:07 +03:00
function _tide_refresh_prompt --on-variable _tide_left_prompt_display_$fish_pid --on-variable _tide_right_prompt_display_$fish_pid
set -g _tide_repainting
2021-03-02 20:52:58 +03:00
commandline --function repaint
2021-03-01 03:47:07 +03:00
end
# Double underscores to avoid erasing this function on uninstall
function __tide_on_fish_exit --on-event fish_exit
set -e _tide_left_prompt_display_$fish_pid
set -e _tide_right_prompt_display_$fish_pid
end