]> arthur.barton.de Git - ax-zsh.git/blob - plugins/powerline-shell/powerline-shell.zshrc
Add "powerline-shell" plugin
[ax-zsh.git] / plugins / powerline-shell / powerline-shell.zshrc
1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # powerline-shell.zshrc: "powerline-shell" integration.
3
4 [[ "$TERM" = "linux" ]] && return
5
6 if [[ -z "$POWERLINE_SHELL" ]]; then
7         for p (
8                 "$HOME/powerline-shell.py"
9                 "$HOME/.powerline-shell.py"
10         ); do
11                 [[ -r "$p" ]] || continue
12                 POWERLINE_SHELL="$p"
13                 break
14         done
15         unset p
16 fi
17 if [[ ! -r "$POWERLINE_SHELL" ]]; then
18         echo "Powerline shell extension not found/readable!"
19         return
20 fi
21
22 function powerline_precmd() {
23         PS1="$(
24                 $POWERLINE_SHELL \
25                         --shell zsh \
26                         --mode ${POWERLINE_SHELL_MODE:-"compatible"} \
27                         --colorize-hostname \
28                         --cwd-mode ${POWERLINE_SHELL_CWD_MODE:-"fancy"} \
29                         --cwd-max-depth ${POWERLINE_SHELL_CWD_DEPTH:-4} \
30                         $? 2>/dev/null
31         )"
32 }
33
34 # Make sure "powerline_precmd" isn't installed already
35 for s in "${precmd_functions[@]}"; do
36         [[ "$s" = "powerline_precmd" ]] && return
37 done
38
39 precmd_functions+=(powerline_precmd)