Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CURRENT_BG='NONE'
- SEGMENT_SEPARATOR='\u25B6'
- CURRENT_BG_OLD="$CURRENT_BG"
- # Begin a segment
- # Takes two arguments, background and foreground. Both can be omitted,
- # rendering default background/foreground.
- prompt_segment() {
- local bg fg
- [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
- [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
- if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
- echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
- else
- echo -n "%{$bg%}%{$fg%} "
- fi
- CURRENT_BG=$1
- [[ -n $3 ]] && echo -n $3
- }
- prompt_begin() {
- echo -e "\n"
- prompt_segment blue blue ' '
- prompt_status(){
- local symbols
- symbols=()
- [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
- # [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
- symbols+="%{%F{yellow}%}%#"
- [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
- symbols=$symbols" "
- [[ -n "$symbols" ]] && prompt_segment black default "$symbols "
- }
- }
- prompt_begin_2(){
- echo -e "\n"
- # CURRENT_BG='NONE'
- # prompt_segment blue black ' '
- }
- # End the prompt, closing any open segments
- prompt_end() {
- if [[ -n $CURRENT_BG ]]; then
- echo -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
- else
- echo -n "%{%k%}"
- fi
- echo -n "%{%f%}"
- CURRENT_BG=''
- }
- ### Prompt components
- # Each component will draw itself, and hide itself if no information needs to be shown
- # Context: user@hostname (who am I and where am I)
- prompt_context() {
- prompt_segment black green "%n@%m"
- }
- prompt_date() {
- prompt_segment blue black "$(date +%d.%m-%H:%M:%S)"
- prompt_segment black green ' %~'
- }
- vcs_info_wrapper() {
- vcs_info
- if [ -n "$vcs_info_msg_0_" ]; then
- echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
- fi
- }
- prompt_git() {
- prompt_segment yellow black "$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/')"
- }
- # Dir: current working directory
- #prompt_dir() {
- # prompt_segment black green ' %~'
- #}
- prompt_between(){
- prompt_segment black black ''
- # RPROMPT=$(build_prompt_right)
- #build_prompt_right() {
- CURRENT_BG='black'
- prompt_segment blue black ${vcs_info_msg_0_}
- #}
- }
- # Virtualenv: current working virtualenv
- prompt_virtualenv() {
- local virtualenv_path="$VIRTUAL_ENV"
- if [[ -n $virtualenv_path ]]; then
- prompt_segment blue black "(`basename $virtualenv_path`)"
- fi
- }
- # Status:
- # - was there an error
- # - am I root
- # - are there background jobs?
- zstyle ':vcs_info:*' enable git hg svn
- zstyle ':vcs_info:*' get-revision true
- zstyle ':vcs_info:*' check-for-changes true
- zstyle ':vcs_info:*' formats "%s \u25B6 [%r/%S] %b %u%c "
- zstyle ':vcs_info:*' stagedstr '%F{green}●'
- zstyle ':vcs_info:*' unstagedstr '%F{yellow}●'
- ## Main prompt
- #build_prompt() {
- # RETVAL=$?
- # prompt_begin
- # prompt_status
- # prompt_virtualenv
- # prompt_context
- # prompt_date
- # prompt_between
- # prompt_end
- # CURRENT_BG=''
- # prompt_begin_2
- ## prompt_dir
- # prompt_end
- #}
- #PROMPT='%{%f%b%k%}$(build_prompt)%{$reset_color%} '
- ## Main prompt
- build_prompt() {
- RETVAL=$?
- prompt_begin
- prompt_status
- prompt_virtualenv
- prompt_context
- prompt_date
- prompt_git
- prompt_between
- prompt_end
- CURRENT_BG=''
- prompt_begin_2
- # prompt_dir
- prompt_end
- }
- PROMPT='%{%f%b%k%}$(build_prompt)%{$reset_color%} '
Add Comment
Please, Sign In to add comment