Giving the prompt a nice refresh
This commit is contained in:
@@ -1,26 +1,37 @@
|
|||||||
|
# heavily inspired by the wonderful pure theme
|
||||||
|
# https://github.com/sindresorhus/pure
|
||||||
|
|
||||||
|
# For my own and others sanity
|
||||||
|
# git:
|
||||||
|
# %b => current branch
|
||||||
|
# %a => current action (rebase/merge)
|
||||||
|
# prompt:
|
||||||
|
# %F => color dict
|
||||||
|
# %f => reset color
|
||||||
|
# %~ => current path
|
||||||
|
# %* => time
|
||||||
|
# %n => username
|
||||||
|
# %m => shortname host
|
||||||
|
# %(?..) => prompt conditional - %(condition.true.false)
|
||||||
|
|
||||||
|
autoload -Uz vcs_info
|
||||||
|
zstyle ':vcs_info:*' enable git # You can add hg too if needed: `git hg`
|
||||||
|
zstyle ':vcs_info:git*' formats ' %b'
|
||||||
|
zstyle ':vcs_info:git*' actionformats ' %b|%a'
|
||||||
|
|
||||||
autoload colors && colors
|
autoload colors && colors
|
||||||
|
|
||||||
git_branch() {
|
|
||||||
echo $(/usr/bin/git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'})
|
|
||||||
}
|
|
||||||
|
|
||||||
git_dirty() {
|
git_dirty() {
|
||||||
st=$(/usr/bin/git status 2>/dev/null | tail -n 1)
|
# check if we're in a git repo
|
||||||
if [[ $st == "" ]]
|
command git rev-parse --is-inside-work-tree &>/dev/null || return
|
||||||
then
|
|
||||||
echo ""
|
|
||||||
else
|
|
||||||
if [[ $st == "nothing to commit (working directory clean)" ]]
|
|
||||||
then
|
|
||||||
echo "%{$fg_bold[green]%}✔ $(git_prompt_info)%{$reset_color%}"
|
|
||||||
else
|
|
||||||
echo "%{$fg_bold[red]%}✗ $(git_prompt_info)%{$reset_color%}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
unpushed() {
|
# check if it's dirty
|
||||||
/usr/bin/git cherry -v @{upstream} 2>/dev/null
|
command git diff --quiet --ignore-submodules HEAD &>/dev/null;
|
||||||
|
if [[ $? -eq 1 ]]; then
|
||||||
|
echo "%F{red}✗%f"
|
||||||
|
else
|
||||||
|
echo "%F{green}✔%f"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
git_prompt_info() {
|
git_prompt_info() {
|
||||||
@@ -29,8 +40,8 @@ git_prompt_info() {
|
|||||||
echo "${ref#refs/heads/}"
|
echo "${ref#refs/heads/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
need_push() {
|
needs_push() {
|
||||||
if [[ $(unpushed) == "" ]]
|
if [[ $(git cherry -v @{upstream} 2>/dev/null) == "" ]]
|
||||||
then
|
then
|
||||||
echo " "
|
echo " "
|
||||||
else
|
else
|
||||||
@@ -38,6 +49,7 @@ need_push() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# indicate a job (for example, vim) has been backgrounded
|
||||||
suspended_jobs() {
|
suspended_jobs() {
|
||||||
sj=$(jobs 2>/dev/null | tail -n 1)
|
sj=$(jobs 2>/dev/null | tail -n 1)
|
||||||
if [[ $sj == "" ]]; then
|
if [[ $sj == "" ]]; then
|
||||||
@@ -47,9 +59,10 @@ suspended_jobs() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_name(){
|
precmd() {
|
||||||
echo "%{$fg_bold[cyan]%}%1/%\/%{$reset_color%}"
|
vcs_info
|
||||||
|
print -P '\n%F{blue}%~ `git_dirty`%F{236}$vcs_info_msg_0_%f'
|
||||||
}
|
}
|
||||||
|
|
||||||
export PROMPT=$'$(directory_name) %{$fg_bold[magenta]%}➜%{$reset_color%} '
|
export PROMPT='%(?.%F{magenta}.%F{red})❯%f '
|
||||||
export RPROMPT=$'$(git_dirty)$(need_push)$(suspended_jobs)'
|
export RPROMPT='`suspended_jobs`'
|
||||||
|
|||||||
Reference in New Issue
Block a user