Compare commits

..

10 Commits

Author SHA1 Message Date
a4aad67bd3 removed cost function 2024-11-25 20:39:47 -08:00
ChesterYue
7f06398c0a [F] format - space 2024-04-23 21:08:12 +08:00
ChesterYue
4c1ba4a4e1 [F] [close #24] git - status disappear 2024-04-23 21:05:50 +08:00
ChesterYue
1d96f9984d [F] [#23] README - typo of ~/.zshrc 2023-05-19 16:47:42 +08:00
ChesterYue
abcf3f381b [U] color 2023-03-27 00:15:06 +08:00
ChesterYue
d1a5810276 [U] demo - image 2023-03-27 00:14:05 +08:00
ChesterYue
65dbfbd56c [U] demo - image 2023-03-27 00:03:19 +08:00
ChesterYue
387e079958 [U] color 2023-03-26 04:13:23 +08:00
ChesterYue
2a9e6c86b3 [U] color 2023-03-26 03:58:12 +08:00
ChesterYue
5bb42bd6c6 [U] git - prompt 2023-03-25 15:55:20 +08:00
5 changed files with 58 additions and 55 deletions

View File

@@ -21,7 +21,7 @@ An oh-my-zsh theme;
1. clone repo: ```git clone https://github.com/ChesterYue/ohmyzsh-theme-passion```;
2. copy theme: ```cp ./ohmyzsh-theme-passion/passion.zsh-theme ~/.oh-my-zsh/themes/passion.zsh-theme```;
3. modify rc: open ```~/.zshrc``` find ```ZSH_THEME``` edit to ```ZSH_THEME="passion"```;
4. execute rc: ```source ~./zshrc```;
4. execute rc: ```source ~/.zshrc```;
* see also: [Overriding and adding themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes);
@@ -29,12 +29,12 @@ An oh-my-zsh theme;
##### macOS, command not found: gdate
* passion.zsh-theme depends on cmd ```gdate``` to get current time in milliseconds. get ```gdate``` on macOS by running ```brew install coreutils``` then ```source ~./zshrc```;
* passion.zsh-theme depends on cmd ```gdate``` to get current time in milliseconds. get ```gdate``` on macOS by running ```brew install coreutils``` then ```source ~/.zshrc```;
* see also: [#12](https://github.com/ChesterYue/ohmyzsh-theme-passion/issues/12);
##### Linux, command not found: bc
* passion.zsh-theme depends on cmd ```bc``` to calculate the command running time cost. [get bc on Linux](https://www.tecmint.com/bc-command-examples/#:~:text=If%20you%20don%E2%80%99t%20have%20bc%20on%20your%20system%2C,command%20prompt%20and%20simply%20start%20calculating%20your%20expressions.) then ```source ~./zshrc```;
* passion.zsh-theme depends on cmd ```bc``` to calculate the command running time cost. [get bc on Linux](https://www.tecmint.com/bc-command-examples/#:~:text=If%20you%20don%E2%80%99t%20have%20bc%20on%20your%20system%2C,command%20prompt%20and%20simply%20start%20calculating%20your%20expressions.) then ```source ~/.zshrc```;
* see also: [#13](https://github.com/ChesterYue/ohmyzsh-theme-passion/issues/13);
##### Centos 7, shell exit

View File

@@ -4,14 +4,14 @@
make sure image refed by [External-themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) exist;
## iTerm title
Settings - Profiles - Window - Custom tab title - ohmyzsh-theme-passion
## cmd
``` shell
# mkdir demo
# cd demo
# mkdir demo-git
# cd demo-git
# git init
# mkdir demo; cd demo; mkdir demo-git; cd demo-git; git init;
# git config --local user.name / user.email ...
# cd ..
@@ -25,4 +25,6 @@ touch test.txt
git st
git add -A
git ci -m "test"
# enter twice
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1023 KiB

After

Width:  |  Height:  |  Size: 975 KiB

View File

@@ -22,6 +22,7 @@ function real_time() {
echo "${color}${time}${color_reset}";
}
# login_info
function login_info() {
local color="%{$fg_no_bold[cyan]%}"; # color in PROMPT need format in %{XXX%} which is not same with echo
@@ -59,13 +60,13 @@ function directory() {
# git
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_no_bold[cyan]%}[git %{$fg_no_bold[red]%}";
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_no_bold[cyan]%}[";
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} ";
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_no_bold[cyan]%}] 🔥";
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_no_bold[red]%}✖%{$fg_no_bold[cyan]%}]";
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_no_bold[cyan]%}]";
function update_git_status() {
GIT_STATUS=$(git_prompt_info);
GIT_STATUS=$(_omz_git_prompt_info);
}
function git_status() {
@@ -119,51 +120,51 @@ output_command_execute_after() {
local color_time="$fg_no_bold[cyan]";
time="${color_time}${time}${color_reset}";
# cost
local time_end="$(current_time_millis)";
local cost=$(bc -l <<<"${time_end}-${COMMAND_TIME_BEGIN}");
COMMAND_TIME_BEGIN="-20200325"
local length_cost=${#cost};
if [ "$length_cost" = "4" ];
then
cost="0${cost}"
fi
cost="[cost ${cost}s]"
local color_cost="$fg_no_bold[cyan]";
cost="${color_cost}${cost}${color_reset}";
# # cost
# local time_end="$(current_time_millis)";
# local cost=$(bc -l <<<"${time_end}-${COMMAND_TIME_BEGIN}");
# COMMAND_TIME_BEGIN="-20200325"
# local length_cost=${#cost};
# if [ "$length_cost" = "4" ];
# then
# cost="0${cost}"
# fi
# cost="[cost ${cost}s]"
# local color_cost="$fg_no_bold[cyan]";
# cost="${color_cost}${cost}${color_reset}";
echo -e "${time} ${cost} ${cmd}";
echo -e "";
# echo -e "${time} ${cost} ${cmd}";
# echo -e "";
}
# command execute before
# REF: http://zsh.sourceforge.net/Doc/Release/Functions.html
preexec() { # cspell:disable-line
COMMAND_TIME_BEGIN="$(current_time_millis)";
}
# preexec() { # cspell:disable-line
# COMMAND_TIME_BEGIN="$(current_time_millis)";
# }
current_time_millis() {
local time_millis;
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
time_millis="$(date +%s.%3N)";
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
time_millis="$(gdate +%s.%3N)";
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
elif [[ "$OSTYPE" == "win32" ]]; then
# I'm not sure this can happen.
elif [[ "$OSTYPE" == "freebsd"* ]]; then
# ...
else
# Unknown.
fi
echo $time_millis;
}
# current_time_millis() {
# local time_millis;
# if [[ "$OSTYPE" == "linux-gnu" ]]; then
# # Linux
# time_millis="$(date +%s.%3N)";
# elif [[ "$OSTYPE" == "darwin"* ]]; then
# # macOS
# time_millis="$(gdate +%s.%3N)";
# elif [[ "$OSTYPE" == "cygwin" ]]; then
# # POSIX compatibility layer and Linux environment emulation for Windows
# elif [[ "$OSTYPE" == "msys" ]]; then
# # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
# elif [[ "$OSTYPE" == "win32" ]]; then
# # I'm not sure this can happen.
# elif [[ "$OSTYPE" == "freebsd"* ]]; then
# # ...
# else
# # Unknown.
# fi
# echo $time_millis;
# }
# command execute after

View File

@@ -163,13 +163,13 @@
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.92548316717147827</real>
<real>0.90196079015731812</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.68626224994659424</real>
<real>0.67843139171600342</real>
<key>Red Component</key>
<real>0.11377838999032974</real>
<real>0.19607843458652496</real>
</dict>
<key>Ansi 7 Color</key>
<dict>
@@ -215,13 +215,13 @@
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.20000000298023224</real>
<real>0.12156862765550613</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.16078431904315948</real>
<real>0.11764705926179886</real>
<key>Red Component</key>
<real>0.14901961386203766</real>
<real>0.11372549086809158</real>
</dict>
<key>Badge Color</key>
<dict>