fish-shell/share/functions/fish_breakpoint_prompt.fish
Kurtis Rader df01547eab implement the fish_breakpoint_prompt function
This is another step to resolving issue #1310. It makes
`fish_breakpoint_prompt` a replacement for `fish_prompt` if it is defined
and we're presenting a prompt in the context of a `breakpoint` command.
2017-06-20 17:18:59 -07:00

23 lines
974 B
Fish

# Define the default debugging prompt command.
function fish_breakpoint_prompt --description "A right prompt to be used when `breakpoint` is executed"
set -l saved_status $status
set -l function (status current-function)
set -l line (status current-line-number)
# At the moment we don't include the filename because, even if we truncate it, it makes the
# prompt too long.
#set -l filename (status current-filename)
#set -l prompt "$filename:$function:$line >"
set -l prompt "$function:$line"
if test $saved_status -ne 0
set prompt "$prompt [!$saved_status]"
end
set prompt "$prompt > "
# Make sure the prompt doesn't consume more than half the terminal width.
set -l max_len (math "$COLUMNS / 2")
if test (string length -- $prompt) -gt $max_len
set prompt ...(string sub -s -(math $max_len - 3) -- $prompt)
end
echo -ns (set_color $fish_color_status) "BP $prompt" (set_color normal) ' '
end