]> arthur.barton.de Git - ax-zsh.git/commitdiff
Add "powerline-shell" plugin
authorAlexander Barton <alex@barton.de>
Sun, 4 Oct 2015 01:29:36 +0000 (03:29 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 4 Oct 2015 01:29:36 +0000 (03:29 +0200)
plugins/powerline-shell/README.md [new file with mode: 0644]
plugins/powerline-shell/powerline-shell.zshrc [new file with mode: 0644]

diff --git a/plugins/powerline-shell/README.md b/plugins/powerline-shell/README.md
new file mode 100644 (file)
index 0000000..6f89f65
--- /dev/null
@@ -0,0 +1,13 @@
+## powerline-shell
+
+"powerline-shell" (see https://github.com/milkbikis/powerline-shell)
+integration for ZSH.
+
+### Configuration
+
+- `POWERLINE_SHELL` ($HOME/powerline-shell.py; $HOME/.powerline-shell.py)
+- `POWERLINE_SHELL_MODE` (compatible)
+- `POWERLINE_SHELL_CWD_MODE` (fancy)
+- `POWERLINE_SHELL_CWD_DEPTH` (4)
+
+See `powerline-shell.py --help` for details.
diff --git a/plugins/powerline-shell/powerline-shell.zshrc b/plugins/powerline-shell/powerline-shell.zshrc
new file mode 100644 (file)
index 0000000..36f6a6f
--- /dev/null
@@ -0,0 +1,39 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# powerline-shell.zshrc: "powerline-shell" integration.
+
+[[ "$TERM" = "linux" ]] && return
+
+if [[ -z "$POWERLINE_SHELL" ]]; then
+       for p (
+               "$HOME/powerline-shell.py"
+               "$HOME/.powerline-shell.py"
+       ); do
+               [[ -r "$p" ]] || continue
+               POWERLINE_SHELL="$p"
+               break
+       done
+       unset p
+fi
+if [[ ! -r "$POWERLINE_SHELL" ]]; then
+       echo "Powerline shell extension not found/readable!"
+       return
+fi
+
+function powerline_precmd() {
+       PS1="$(
+               $POWERLINE_SHELL \
+                       --shell zsh \
+                       --mode ${POWERLINE_SHELL_MODE:-"compatible"} \
+                       --colorize-hostname \
+                       --cwd-mode ${POWERLINE_SHELL_CWD_MODE:-"fancy"} \
+                       --cwd-max-depth ${POWERLINE_SHELL_CWD_DEPTH:-4} \
+                       $? 2>/dev/null
+       )"
+}
+
+# Make sure "powerline_precmd" isn't installed already
+for s in "${precmd_functions[@]}"; do
+       [[ "$s" = "powerline_precmd" ]] && return
+done
+
+precmd_functions+=(powerline_precmd)