diff options
author | Mateja <mail@matejamaric.com> | 2021-06-20 22:01:05 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-06-20 22:01:05 +0200 |
commit | 5c68b137a6b1ecf59e4c89ac5ca9352c0ef3e849 (patch) | |
tree | c4b91179b698d74b2f8b0c7ea92266678e556f65 /.config/zsh/zsh-prompt | |
parent | 740c3cc87b71c9f7a68f83f5c6a1434600f04220 (diff) | |
download | dotfiles-5c68b137a6b1ecf59e4c89ac5ca9352c0ef3e849.tar.gz dotfiles-5c68b137a6b1ecf59e4c89ac5ca9352c0ef3e849.zip |
Added zsh configuration files.
Diffstat (limited to '.config/zsh/zsh-prompt')
-rw-r--r-- | .config/zsh/zsh-prompt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.config/zsh/zsh-prompt b/.config/zsh/zsh-prompt new file mode 100644 index 0000000..f0a86dc --- /dev/null +++ b/.config/zsh/zsh-prompt @@ -0,0 +1,40 @@ +#!/bin/sh + +## autoload vcs and colors +autoload -Uz vcs_info +autoload -U colors && colors + +# enable only git +zstyle ':vcs_info:*' enable git + +# setup a hook that runs before every ptompt. +precmd_vcs_info() { vcs_info } +precmd_functions+=( precmd_vcs_info ) +setopt prompt_subst + +# add a function to check for untracked files in the directory. +# from https://github.com/zsh-users/zsh/blob/master/Misc/vcs_info-examples +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +# ++vi-git-untracked(){ + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ + git status --porcelain | grep '??' &> /dev/null ; then + # This will show the marker if there are any untracked files in repo. + # If instead you want to show the marker only if there are untracked + # files in $PWD, use: + #[[ -n $(git ls-files --others --exclude-standard) ]] ; then + hook_com[staged]+='!' # signify new files with a bang + fi +} + +zstyle ':vcs_info:*' check-for-changes true +# zstyle ':vcs_info:git:*' formats " %r/%S %b %m%u%c " +zstyle ':vcs_info:git:*' formats " %{$fg[blue]%}(%{$fg[red]%}%m%u%c%{$fg[yellow]%}%{$fg[magenta]%} %b%{$fg[blue]%})" + +# format our main prompt for hostname current folder, and permissions. +PROMPT="%B%{$fg[blue]%}[%{$fg[white]%}%n%{$fg[red]%}@%{$fg[white]%}%m%{$fg[blue]%}] %(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )%{$fg[cyan]%}%c%{$reset_color%}" +# PROMPT="%{$fg[green]%}%n@%m %~ %{$reset_color%}%#> " +PROMPT+="\$vcs_info_msg_0_ " +# TODO look into this for more colors +# https://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ +# also ascii escape codes |