Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
69507c95
Unverified
Commit
69507c95
authored
Mar 28, 2021
by
Marc Cornellà
Committed by
GitHub
Mar 28, 2021
Browse files
refactor(adben): refactor theme and degrade gracefully on missing dependencies (#9734)
parent
6e567841
Changes
1
Show whitespace changes
Inline
Side-by-side
themes/adben.zsh-theme
View file @
69507c95
...
@@ -29,11 +29,13 @@
...
@@ -29,11 +29,13 @@
# # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info:
# # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info:
# # https://pthree.org/2008/11/23/727/
# # https://pthree.org/2008/11/23/727/
# # enjoy!
# # enjoy!
########## COLOR ###########
########## COLOR ###########
for
COLOR
in
CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY
;
do
for
COLOR
in
CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY
;
do
eval
PR_
$COLOR
=
'%{$fg[${(L)COLOR}]%}'
eval
PR_
$COLOR
=
'%{$fg[${(L)COLOR}]%}'
eval
PR_BRIGHT_
$COLOR
=
'%{$fg_bold[${(L)COLOR}]%}'
eval
PR_BRIGHT_
$COLOR
=
'%{$fg_bold[${(L)COLOR}]%}'
done
done
PR_RESET
=
"%{
$reset_color
%}"
PR_RESET
=
"%{
$reset_color
%}"
RED_START
=
"
${
PR_RESET
}${
PR_GREY
}
<
${
PR_RESET
}${
PR_RED
}
<
${
PR_BRIGHT_RED
}
<
${
PR_RESET
}
"
RED_START
=
"
${
PR_RESET
}${
PR_GREY
}
<
${
PR_RESET
}${
PR_RED
}
<
${
PR_BRIGHT_RED
}
<
${
PR_RESET
}
"
RED_END
=
"
${
PR_RESET
}${
PR_BRIGHT_RED
}
>
${
PR_RESET
}${
PR_RED
}
>
${
PR_GREY
}
>
${
PR_RESET
}
"
RED_END
=
"
${
PR_RESET
}${
PR_BRIGHT_RED
}
>
${
PR_RESET
}${
PR_RED
}
>
${
PR_GREY
}
>
${
PR_RESET
}
"
...
@@ -44,14 +46,14 @@ DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
...
@@ -44,14 +46,14 @@ DIVISION="${PR_RESET}${PR_RED} < ${PR_RESET}"
VCS_DIRTY_COLOR
=
"
${
PR_RESET
}${
PR_YELLOW
}
"
VCS_DIRTY_COLOR
=
"
${
PR_RESET
}${
PR_YELLOW
}
"
VCS_CLEAN_COLOR
=
"
${
PR_RESET
}${
PR_GREEN
}
"
VCS_CLEAN_COLOR
=
"
${
PR_RESET
}${
PR_GREEN
}
"
VCS_SUFIX_COLOR
=
"
${
PR_RESET
}${
PR_RED
}
›
${
PR_RESET
}
"
VCS_SUFIX_COLOR
=
"
${
PR_RESET
}${
PR_RED
}
›
${
PR_RESET
}
"
# ########## COLOR ###########
#
########## SVN ###########
########## SVN ###########
ZSH_THEME_SVN_PROMPT_PREFIX
=
"
${
PR_RESET
}${
PR_RED
}
‹svn:"
ZSH_THEME_SVN_PROMPT_PREFIX
=
"
${
PR_RESET
}${
PR_RED
}
‹svn:"
ZSH_THEME_SVN_PROMPT_SUFFIX
=
""
ZSH_THEME_SVN_PROMPT_SUFFIX
=
""
ZSH_THEME_SVN_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_SVN_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_SVN_PROMPT_CLEAN
=
"
${
VCS_CLEAN_COLOR
}
✔
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_SVN_PROMPT_CLEAN
=
"
${
VCS_CLEAN_COLOR
}
✔
${
VCS_SUFIX_COLOR
}
"
# ########## SVN ###########
#
########## GIT ###########
########## GIT ###########
ZSH_THEME_GIT_PROMPT_PREFIX
=
"
${
PR_RESET
}${
PR_RED
}
‹git:"
ZSH_THEME_GIT_PROMPT_PREFIX
=
"
${
PR_RESET
}${
PR_RED
}
‹git:"
ZSH_THEME_GIT_PROMPT_SUFFIX
=
""
ZSH_THEME_GIT_PROMPT_SUFFIX
=
""
ZSH_THEME_GIT_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_GIT_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘
${
VCS_SUFIX_COLOR
}
"
...
@@ -62,25 +64,34 @@ ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖${PR_RESET}"
...
@@ -62,25 +64,34 @@ ZSH_THEME_GIT_PROMPT_DELETED="${PR_RESET}${PR_YELLOW} ✖${PR_RESET}"
ZSH_THEME_GIT_PROMPT_RENAMED
=
"
${
PR_RESET
}${
PR_YELLOW
}
➜
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_RENAMED
=
"
${
PR_RESET
}${
PR_YELLOW
}
➜
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_UNMERGED
=
"
${
PR_RESET
}${
PR_YELLOW
}
═
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_UNMERGED
=
"
${
PR_RESET
}${
PR_YELLOW
}
═
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_UNTRACKED
=
"
${
PR_RESET
}${
PR_YELLOW
}
✭
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_UNTRACKED
=
"
${
PR_RESET
}${
PR_YELLOW
}
✭
${
PR_RESET
}
"
# ########## GIT ###########
function
precmd
{
# Get a fortune quote
#gets the fortune
ps1_fortune
()
{
ps1_fortune
()
{
((
${
+commands[fortune]
}
))
&&
fortune
#Choose from all databases, regardless of whether they are considered "offensive"
}
fortune
-a
}
# Obtain a command tip
#obtains the tip
ps1_command_tip
()
{
ps1_command_tip
()
{
{
wget
-qO
- http://www.commandlinefu.com/commands/random/plaintext |
sed
1d |
sed
'/^$/d'
if
((
${
+commands[wget]
}
))
;
then
}
command
wget
-qO-
https://www.commandlinefu.com/commands/random/plaintext
prompt_header
()
{
elif
((
${
+commands[curl]
}
))
;
then
if
[[
"true"
==
"
$ENABLE_COMMAND_TIP
"
]]
;
then
command
curl
-fsL
https://www.commandlinefu.com/commands/random/plaintext
fi
}
|
sed
1d |
sed
'/^$/d'
}
function
precmd_adben
{
prompt_header
()
{
if
[[
"
$ENABLE_COMMAND_TIP
"
=
true
]]
;
then
ps1_command_tip
ps1_command_tip
else
else
ps1_fortune
ps1_fortune
fi
fi
}
}
PROMPT_HEAD
=
"
${
RED_START
}${
PR_YELLOW
}
$(
prompt_header
)
${
PR_RESET
}
"
PROMPT_HEAD
=
"
${
RED_START
}${
PR_YELLOW
}
$(
prompt_header
)
${
PR_RESET
}
"
# set a simple variable to show when in screen
# set a simple variable to show when in screen
if
[[
-n
"
${
WINDOW
}
"
]]
;
then
if
[[
-n
"
${
WINDOW
}
"
]]
;
then
SCREEN
=
""
SCREEN
=
""
...
@@ -88,7 +99,7 @@ function precmd {
...
@@ -88,7 +99,7 @@ function precmd {
}
}
# Context: user@directory or just directory
# Context: user@directory or just directory
prompt_context
()
{
prompt_context
()
{
if
[[
"
$USERNAME
"
!=
"
$DEFAULT_USER
"
||
-n
"
$SSH_CLIENT
"
]]
;
then
if
[[
"
$USERNAME
"
!=
"
$DEFAULT_USER
"
||
-n
"
$SSH_CLIENT
"
]]
;
then
echo
-n
"
${
PR_RESET
}${
PR_RED
}
$USERNAME
@%m
${
PR_RESET
}${
PR_BRIGHT_YELLOW
}
%~%<<
${
PR_RESET
}
"
echo
-n
"
${
PR_RESET
}${
PR_RED
}
$USERNAME
@%m
${
PR_RESET
}${
PR_BRIGHT_YELLOW
}
%~%<<
${
PR_RESET
}
"
else
else
...
@@ -96,19 +107,20 @@ prompt_context () {
...
@@ -96,19 +107,20 @@ prompt_context () {
fi
fi
}
}
set_prompt
()
{
########## SETUP ###########
# required for the prompt
setopt prompt_subst
autoload zsh/terminfo
# ######### PROMPT #########
# Required for the prompt
PROMPT
=
'${PROMPT_HEAD}
setopt prompt_subst
autoload zsh/terminfo
# Prompt
PROMPT
=
'${PROMPT_HEAD}
${RED_START}$(prompt_context)
${RED_START}$(prompt_context)
${GREEN_START_P1}'
${GREEN_START_P1}'
RPROMPT
=
'${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
RPROMPT
=
'${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
# Matching continuation prompt
# Matching continuation prompt
PROMPT2
=
'${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
PROMPT2
=
'${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
# ######### PROMPT #########
}
set_prompt
# Prompt head
autoload
-Uz
add-zsh-hook
add-zsh-hook precmd precmd_adben
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment