Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
a94e2634
Unverified
Commit
a94e2634
authored
Nov 30, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(adben): simplify used variables and %-quote prompt functions
Closes #10474 Co-authored-by:
Tom Payne
<
twpayne@gmail.com
>
parent
428f8151
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
58 deletions
+49
-58
expect.txt
.github/actions/spelling/expect.txt
+0
-1
adben.zsh-theme
themes/adben.zsh-theme
+49
-57
No files found.
.github/actions/spelling/expect.txt
View file @
a94e2634
...
@@ -3688,7 +3688,6 @@ Subsubcommands
...
@@ -3688,7 +3688,6 @@ Subsubcommands
Subsubsubcommands
Subsubsubcommands
sudo
sudo
sudoedit
sudoedit
SUFIX
suitenames
suitenames
sunaku
sunaku
sunion
sunion
...
...
themes/adben.zsh-theme
View file @
a94e2634
...
@@ -32,42 +32,44 @@
...
@@ -32,42 +32,44 @@
########## 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}]%}'
print
-v
"PR_
$COLOR
"
"%b%{
$fg
[
${
(L)COLOR
}
]%}"
eval
PR_BRIGHT_
$COLOR
=
'%{$fg_bold[${(L)COLOR}]%}'
print
-v
"PR_BRIGHT_
$COLOR
"
"%B%{
$fg
[
${
(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_END
=
"
${
PR_RESET
}${
PR_BRIGHT_RED
}
>
${
PR_RESET
}${
PR_RED
}
>
${
PR_GREY
}
>
${
PR_RESET
}
"
RED_START
=
"
${
PR_GREY
}
<
${
PR_RED
}
<
${
PR_BRIGHT_RED
}
<
${
PR_RESET
}
"
GREEN_END
=
"
${
PR_RESET
}${
PR_BRIGHT_GREEN
}
>
${
PR_RESET
}${
PR_GREEN
}
>
${
PR_GREY
}
>
${
PR_RESET
}
"
RED_END
=
"
${
PR_BRIGHT_RED
}
>
${
PR_RED
}
>
${
PR_GREY
}
>
${
PR_RESET
}
"
GREEN_BASE_START
=
"
${
PR_RESET
}${
PR_GREY
}
>
${
PR_RESET
}${
PR_GREEN
}
>
${
PR_BRIGHT_GREEN
}
>
${
PR_RESET
}
"
GREEN_START
=
"
${
PR_GREY
}
>
${
PR_GREEN
}
>
${
PR_BRIGHT_GREEN
}
>
${
PR_RESET
}
"
GREEN_START_P1
=
"
${
PR_RESET
}${
GREEN_BASE_START
}${
PR_RESET
}
"
GREEN_END
=
"
${
PR_BRIGHT_GREEN
}
>
${
PR_GREEN
}
>
${
PR_GREY
}
>
${
PR_RESET
}
"
DIVISION
=
"
${
PR_RESET
}${
PR_RED
}
<
${
PR_RESET
}
"
VCS_DIRTY_COLOR
=
"
${
PR_RESET
}${
PR_YELLOW
}
"
########## VCS ###########
VCS_CLEAN_COLOR
=
"
${
PR_RESET
}${
PR_GREEN
}
"
VCS_DIRTY_COLOR
=
"
${
PR_YELLOW
}
"
VCS_SUFIX_COLOR
=
"
${
PR_RESET
}${
PR_RED
}
›
${
PR_RESET
}
"
VCS_CLEAN_COLOR
=
"
${
PR_GREEN
}
"
VCS_SUFFIX_COLOR
=
"
${
PR_RED
}
›
${
PR_RESET
}
"
########## SVN ###########
########## SVN ###########
ZSH_THEME_SVN_PROMPT_PREFIX
=
"
${
PR_RE
SET
}${
PR_RE
D
}
‹svn:"
ZSH_THEME_SVN_PROMPT_PREFIX
=
"
${
PR_RED
}
‹svn:"
ZSH_THEME_SVN_PROMPT_SUFFIX
=
""
ZSH_THEME_SVN_PROMPT_SUFFIX
=
"
${
VCS_SUFFIX_COLOR
}
"
ZSH_THEME_SVN_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_SVN_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘"
ZSH_THEME_SVN_PROMPT_CLEAN
=
"
${
VCS_CLEAN_COLOR
}
✔
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_SVN_PROMPT_CLEAN
=
"
${
VCS_CLEAN_COLOR
}
✔"
########## GIT ###########
########## GIT ###########
ZSH_THEME_GIT_PROMPT_PREFIX
=
"
${
PR_RE
SET
}${
PR_RE
D
}
‹git:"
ZSH_THEME_GIT_PROMPT_PREFIX
=
"
${
PR_RED
}
‹git:"
ZSH_THEME_GIT_PROMPT_SUFFIX
=
""
ZSH_THEME_GIT_PROMPT_SUFFIX
=
"
${
VCS_SUFFIX_COLOR
}
"
ZSH_THEME_GIT_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_GIT_PROMPT_DIRTY
=
"
${
VCS_DIRTY_COLOR
}
✘"
ZSH_THEME_GIT_PROMPT_CLEAN
=
"
${
VCS_CLEAN_COLOR
}
✔
${
VCS_SUFIX_COLOR
}
"
ZSH_THEME_GIT_PROMPT_CLEAN
=
"
${
VCS_CLEAN_COLOR
}
✔"
ZSH_THEME_GIT_PROMPT_ADDED
=
"
${
PR_
RESET
}${
PR_YELLOW
}
✚
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_ADDED
=
"
${
PR_
YELLOW
}
✚
"
ZSH_THEME_GIT_PROMPT_MODIFIED
=
"
${
PR_
RESET
}${
PR_YELLOW
}
✹
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_MODIFIED
=
"
${
PR_
YELLOW
}
✹
"
ZSH_THEME_GIT_PROMPT_DELETED
=
"
${
PR_
RESET
}${
PR_YELLOW
}
✖
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_DELETED
=
"
${
PR_
YELLOW
}
✖
"
ZSH_THEME_GIT_PROMPT_RENAMED
=
"
${
PR_
RESET
}${
PR_YELLOW
}
➜
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_RENAMED
=
"
${
PR_
YELLOW
}
➜
"
ZSH_THEME_GIT_PROMPT_UNMERGED
=
"
${
PR_
RESET
}${
PR_YELLOW
}
═
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_UNMERGED
=
"
${
PR_
YELLOW
}
═
"
ZSH_THEME_GIT_PROMPT_UNTRACKED
=
"
${
PR_
RESET
}${
PR_YELLOW
}
✭
${
PR_RESET
}
"
ZSH_THEME_GIT_PROMPT_UNTRACKED
=
"
${
PR_
YELLOW
}
✭
"
# Get a fortune quote
# Get a fortune quote
ps1_fortune
()
{
ps1_fortune
()
{
((
${
+commands[fortune]
}
))
&&
fortune
if
((
${
+commands[fortune]
}
))
;
then
fortune
fi
}
}
# Obtain a command tip
# Obtain a command tip
...
@@ -77,33 +79,27 @@ ps1_command_tip() {
...
@@ -77,33 +79,27 @@ ps1_command_tip() {
command
wget
-qO-
https://www.commandlinefu.com/commands/random/plaintext
command
wget
-qO-
https://www.commandlinefu.com/commands/random/plaintext
elif
((
${
+commands[curl]
}
))
;
then
elif
((
${
+commands[curl]
}
))
;
then
command
curl
-fsL
https://www.commandlinefu.com/commands/random/plaintext
command
curl
-fsL
https://www.commandlinefu.com/commands/random/plaintext
fi
fi
}
|
sed
1d |
sed
'
/^$/d'
}
|
sed
'1d;
/^$/d'
}
}
function
precmd_adben
{
# Show prompt header (fortune / command tip)
prompt_header
()
{
prompt_header
()
{
if
[[
"
$ENABLE_COMMAND_TIP
"
=
true
]]
;
then
local
header
=
$(
ps1_command_tip
case
"
${
ENABLE_COMMAND_TIP
:-}
"
in
else
true
)
ps1_command_tip
;;
ps1_fortune
*
)
ps1_fortune
;;
fi
esac
}
)
PROMPT_HEAD
=
"
${
RED_START
}${
PR_YELLOW
}$(
prompt_header
)${
PR_RESET
}
"
# Make sure to quote % so that they're not expanded by the prompt
echo
-n
"
${
header
:gs/%/%%
}
"
# set a simple variable to show when in screen
if
[[
-n
"
${
WINDOW
}
"
]]
;
then
SCREEN
=
""
fi
}
}
# 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
}
%n@%m"
else
echo
-n
"
${
PR_RESET
}${
PR_BRIGHT_YELLOW
}
%~%<<
${
PR_RESET
}
"
fi
fi
}
}
...
@@ -111,16 +107,12 @@ prompt_context() {
...
@@ -111,16 +107,12 @@ prompt_context() {
# Required for the prompt
# Required for the prompt
setopt prompt_subst
setopt prompt_subst
autoload zsh/terminfo
# Prompt
# Prompt: header, context (user@host), directory
PROMPT
=
'${PROMPT_HEAD}
PROMPT
=
"
${
RED_START
}${
PR_YELLOW
}
\$
(prompt_header)
${
PR_RESET
}
${RED_START}$(prompt_context)
${
RED_START
}
\$
(prompt_context)
${
PR_BRIGHT_YELLOW
}
%~
${
PR_RESET
}
${GREEN_START_P1}'
${
GREEN_START
}
"
RPROMPT
=
'${PR_RESET}$(git_prompt_info)$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}${PR_RESET}'
# Right prompt: vcs status + time
RPROMPT
=
"
\$
(git_prompt_info)
\$
(svn_prompt_info)
${
PR_YELLOW
}
%D{%R.%S %a %b %d %Y}
${
GREEN_END
}
"
# Matching continuation prompt
# Matching continuation prompt
PROMPT2
=
'${GREEN_BASE_START}${PR_RESET} %_ ${GREEN_BASE_START}${PR_RESET} '
PROMPT2
=
"
${
GREEN_START
}
%_
${
GREEN_START
}
"
# 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