summary refs log tree commit diff stats
path: root/tag-zsh/config/zsh
diff options
context:
space:
mode:
authorAlan Pearce2016-07-19 12:55:36 +0200
committerAlan Pearce2016-07-19 12:55:36 +0200
commit0f756df9afe3476cd4bef8fac54a5cbdb93080e8 (patch)
tree7430ddcc39c730e7ed85a48d9e7029d9a8be1648 /tag-zsh/config/zsh
parenta58e033e366f7a5776e6d53ac45b44a426aadbd2 (diff)
downloaddotfiles-0f756df9afe3476cd4bef8fac54a5cbdb93080e8.tar.lz
dotfiles-0f756df9afe3476cd4bef8fac54a5cbdb93080e8.tar.zst
dotfiles-0f756df9afe3476cd4bef8fac54a5cbdb93080e8.zip
zsh: Improve use of pure prompt
- Don’t initialise it in a dumb terminal
- Fallback to a “light” version if it’s not installed
Diffstat (limited to 'tag-zsh/config/zsh')
-rw-r--r--tag-zsh/config/zsh/zshrc37
1 files changed, 32 insertions, 5 deletions
diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc
index 7fcacd3..ddcdfbd 100644
--- a/tag-zsh/config/zsh/zshrc
+++ b/tag-zsh/config/zsh/zshrc
@@ -2,8 +2,8 @@
 source $ZPLUG_HOME/init.zsh
 
 zplug "zsh-users/zsh-completions"
-zplug "mafredri/zsh-async", use:async.zsh
-zplug "sindresorhus/pure", on:"mafredri/zsh-async", as:plugin, use:pure.zsh
+zplug "mafredri/zsh-async", use:async.zsh, if:"[[ $TERM != \"dumb\" ]]"
+zplug "sindresorhus/pure", on:"mafredri/zsh-async", as:plugin, use:pure.zsh, if:"[[ $TERM != \"dumb\" ]]"
 zplug "Tarrasch/zsh-autoenv", as:plugin
 zplug "clvv/fasd", hook-build:"PREFIX=$HOME make install"
 zplug "alanpearce/zsh-directory-history", at:"dirlog-as-zsh-function", as:command, use:"dirhist"
@@ -129,10 +129,37 @@ then
 	autoload -U compinit && compinit
 fi
 
-if zplug check sindresorhus/pure
+if [[ $TERM == "dumb" ]]
 then
-	autoload -Uz promptinit && promptinit
-	prompt pure &> /dev/null
+	PROMPT="> "
+else
+	if zplug check sindresorhus/pure
+	then
+		autoload -Uz promptinit && promptinit
+		prompt pure &> /dev/null
+	else
+		autoload -Uz vcs_info
+
+		zstyle ':vcs_info:*' enable git
+		zstyle ':vcs_info:*' use-simple true
+		# only export two msg variables from vcs_info
+		zstyle ':vcs_info:*' max-exports 2
+		# vcs_info_msg_0_ = ' %b' (for branch)
+		# vcs_info_msg_1_ = 'x%R' git top level (%R), x-prefix prevents creation of a named path (AUTO_NAME_DIRS)
+		zstyle ':vcs_info:git*' formats ' %b' 'x%R'
+		zstyle ':vcs_info:git*' actionformats ' %b|%a' 'x%R'
+
+		# show username@host if logged in through SSH
+		[[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username=' %F{242}%n@%m%f'
+
+		# show username@host if root, with username in white
+		[[ $UID -eq 0 ]] && prompt_pure_username=' %F{white}%n%f%F{242}@%m%f'
+
+		setopt prompt_subst
+		setopt prompt_cr
+		PROMPT='%F{blue}%~%f%F{242}${vcs_info_msg_0_}%f${prompt_pure_username}
+%(?.%F{magenta}.%F{red})>%f '
+	fi
 fi
 
 if zplug check clvv/fasd