mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Merge 3609af76c2 into d05b2010ff
This commit is contained in:
commit
a69526565b
4 changed files with 70 additions and 7 deletions
13
lib/git.zsh
13
lib/git.zsh
|
|
@ -1,7 +1,12 @@
|
||||||
# get the name of the branch we are on
|
# get the name of the branch we are on
|
||||||
function git_prompt_info() {
|
function git_prompt_info() {
|
||||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
if parse_git_dirty; then
|
||||||
|
INFO="$ZSH_THEME_GIT_PROMPT_DIRTY_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||||
|
else
|
||||||
|
INFO="$ZSH_THEME_GIT_PROMPT_CLEAN_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||||
|
fi
|
||||||
|
echo "$ZSH_THEME_GIT_PROMPT_PREFIX$INFO$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -11,11 +16,7 @@ parse_git_dirty() {
|
||||||
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
||||||
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
||||||
fi
|
fi
|
||||||
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
|
[[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]] && return 0 || return 1
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
|
||||||
else
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@ PS1="%n@%m:%~%# "
|
||||||
# git theming default: Variables for theming the git info prompt
|
# git theming default: Variables for theming the git info prompt
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
|
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
||||||
|
ZSH_THEME_GIT_PROMPT_DIRTY_PREFIX="" # Text to display if the branch is dirty
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
||||||
|
ZSH_THEME_GIT_PROMPT_CLEAN_PREFIX="" # Text to display if the branch is clean
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
||||||
|
|
||||||
# Setup the prompt with pretty colors
|
# Setup the prompt with pretty colors
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,39 @@ function start_agent {
|
||||||
. ${GPG_ENV} > /dev/null
|
. ${GPG_ENV} > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ -n $SSH_AUTH_SOCK && -n $SSH_CONNECTION ]]; then
|
||||||
|
case $GPG_USE_FORWARDED_SSH_AGENT in
|
||||||
|
'always')
|
||||||
|
FOWARDED_AGENT=1
|
||||||
|
;;
|
||||||
|
'never')
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Use forwarded ssh-agent?(y/N) "
|
||||||
|
read
|
||||||
|
[[ $REPLY == 'y' ]] && FOWARDED_AGENT=1
|
||||||
|
esac
|
||||||
|
if [[ -n $FOWARDED_AGENT ]]; then
|
||||||
|
SSH_AUTH_SOCK_TMP=$SSH_AUTH_SOCK
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Source GPG agent settings, if applicable
|
# Source GPG agent settings, if applicable
|
||||||
if [ -f "${GPG_ENV}" ]; then
|
if [ -f "${GPG_ENV}" ]; then
|
||||||
. ${GPG_ENV} > /dev/null
|
. ${GPG_ENV} > /dev/null
|
||||||
ps -ef | grep ${SSH_AGENT_PID} | grep gpg-agent > /dev/null || {
|
command ps -ef | grep ${SSH_AGENT_PID} | grep gpg-agent > /dev/null || {
|
||||||
start_agent;
|
start_agent;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
start_agent;
|
start_agent;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[[ -n $FOWARDED_AGENT ]] && SSH_AUTH_SOCK=$SSH_AUTH_SOCK_TMP
|
||||||
|
|
||||||
export GPG_AGENT_INFO
|
export GPG_AGENT_INFO
|
||||||
export SSH_AUTH_SOCK
|
export SSH_AUTH_SOCK
|
||||||
export SSH_AGENT_PID
|
export SSH_AGENT_PID
|
||||||
|
|
||||||
|
|
||||||
GPG_TTY=$(tty)
|
GPG_TTY=$(tty)
|
||||||
export GPG_TTY
|
export GPG_TTY
|
||||||
|
|
|
||||||
40
themes/nc.zsh-theme
Normal file
40
themes/nc.zsh-theme
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
ps1='%S%B[%n@%m]%s%b %! %3(~|~/%B...%b/%2~|%~)$(git_prompt_info)%B%F{green}]%f%b '
|
||||||
|
ps2='%_%B%F{green}>%f%b '
|
||||||
|
|
||||||
|
PROMPT=$ps1
|
||||||
|
PROMPT2=$ps2
|
||||||
|
RPS1='%F{yellow}$(git_prompt_status)%f %(?|%F{green}%?%f|%F{yellow}%?%f)(%j) %T'
|
||||||
|
|
||||||
|
function zle-keymap-select zle-line-init {
|
||||||
|
if [[ $KEYMAP == 'vicmd' ]] {
|
||||||
|
PROMPT=${ps1//green/red}
|
||||||
|
PROMPT2=${ps2//green/red}
|
||||||
|
} else {
|
||||||
|
PROMPT=$ps1
|
||||||
|
PROMPT2=$ps2
|
||||||
|
}
|
||||||
|
zle reset-prompt
|
||||||
|
}
|
||||||
|
function zle-line-finish {
|
||||||
|
PROMPT=$ps1
|
||||||
|
PROMPT2=$ps2
|
||||||
|
zle reset-prompt
|
||||||
|
}
|
||||||
|
|
||||||
|
zle -N zle-line-init
|
||||||
|
zle -N zle-line-finish
|
||||||
|
zle -N zle-keymap-select
|
||||||
|
|
||||||
|
ZSH_THEME_GIT_PROMPT_PREFIX=" git:"
|
||||||
|
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
||||||
|
ZSH_THEME_GIT_PROMPT_CLEAN_PREFIX="%{$fg[green]%}("
|
||||||
|
ZSH_THEME_GIT_PROMPT_DIRTY_PREFIX="%{$fg[yellow]%}("
|
||||||
|
ZSH_THEME_GIT_PROMPT_CLEAN=")%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_DIRTY=")%{$reset_color%}"
|
||||||
|
|
||||||
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="?"
|
||||||
|
ZSH_THEME_GIT_PROMPT_ADDED="+"
|
||||||
|
ZSH_THEME_GIT_PROMPT_MODIFIED="!"
|
||||||
|
ZSH_THEME_GIT_PROMPT_RENAMED="R"
|
||||||
|
ZSH_THEME_GIT_PROMPT_DELETED="-"
|
||||||
|
ZSH_THEME_GIT_PROMPT_UNMERGED="U"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue