summaryrefslogtreecommitdiffstats
path: root/.zsh/rc/15prompt
blob: 5eb75ec0d1a8846e4da3e25eb9ec6a220a64b964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#--------------------
# Terminal title
#--------------------
# also found somewhere
prompt_eof_setup() {
  # preexec() is run after you press enter on your command but before the command is run.
  preexec() {
    # define screen/terminal title with the current command (http://aperiodic.net/phil/prompt/)
    case $TERM in
      rxvt-unicode*)
        printf '\33]2;%s\007' $1
      ;;
      screen*)
        local CMD=${1[(wr)^(*=*|sudo|ssh|exec|-*)]}
        printf '\ek%s\e\\' $CMD;;
    esac
  }
}

prompt_eof_setup "$@"




# function to show the current git branch in prompt
parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
} 

#--------------------
# Prompt
#--------------------
# necessary if you want to use functions in the prompt
# without this they wouldn't be run again
precmd () {
# this has to be on the edge or you have some spaces in the prompt 
# if you have any workaround please tell
PS1="${fg_light_red}$USERNAME${fg_no_colour}@${fg_light_green}%m${fg_no_colour} \
- ${fg_light_blue}%~${fg_no_colour} ${fg_purple}$(parse_git_branch)${fg_no_colour}
[${fg_cyan}%*${fg_no_colour}] > " 
}

## Spelling prompt
SPROMPT='zsh: correct '%R' to '%r' ? ([Y]es/[N]o/[E]dit/[A]bort) '