
我嘗試$status
在 Fish shell 中新增提示符,但它總是列印 0。
這個問題不久前在 irc 上被問到,我很驚訝這裡沒有答案,所以我想我也應該在這裡發布它。
答案1
這是因為您在提示符號中呼叫的任何函數/命令都會重置該值。為了使其工作,將值分配給另一個變量,這是您在fish_prompt或fish_right_prompt函數中做的第一件事。
function fish_prompt --description 'Write out the prompt'
set -l _display_status $status
...
printf '%s' $_display_status
end