Support multiline prompt in tcsh

Notes:

- I had to launch script twice because tcsh does not actually support multiline
  prompt: it squashes everything into one line.
- Thus I had to add POWERLINE_TCSH_NO_ABOVE_PROMPT: running python twice is not
  nice for performance.
- Due to 1) tcsh shifting rprompt by 1 and 2) tcsh not accepting %{%}-escaped
  color section at the very end of rprompt (actually it is accepting it, just
  makes user input colored as that section) I had to reduce computed width by 2.
- As running powerline command in precmd modifies status code I had to use
  POWERLINE_STATUS variable to save status.
- As tcsh does not accept names that start with underscore non-API powerline
  variables do not start with underscore.
This commit is contained in:
ZyX 2014-06-24 21:22:09 +04:00
parent 3b4a2b3520
commit 5df7b36c3a
1 changed files with 9 additions and 3 deletions

View File

@ -19,7 +19,13 @@ if ! ( $?POWERLINE_NO_TCSH_TMUX_SUPPORT || $?POWERLINE_NO_SHELL_TMUX_SUPPORT ) t
alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd"
endif
if ! ( $?POWERLINE_NO_TCSH_PROMPT || $?POWERLINE_NO_SHELL_PROMPT ) then
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r tcsh_prompt --last_exit_code=$?`"'
alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r tcsh_prompt --last_exit_code=$?` "'
alias precmd "`alias precmd` ; _powerline_set_prompt ; _powerline_set_rprompt"
if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then
alias _powerline_above true
else
alias _powerline_above '$POWERLINE_COMMAND shell above --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS'
endif
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r tcsh_prompt --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"'
alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r tcsh_prompt --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "'
alias _powerline_set_columns 'set POWERLINE_COLUMNS=`stty size|cut -d" " -f2` ; set POWERLINE_COLUMNS=`expr $POWERLINE_COLUMNS - 2`'
alias precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt'
endif