From 8fc802bb7843ce0e32661cfa23f8947dc3ddea68 Mon Sep 17 00:00:00 2001 From: Tharre Date: Sun, 12 Aug 2018 00:05:51 +0200 Subject: zsh: replace oh-my-zsh with vanilla zsh configs oh-my-zsh introduces *a lot* of bloat, but I've barely been using any of it these past years. Just picking the options I use makes zsh easier to work with and debug (and hopefully faster). --- .zsh/prompt_custom_setup | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .zsh/prompt_custom_setup (limited to '.zsh/prompt_custom_setup') diff --git a/.zsh/prompt_custom_setup b/.zsh/prompt_custom_setup new file mode 100644 index 0000000..1fd02c4 --- /dev/null +++ b/.zsh/prompt_custom_setup @@ -0,0 +1,30 @@ +# my custom zsh theme +# requires `setopt PROMPT_SUBST` + + +# prefix hostname if ssh session was detected +function prompt_print_hostname() { + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] || [ -n "$SSH_TTY" ]; then + printf "%s" "%F{red}[%m]%f " + fi +} + +function git_prompt_parse_dirty() { + local FLAGS=("--porcelain" "--ignore-submodules=dirty") + local STATUS=$(command git status $FLAGS | tail -n1) + if [[ -n $STATUS ]]; then + printf "%s" "%F{214}*%f" + fi +} + +function git_prompt_info() { + local ref + ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 + + printf "%s" "%F{075} (${ref#refs/heads/}$(git_prompt_parse_dirty)%F{075})%f" +} + +PS1='$(prompt_print_hostname)%F{032}%(8~"[..]/")%7~$(git_prompt_info) %F{105}%1(j.[%j] .)%(!.#.$)%f ' +PS2='%F{red}\ %f' +RPS1="%(?..%F{red}:%?%f)" -- cgit v1.2.3-70-g09d2