zshrc: Add an option to get the old simple prompt
This commit is contained in:
parent
eb1a601086
commit
b59c4cf08c
1 changed files with 26 additions and 12 deletions
28
zshrc
28
zshrc
|
@ -9,6 +9,7 @@ local ls=""
|
|||
local ls_color="auto"
|
||||
local ls_on_cd="yes"
|
||||
local ls_on_init="no"
|
||||
local simple_prompt="no"
|
||||
|
||||
bindkey -v
|
||||
# history-incremental-search-backward is much more useful than
|
||||
|
@ -67,22 +68,35 @@ case $TERM_PROGRAM in
|
|||
;;
|
||||
esac
|
||||
|
||||
if [ "$simple_prompt" = yes ]; then
|
||||
set_prompt() {
|
||||
PS1="%F{23}%m %F{29}%c$1%F{36}%(!.#.>)%f "
|
||||
local branch
|
||||
[ -n "$1" ] && branch="%F{black}%B(%b%F{cyan}$1%F{black}%B)%b%f"
|
||||
|
||||
PS1="%m:%c$branch%B%(!.#.$)%b "
|
||||
PS2="%B>%b "
|
||||
RPS1="%(1j.%F{yellow}%j%f.)%(?..%(1j. .)%F{red}%?%f)"
|
||||
RPS2="%(1_.%F{black}%B(%_%)%b%f.)"
|
||||
}
|
||||
else
|
||||
set_prompt() {
|
||||
local branch
|
||||
[ -n "$1" ] && branch="%F{36}(%F{78}$1%F{36})"
|
||||
|
||||
PS1="%F{23}%m %F{29}%c$branch%F{36}%(!.#.>)%f "
|
||||
PS2="%B>%b "
|
||||
RPS1="%(1j.%F{yellow}%j%f.)%(?..%(1j. .)%F{red}%?%f)"
|
||||
RPS2="%(1_.%F{black}%B(%_%)%b%f.)"
|
||||
}
|
||||
fi
|
||||
set_prompt
|
||||
|
||||
__precmd() {
|
||||
__update_terminal_cwd
|
||||
|
||||
local branch_name=$(git symbolic-ref HEAD 2>/dev/null)
|
||||
branch_name=${branch_name##refs/heads/}
|
||||
if [ -n "$branch_name" -a "$branch_name" != master ]; then
|
||||
local branch="%F{36}(%F{78}$branch_name%F{36})"
|
||||
fi
|
||||
local branch=$(git symbolic-ref HEAD 2>/dev/null)
|
||||
branch=${branch##refs/heads/}
|
||||
[ "$branch" = master ] && branch=""
|
||||
set_prompt $branch
|
||||
}
|
||||
|
||||
|
@ -201,5 +215,5 @@ alias pws="__pw -k ~/.cryptopassphrase-server.key"
|
|||
ixio() { curl -F 'f:1=<-' ix.io }
|
||||
0x0st() { curl -F'file=@-' https://0x0.st }
|
||||
|
||||
unset fgrep grep grep_color ls ls_color ls_on_cd ls_on_init
|
||||
unset fgrep grep grep_color ls ls_color ls_on_cd ls_on_init simple_prompt
|
||||
unset HISTFILE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue