Remove use of RPS1
Following on from the previous commit, use of `RPS1` results in the prompt being redrawn when the terminal gets narrower, this makes the line drawn by `fresh_line_one` scroll off the screen. By removing any use of `RPS1` this behaviour goes away.
This commit is contained in:
parent
df819f58a8
commit
f24253b8c1
@ -19,8 +19,8 @@ prompt_fresh_setup() {
|
||||
autoload -U add-zsh-hook
|
||||
|
||||
# Hook to print the first line of the "two line" prompt, this line is not
|
||||
# actually part of the prompt so does not get redrawn which can sometimes
|
||||
# cause lines before the prompt to disappear.
|
||||
# actually part of the prompt so does not get redrawn, this is preferable
|
||||
# since sometimes lines before the prompt can disappear.
|
||||
add-zsh-hook precmd fresh_line_one
|
||||
|
||||
if [ $almostontop -eq 1 ]; then
|
||||
@ -46,8 +46,6 @@ prompt_fresh_setup() {
|
||||
PS1="«$user» "
|
||||
PS2="«${(l:${#userhost}:: :)}» "
|
||||
|
||||
RPS1='$(fresh_rprompt)'
|
||||
|
||||
prompt_opts=(percent sp subst)
|
||||
}
|
||||
|
||||
@ -89,7 +87,7 @@ fresh_line_one() {
|
||||
fi
|
||||
|
||||
# Construct the git prompt
|
||||
local git="%{%F{66}%}$branch%{%f%}$ahead$behind "
|
||||
local git=" %{%F{66}%}$branch%{%f%}$ahead$behind "
|
||||
|
||||
if [ -f ~/.cache/zsh/git-prompt ]; then
|
||||
# Get the change counts from git-prompt
|
||||
@ -119,26 +117,23 @@ fresh_line_one() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Print the first line of the prompt
|
||||
# If the last command failed, display its error code at the right
|
||||
if [[ $exit_code -ne 0 ]]; then
|
||||
# The last command failed, display its error code at the right
|
||||
local result=" %{%B%F{1}%}$exit_code%{%f%b%}"
|
||||
fi
|
||||
|
||||
# Construct the prompt string
|
||||
local line="$time_stamp $directory $git$result"
|
||||
print -P "$line"
|
||||
}
|
||||
|
||||
fresh_rprompt() {
|
||||
rprompt=""
|
||||
if [[ ! -z "$DOCKER_MACHINE_NAME" ]]; then
|
||||
rprompt="$rprompt %{%F{3}%}$DOCKER_MACHINE_NAME%{%f%}"
|
||||
fi
|
||||
# If a virtualenv is enabled, display it's basename
|
||||
if [[ ! -z "$VIRTUAL_ENV" ]]; then
|
||||
rprompt="$rprompt %{%F{3}%}$(basename $VIRTUAL_ENV)%{%f%}"
|
||||
py=" %{%F{4}%}py%{%f%}%{%F{3}%}$(basename $VIRTUAL_ENV)%{%f%}"
|
||||
fi
|
||||
echo $rprompt
|
||||
|
||||
# If docker-machine env is active, display the machines name
|
||||
if [[ ! -z "$DOCKER_MACHINE_NAME" ]]; then
|
||||
docker=" %{%F{6}%}$DOCKER_MACHINE_NAME%{%f%}"
|
||||
fi
|
||||
|
||||
# Print the first line of the prompt
|
||||
print -P "$time_stamp $directory$git$py$docker$result"
|
||||
}
|
||||
|
||||
fresh_almostontop() {
|
||||
@ -148,10 +143,9 @@ fresh_almostontop() {
|
||||
}
|
||||
|
||||
fresh_compile_git_prompt() {
|
||||
# Compile a simple C executable which parses the output of `git status
|
||||
# --procelain` to greatly decrease the time taken to render the prompt
|
||||
local cache=~/.cache/zsh
|
||||
if [ ! -d $cache ]; then mkdir -p $cache; fi
|
||||
# Compile a simple C program which parses the output of `git status
|
||||
# --procelain` to greatly decrease the time taken to draw the prompt
|
||||
local cache=~/.cache/zsh; [ ! -d $cache ] && mkdir -p $cache
|
||||
if [ ! -f $cache/git-prompt ]; then
|
||||
cc -x c -std=gnu99 -O3 -DNDEBUG -o $cache/git-prompt - 2> /dev/null << EOF
|
||||
#include <stdio.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user