Merge pull request #250 from ZQPei/master

themes/pzq: Add pzq themes inspired by ys-theme from oh-my-zsh and rana
This commit is contained in:
Koichi Murase
2022-09-08 06:17:04 +09:00
committed by GitHub
4 changed files with 156 additions and 8 deletions

View File

@@ -188,6 +188,10 @@
[![](purity/purity-dark.png)](purity/purity-dark.png)
## `pzq`
[![](pzq/pzq-dark.png)](pzq/pzq-dark.png)
## `rainbowbrite`
[![](rainbowbrite/rainbowbrite-dark.png)](rainbowbrite/rainbowbrite-dark.png)

BIN
themes/pzq/pzq-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

144
themes/pzq/pzq.theme.sh Normal file
View File

@@ -0,0 +1,144 @@
#!/usr/bin/env bash
# Theme inspired by:
# - ys theme - https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/ys.zsh-theme
# - rana theme - https://github.com/ohmybash/oh-my-bash/blob/master/themes/rana/rana.theme.sh
#
# by Ziqiang Pei<ziqiangpei@foxmail.com>
OMB_PROMPT_CONDAENV_FORMAT='(%s)'
OMB_PROMPT_VIRTUALENV_FORMAT='(%s)'
# ----------------------------------------------------------------- COLOR CONF
D_DEFAULT_COLOR="$_omb_prompt_white"
D_INTERMEDIATE_COLOR="$_omb_prompt_bold_white"
D_NUMBER_COLOR="$_omb_prompt_bold_navy"
D_USER_COLOR="$_omb_prompt_teal"
D_SUPERUSER_COLOR="$_omb_prompt_brown"
D_MACHINE_COLOR="$_omb_prompt_green"
D_DIR_COLOR="$_omb_prompt_bold_olive"
D_GIT_DEFAULT_COLOR="$_omb_prompt_white"
D_GIT_BRANCH_COLOR="$_omb_prompt_teal"
D_GIT_PROMPT_COLOR="$_omb_prompt_brown"
D_SCM_COLOR="$_omb_prompt_bold_olive"
D_BRANCH_COLOR="$_omb_prompt_teal"
D_CHANGES_COLOR="$_omb_prompt_white"
D_TIME_COLOR="$_omb_prompt_white"
D_DOLLOR_COLOR="$_omb_prompt_bold_brown"
D_CMDFAIL_COLOR="$_omb_prompt_brown"
D_VIMSHELL_COLOR="$_omb_prompt_teal"
# ------------------------------------------------------------------ FUNCTIONS
case $TERM in
xterm*)
TITLEBAR='\[\e]0;\w\e\\\]'
;;
*)
TITLEBAR=""
;;
esac
is_vim_shell() {
if [[ ${VIMRUNTIME-} ]]; then
echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} "
fi
}
mitsuhikos_lastcommandfailed() {
local status=$?
if ((status != 0)); then
echo " ${D_DEFAULT_COLOR}C:${D_CMDFAIL_COLOR}$code ${D_DEFAULT_COLOR}"
fi
}
# vcprompt for scm instead of oh-my-bash default
demula_vcprompt() {
if [[ ${VCPROMPT_EXECUTABLE-} ]]; then
local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
$VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT"
fi
}
# checks if the plugin is installed before calling battery_charge
safe_battery_charge() {
if _omb_util_function_exists battery_charge; then
battery_charge
fi
}
prompt_git() {
local branchName=''
# Check if the current directory is in a Git repository.
if git rev-parse --is-inside-work-tree &>/dev/null; then
# Get the short symbolic ref.
# If HEAD isnt a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up.
branchName=$(
git symbolic-ref --quiet --short HEAD 2> /dev/null ||
git rev-parse --short HEAD 2> /dev/null ||
echo '(unknown)');
echo "${D_GIT_DEFAULT_COLOR}on ${D_GIT_BRANCH_COLOR}${branchName} "
else
return
fi
}
limited_pwd() {
# Max length of PWD to display
local MAX_PWD_LENGTH=20
# Replace $HOME with ~ if possible
local RELATIVE_PWD=${PWD/#$HOME/\~}
local offset=$((${#RELATIVE_PWD}-MAX_PWD_LENGTH))
if ((offset > 0)); then
local truncated_symbol='...'
local TRUNCATED_PWD=${RELATIVE_PWD:offset:MAX_PWD_LENGTH}
echo -n "${truncated_symbol}/${TRUNCATED_PWD#*/}"
else
echo -n "${RELATIVE_PWD}"
fi
}
# -------------------------------------------------------------- PROMPT OUTPUT
_omb_theme_PROMPT_COMMAND() {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
local SAVE_CURSOR='\[\e7'
local RESTORE_CURSOR='\e8\]'
local MOVE_CURSOR_RIGHTMOST='\e['${COLUMNS:-9999}'C'
local MOVE_CURSOR_5_LEFT='\e[5D'
local THEME_CLOCK_FORMAT="%H:%M:%S %y-%m-%d"
# Replace $HOME with ~ if possible
local RELATIVE_PWD=${PWD/#$HOME/\~}
local python_venv
_omb_prompt_get_python_venv
PS1=${TITLEBAR}$python_venv$'\n'
if [[ $OSTYPE == linux-gnu ]]; then
PS1+="${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}"
PS1+="$(safe_battery_charge)${RESTORE_CURSOR}"
PS1+="${D_NUMBER_COLOR}# ${D_USER_COLOR}\u ${D_DEFAULT_COLOR}"
else
PS1+="${D_NUMBER_COLOR}# ${D_USER_COLOR}\u ${D_DEFAULT_COLOR}"
fi
PS1+="@ ${D_MACHINE_COLOR}\h ${D_DEFAULT_COLOR}"
PS1+="in ${D_DIR_COLOR}${RELATIVE_PWD} ${D_INTERMEDIATE_COLOR}"
PS1+=$(prompt_git)
PS1+=${D_TIME_COLOR}[$(clock_prompt)]
PS1+=${LAST_COMMAND_FAILED}
PS1+=$(demula_vcprompt)
PS1+=$(is_vim_shell)
if [[ $OSTYPE != linux-gnu ]]; then
PS1+=$(safe_battery_charge)
fi
PS1+=$'\n'"${D_DOLLOR_COLOR}$ ${D_DEFAULT_COLOR}"
PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
}
# Runs prompt (this bypasses oh-my-bash $PROMPT setting)
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND

View File

@@ -76,11 +76,11 @@ D_VIMSHELL_COLOR="$_omb_prompt_teal"
# ------------------------------------------------------------------ FUNCTIONS
case $TERM in
xterm*)
TITLEBAR="\033]0;\w\007"
;;
TITLEBAR='\[\e]0;\w\e\\\]'
;;
*)
TITLEBAR=""
;;
TITLEBAR=""
;;
esac
is_vim_shell() {
@@ -165,10 +165,10 @@ prompt_git() {
# -------------------------------------------------------------- PROMPT OUTPUT
_omb_theme_PROMPT_COMMAND() {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
local SAVE_CURSOR='\033[s'
local RESTORE_CURSOR='\033[u'
local MOVE_CURSOR_RIGHTMOST='\033[500C'
local MOVE_CURSOR_5_LEFT='\033[5D'
local SAVE_CURSOR='\[\e7'
local RESTORE_CURSOR='\e8\]'
local MOVE_CURSOR_RIGHTMOST='\e['${COLUMNS:-9999}'C'
local MOVE_CURSOR_5_LEFT='\e[5D'
PS1=${TITLEBAR}$'\n'
if [[ $OSTYPE == linux* ]]; then