summary refs log tree commit diff
path: root/zshrc
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-12-18 19:44:36 -0800
committerFranck Cuny <franck@fcuny.net>2021-12-18 19:44:36 -0800
commit55f5f05b659cf95abbdae4233835bbc01d98c68e (patch)
treeff3030ba0b942099e0a6600757b9edc815adc22d /zshrc
parentemacs: enable camel case option for spell check (diff)
downloademacs.d-55f5f05b659cf95abbdae4233835bbc01d98c68e.tar.gz
zsh: update my prompt
Add the host's name at the beginning of the prompt, with a background
color. Also add some information about git at the end of the prompt.
Diffstat (limited to 'zshrc')
-rw-r--r--zshrc24
1 files changed, 23 insertions, 1 deletions
diff --git a/zshrc b/zshrc
index f54f769..dcc8242 100644
--- a/zshrc
+++ b/zshrc
@@ -14,7 +14,20 @@ setopt always_to_end
 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
 
 autoload -U select-word-style
-select-word-style bash
+autoload -U colors && colors
+
+autoload -Uz vcs_info add-zsh-hook
+setopt prompt_subst
+
+add-zsh-hook precmd vcs_info
+# Enable checking for (un)staged changes, enabling use of %u and %c
+zstyle ':vcs_info:*' check-for-changes true
+# Set custom strings for an unstaged vcs repo changes (*) and staged changes (+)
+zstyle ':vcs_info:*' unstagedstr "%F{yellow}●%f"
+zstyle ':vcs_info:*' stagedstr   "%F{green}●%f"
+# Set the format of the Git information for vcs_info
+zstyle ':vcs_info:git:*' formats       " (%b%c%u)"
+zstyle ':vcs_info:git:*' actionformats " (%b|%a%u%c)"
 
 # Print timing statistics for everything which takes longer than 5 seconds of
 # user + system time ('sleep 6' does not work because of 0% user/system time!).
@@ -24,6 +37,15 @@ REPORTTIME=5
 # based on EDITOR/VISUAL).
 bindkey -e
 
+PROMPT='%K{cyan}%F{black}%m%k%f %~%F{red}${vcs_info_msg_0_}%f %# '
+
+# For tramp (emacs).
+if [ "$TERM" = "dumb" ]; then
+  unset PROMPT
+  PS1='$ '
+  unsetopt zle
+fi
+
 # The next line updates PATH for the Google Cloud SDK.
 if [ -f '/home/fcuny/workspace/google-cloud-sdk/path.zsh.inc' ]; then . '/home/fcuny/workspace/google-cloud-sdk/path.zsh.inc'; fi