diff --git a/prompt_fresh_setup b/prompt_fresh_setup index d09f52a..fde4845 100644 --- a/prompt_fresh_setup +++ b/prompt_fresh_setup @@ -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