mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
bd18736ee5
Using bare vars is more efficient because it makes the builtin `math` expression cache more useful. That's because if you prefix each var with a dollar-sign then the fish parser expands it before `math` is run. Something like `math x + 1` can be cached since the expression is the same each time it is run. But if you do `math $x + 1` and x==1 then you're effectively executing `math 1 + 1`. And if x==2 the next time then you're running `math 2 + 1`. Which makes the expression cache much less effective.
23 lines
954 B
Fish
23 lines
954 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 -L0 function)
|
|
set -l line (status -L0 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 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
|