├── demo.gif ├── Zhiyin.otf ├── niganma.mp3 ├── README.md ├── LICENSE └── zhiyin.zsh-theme /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmyangXYZ/zhiyin-zsh-theme/HEAD/demo.gif -------------------------------------------------------------------------------- /Zhiyin.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmyangXYZ/zhiyin-zsh-theme/HEAD/Zhiyin.otf -------------------------------------------------------------------------------- /niganma.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmyangXYZ/zhiyin-zsh-theme/HEAD/niganma.mp3 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zhiyin-zsh-theme 2 | 3 | Inspired by [Zhiyin](https://github.com/W-Mai/BuZhiYin), [emoji-ps1](https://github.com/bigomega/emoji-ps1) and built on [ys-zsh-theme](https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/ys.zsh-theme) 4 | 5 | ![](./demo.gif) 6 | 7 | ## Installation 8 | 9 | 1. Install `Zhiyin.otf` font, select it in your iTerm2 (under Non-ASCII font) and add it to your VS Code's font family. 10 | 2. `cp zhiyin.zsh-theme ~/.oh-my-zsh/themes/`, or just add this [code snippet](https://github.com/AmyangXYZ/zhiyin-zsh-theme/blob/b2bf2ac7b4b7dbd68455863a31c632dc79558ef3/zhiyin.zsh-theme#L63-L150) to your favourite zsh theme. 11 | 12 | For Windows WSL users, install Zhiyin.otf and configure your VSCode by adding this to the settings.json `"terminal.integrated.fontFamily": " 'Cascadia Mono',Menlo, Monaco, 'Courier New', monospace, Zhiyin"`. 13 | 14 | ## Zhiyin Sing 15 | 16 | Sing upon ERR signal. Enable by adding below to `zhiyin.zsh-theme`, and copy `niganma.mp3` somewhere you like. 17 | 18 | ```shell 19 | function zhiyin_sing { 20 | afplay ~/Downloads/niganma.mp3 21 | } 22 | 23 | trap zhiyin_sing ERR 24 | ``` 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Amyang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /zhiyin.zsh-theme: -------------------------------------------------------------------------------- 1 | # Clean, simple, compatible and meaningful. 2 | # Tested on Linux, Unix and Windows under ANSI colors. 3 | # It is recommended to use with a dark background. 4 | # Colors: black, red, green, yellow, *blue, magenta, cyan, and white. 5 | # 6 | # Mar 2013 Yad Smood 7 | 8 | # VCS 9 | YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} " 10 | YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}" 11 | YS_VCS_PROMPT_SUFFIX="%{$reset_color%}" 12 | YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x" 13 | YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o" 14 | 15 | # Git info 16 | local git_info='$(git_prompt_info)' 17 | ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}" 18 | ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX" 19 | ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY" 20 | ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN" 21 | 22 | # HG info 23 | local hg_info='$(ys_hg_prompt_info)' 24 | ys_hg_prompt_info() { 25 | # make sure this is a hg dir 26 | if [ -d '.hg' ]; then 27 | echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}" 28 | echo -n $(hg branch 2>/dev/null) 29 | if [ -n "$(hg status 2>/dev/null)" ]; then 30 | echo -n "$YS_VCS_PROMPT_DIRTY" 31 | else 32 | echo -n "$YS_VCS_PROMPT_CLEAN" 33 | fi 34 | echo -n "$YS_VCS_PROMPT_SUFFIX" 35 | fi 36 | } 37 | 38 | local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})" 39 | 40 | # Prompt format: 41 | # 42 | # PRIVILEGES USER @ MACHINE in DIRECTORY on git:BRANCH STATE [TIME] C:LAST_EXIT_CODE 43 | # $ COMMAND 44 | # 45 | # For example: 46 | # 47 | # % ys @ ys-mbp in ~/.oh-my-zsh on git:master x [21:47:42] C:0 48 | # $ 49 | PROMPT=" 50 | %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \ 51 | %(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \ 52 | %{$fg[white]%}@ \ 53 | %{$fg[green]%}%m \ 54 | %{$fg[white]%}in \ 55 | %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\ 56 | ${hg_info}\ 57 | ${git_info}\ 58 | \ 59 | %{$fg[white]%}[%*] $exit_code 60 | %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" 61 | 62 | 63 | psanimate_stop() { 64 | touch /tmp/psanimatepid-$$ 65 | PID=`cat /tmp/psanimatepid-$$` 66 | if [[ ! -z "$PID" ]] 67 | then 68 | (kill $PID > /dev/null 2>&1) 69 | fi 70 | rm /tmp/psanimatepid-$$ 71 | return 0 72 | } 73 | 74 | psanimate() { 75 | SLEEP_TIMER=${1:-'1'} 76 | psanimate_stop 77 | _ps_emoji_animation() { 78 | counter=0 79 | increment=true 80 | S="\033[s" 81 | U="\033[u" 82 | while [ : ] 83 | do 84 | hex=$(printf "%02X" $counter) 85 | Zhiyin="\uE9${hex}" 86 | POS="\033[1000D" 87 | eval echo -ne '$S$POS$Zhiyin $U' 88 | 89 | # Update the counter and check the bounds 90 | if $increment; then 91 | ((counter++)) 92 | if [ $counter -eq 17 ]; then 93 | increment=false 94 | ((counter--)) 95 | fi 96 | else 97 | ((counter--)) 98 | if [ $counter -eq -1 ]; then 99 | increment=true 100 | ((counter++)) 101 | fi 102 | fi 103 | 104 | sleep $SLEEP_TIMER 105 | done 106 | } 107 | (_ps_emoji_animation & ; echo "$!" > /tmp/psanimatepid-$$) 108 | return 0 109 | } 110 | 111 | function pscleanup { 112 | echo "Cleaning the animation stuff" 113 | psanimate_stop 114 | unset PS_TASK_OVER 115 | } 116 | 117 | trap pscleanup EXIT 118 | 119 | # 切换动画状态 120 | function toggle_psanimate_state() { 121 | if [[ $PS_ANIMATION_ENABLED == "true" ]]; then 122 | psanimate_stop 123 | export PS_ANIMATION_ENABLED="false" 124 | else 125 | psanimate 0.08 126 | export PS_ANIMATION_ENABLED="true" 127 | fi 128 | } 129 | 130 | # 设置 zsh 的 preexec 和 precmd 钩子 131 | autoload -Uz add-zsh-hook 132 | 133 | # 在执行命令之前停止动画 134 | preexec() { 135 | if [[ $PS_ANIMATION_ENABLED == "true" ]]; then 136 | psanimate_stop 137 | fi 138 | } 139 | 140 | # 在命令完成后重新启动动画 141 | precmd() { 142 | if [[ $PS_ANIMATION_ENABLED == "true" ]]; then 143 | psanimate 0.08 144 | fi 145 | } 146 | 147 | add-zsh-hook -Uz preexec preexec 148 | add-zsh-hook -Uz precmd precmd 149 | 150 | export PS_ANIMATION_ENABLED="true" 151 | --------------------------------------------------------------------------------