summary refs log tree commit diff stats
path: root/tag-zsh/config
diff options
context:
space:
mode:
authorAlan Pearce2016-07-23 12:09:29 +0200
committerAlan Pearce2016-07-23 12:09:29 +0200
commit8b5d570a7c9d1d139987d979f8a027174ba7f049 (patch)
tree3e8c327a16f2fc59558f55db5e67fdfc96924777 /tag-zsh/config
parent11b2efdab5fad273d0dc98c92ae226d7fdb2388a (diff)
parent84e5cb9fcc9faa1c846e12ec7234e24c18f1fab7 (diff)
downloaddotfiles-8b5d570a7c9d1d139987d979f8a027174ba7f049.tar.lz
dotfiles-8b5d570a7c9d1d139987d979f8a027174ba7f049.tar.zst
dotfiles-8b5d570a7c9d1d139987d979f8a027174ba7f049.zip
Merge branch 'master' of git.alanpearce.uk:alan/dotfiles
Diffstat (limited to 'tag-zsh/config')
-rw-r--r--tag-zsh/config/zsh/zshrc46
1 files changed, 39 insertions, 7 deletions
diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc
index 3e568cd..63384f5 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"
@@ -96,6 +96,11 @@ bindkey '\e	' hist-complete
 zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}'
 zstyle ':completion:*' completer _expand _complete _match
 
+if [[ -z $SSH_AUTH_SOCK && $commands[ssh-agent] ]]
+then
+	eval $(ssh-agent)
+fi
+
 if zplug check Tarrasch/zsh-autoenv
 then
 	AUTOENV_FILE_ENTER=.envrc
@@ -124,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
@@ -151,8 +183,8 @@ fi
 if zplug check alanpearce/zsh-directory-history
 then
 	unsetopt flow_control 			# Let me use ^S and ^Q
-	# bindkey '\e[A' directory-history-search-backward
-	# bindkey '\e[B' directory-history-search-forward
+	bindkey '\e[B' directory-history-search-backward
+	bindkey '\e[A' directory-history-search-forward
 
 	bindkey -M emacs '^R' history-substring-search-up
 	bindkey -M emacs '^S' history-substring-search-down