Support multiline prompt in fish

Note: fish does not accept prompt strings that have width identical to the
terminal width: it makes prompt be reduced to just `>`.
This commit is contained in:
ZyX 2014-06-23 20:43:29 +04:00
parent 5df7b36c3a
commit 8849f9d3d6
1 changed files with 22 additions and 2 deletions

View File

@ -10,15 +10,35 @@ function powerline-setup
end
end
function --on-variable POWERLINE_COMMAND _powerline_update
set -l addargs "--last_exit_code=\$status --last_pipe_status=\$status --jobnum=(jobs -p | wc -l)"
set -l addargs "--last_exit_code=\$status"
set -l addargs "$addargs --last_pipe_status=\$status"
set -l addargs "$addargs --jobnum=(jobs -p | wc -l)"
set -l addargs "$addargs --width=\$_POWERLINE_COLUMNS"
set -l promptside
set -l rpromptpast
set -l columnsexpr
if test -z "$POWERLINE_NO_FISH_ABOVE$POWERLINE_NO_SHELL_ABOVE"
set promptside aboveleft
set rpromptpast 'echo -n " "'
set columnsexpr '(math $COLUMNS - 1)'
else
set promptside left
set rpromptpast
set columnsexpr '$COLUMNS'
end
eval "
function fish_prompt
$POWERLINE_COMMAND shell left $addargs
$POWERLINE_COMMAND shell $promptside $addargs
end
function fish_right_prompt
$POWERLINE_COMMAND shell right $addargs
$rpromptpast
end
function --on-signal WINCH _powerline_set_columns
set -g _POWERLINE_COLUMNS $columnsexpr
end
"
_powerline_set_columns
end
_powerline_update
end