themes/modern+: Adjust coding style

This commit is contained in:
Koichi Murase
2024-04-01 22:20:35 +09:00
parent 617381a165
commit a78672d792
6 changed files with 84 additions and 104 deletions
+20 -25
View File
@@ -56,24 +56,22 @@ esac
PS3=">> "
function __my_rvm_ruby_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "[$full]"
local gemset=$(awk -F'@' '{print $2}' <<< "$GEM_HOME")
[[ $gemset ]] && gemset=@$gemset
local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME")
local full=$version$gemset
[[ $full ]] && echo "[$full]"
}
function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ]
then
if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi
}
function modern_scm_prompt {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return
else
echo "[$(scm_char)][$GREEN$(scm_prompt_info)]"
@@ -82,38 +80,35 @@ function modern_scm_prompt {
# show chroot if exist
function chroot {
if [ -n "$debian_chroot" ]
then
my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}";
echo "($my_ps_chroot)";
if [[ $debian_chroot ]]; then
my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal
echo "($my_ps_chroot)"
fi
}
# show virtualenvwrapper
function my_ve {
if [ -n "$VIRTUAL_ENV" ]
then
my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}";
echo "($my_ps_ve)";
if [[ $VIRTUAL_ENV ]]; then
my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal
echo "($my_ps_ve)"
fi
echo "";
echo ""
}
function _omb_theme_PROMPT_COMMAND {
my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}";
my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}"
# yes, these are the the same for now ...
my_ps_host_root="$ORANGE\h${_omb_prompt_normal}";
my_ps_host_root="$ORANGE\h${_omb_prompt_normal}"
my_ps_user="$BOLD$GREEN\u${_omb_prompt_normal}"
my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}";
my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}"
if [ -n "$VIRTUAL_ENV" ]
then
ve=`basename "$VIRTUAL_ENV"`;
if [[ $VIRTUAL_ENV ]]; then
ve=$(basename "$VIRTUAL_ENV")
fi
# nice prompt
case "`id -u`" in
case $(id -u) in
0) PS1="\n${TITLEBAR}${BRACKET_COLOR}┌─${_omb_prompt_normal}$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${_omb_prompt_green}\w${_omb_prompt_normal}]$(is_vim_shell)${BRACKET_COLOR}
└─▪ ${prompt_symbol} ${_omb_prompt_normal}"
;;
+2 -4
View File
@@ -20,16 +20,14 @@ esac
PS3=">> "
function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ]
then
if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi
}
function modern_scm_prompt {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return
else
echo "[$(scm_char)][$(scm_prompt_info)]"
+3 -6
View File
@@ -20,16 +20,14 @@ esac
PS3=">> "
function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ]
then
if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi
}
function modern_scm_prompt {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return
else
echo "[$(scm_char)][$(scm_prompt_info)]"
@@ -37,8 +35,7 @@ function modern_scm_prompt {
}
function _omb_theme_PROMPT_COMMAND {
if [ $? -ne 0 ]
then
if (($? != 0)); then
# Yes, the indenting on these is weird, but it has to be like
# this otherwise it won't display properly.
+30 -32
View File
@@ -30,23 +30,22 @@ esac
function __my_rvm_ruby_version {
local gemset ; gemset=$(awk -F'@' '{print $2}' <<< "${GEM_HOME}")
local version ; version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}")
[ "${gemset}" != "" ] && gemset="@${gemset}"
local full="${version}${gemset}"
[ "${full}" != "" ] \
&& echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}"
local gemset=$(awk -F'@' '{print $2}' <<< "${GEM_HOME}")
local version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}")
[[ $gemset ]] && gemset=@$gemset
local full=$version$gemset
[[ $full ]] && echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}"
}
function is_vim_shell {
if [ -n "${VIMRUNTIME}" ] ; then
if [[ $VIMRUNTIME ]]; then
echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}"
fi
}
function is_integer { # helper function to make sure input is an integer
[ "$1" -eq "$1" ] > /dev/null 2>&1
return $?
[ "$1" -eq "$1" ] &> /dev/null
return "$?"
}
# XXX do we need/want to integrate with todo.sh? We don't provide it and I
@@ -55,7 +54,7 @@ function todo_txt_count {
if _omb_util_command_exists todo.sh; then # is todo.sh installed
local count=$(todo.sh ls \
| awk '/TODO: [0-9]+ of ([0-9]+) tasks shown/ { print $4 }')
if is_integer "${count}" ; then # did we get a sane answer back
if is_integer "${count}"; then # did we get a sane answer back
echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}T:$count${OMB_THEME_BRACKET_COLOR}]$_omb_prompt_normal"
fi
fi
@@ -63,38 +62,37 @@ function todo_txt_count {
function modern_scm_prompt {
local CHAR=$(scm_char)
if [ ! "${CHAR}" = "${SCM_NONE_CHAR}" ] ; then
printf "%s" \
"${OMB_THEME_BRACKET_COLOR}[${CHAR}${OMB_THEME_BRACKET_COLOR}]" \
"[${OMB_THEME_STRING_COLOR}$(scm_prompt_info)${OMB_THEME_BRACKET_COLOR}]$_omb_prompt_normal"
printf "\n"
if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then
local char=$OMB_THEME_BRACKET_COLOR[$CHAR$OMB_THEME_BRACKET_COLOR]
local info=[$OMB_THEME_STRING_COLOR$(scm_prompt_info)$OMB_THEME_BRACKET_COLOR]
printf '%s\n' "$char$info$_omb_prompt_normal"
fi
}
function _omb_theme_PROMPT_COMMAND {
local my_host="${OMB_THEME_STRING_COLOR}\h${_omb_prompt_normal}";
local my_user="${OMB_THEME_STRING_COLOR}\u${_omb_prompt_normal}";
local my_path="${OMB_THEME_STRING_COLOR}\w${_omb_prompt_normal}";
local bracket_c="${OMB_THEME_BRACKET_COLOR}"
local my_host=$OMB_THEME_STRING_COLOR'\h'$_omb_prompt_normal
local my_user=$OMB_THEME_STRING_COLOR'\u'$_omb_prompt_normal
local my_path=$OMB_THEME_STRING_COLOR'\w'$_omb_prompt_normal
local bracket_c=$OMB_THEME_BRACKET_COLOR
local line2 ; line2="${bracket_c}└─$(todo_txt_count)${PROMPT_CHAR}"
local line2=$bracket_c'└─'$(todo_txt_count)$PROMPT_CHAR
# nice prompt
case "$(id -u)" in
0)
my_user="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}";
line2="${bracket_c}└─${PROMPT_CHAR}"
case $(id -u) in
(0)
my_user=$_omb_prompt_bold_brown'\u'$_omb_prompt_normal
line2=$bracket_c'└─'$PROMPT_CHAR
;;
esac
PS1="${TITLEBAR}"
PS1="${PS1}${bracket_c}┌─[${my_user}${bracket_c}][$my_host${bracket_c}]"
PS1="${PS1}$(modern_scm_prompt)"
PS1="${PS1}$(__my_rvm_ruby_version)"
PS1="${PS1}${bracket_c}[${my_path}${bracket_c}]$(is_vim_shell)"
PS1="${PS1}\n${line2}"
PS1=$TITLEBAR
PS1=$PS1$bracket_c'┌─'[$my_user$bracket_c][$my_host$bracket_c]
PS1=$PS1$(modern_scm_prompt)
PS1=$PS1$(__my_rvm_ruby_version)
PS1=$PS1$bracket_c[$my_path$bracket_c]$(is_vim_shell)
PS1=$PS1'\n'$line2
}
PS2="└─${PROMPT_CHAR}"
PS3=">> "
PS2='└─'$PROMPT_CHAR
PS3='>> '
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
+9 -12
View File
@@ -23,31 +23,28 @@ esac
PS3=">> "
function __my_rvm_ruby_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "[$full]"
local gemset=$(awk -F'@' '{print $2}' <<< "$GEM_HOME")
[[ $gemset ]] && gemset=@$gemset
local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME")
local full=$version$gemset
[[ $full ]] && echo "[$full]"
}
function __my_venv_prompt {
if [ ! -z "$VIRTUAL_ENV" ]
then
if [[ $VIRTUAL_ENV ]]; then
echo "[${_omb_prompt_navy}@${_omb_prompt_normal}${VIRTUAL_ENV##*/}]"
fi
}
function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ]
then
if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi
}
function modern_scm_prompt {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return
else
echo "[$(scm_char)][$(scm_prompt_info)]"
@@ -69,7 +66,7 @@ function _omb_theme_PROMPT_COMMAND {
my_ps_path="\[\033[01;36m\]\w\[\033[00m\]";
# nice prompt
case "`id -u`" in
case $(id -u) in
0) PS1="${TITLEBAR}[$my_ps_root][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${_omb_prompt_teal}\w${_omb_prompt_normal}]$(is_vim_shell)
$ "
;;
+20 -25
View File
@@ -23,24 +23,22 @@ esac
PS3=">> "
function __my_rvm_ruby_version {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "[$full]"
local gemset=$(awk -F'@' '{print $2}' <<< "$GEM_HOME")
[[ $gemset ]] && gemset=@$gemset
local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME")
local full=$version$gemset
[[ $full ]] && echo "[$full]"
}
function is_vim_shell {
if [ ! -z "$VIMRUNTIME" ]
then
if [[ $VIMRUNTIME ]]; then
echo "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]"
fi
}
function modern_scm_prompt {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then
return
else
echo "[$(scm_char)][$(scm_prompt_info)]"
@@ -49,38 +47,35 @@ function modern_scm_prompt {
# show chroot if exist
function chroot {
if [ -n "$debian_chroot" ]
then
my_ps_chroot="${_omb_prompt_bold_teal}$debian_chroot${_omb_prompt_normal}";
echo "($my_ps_chroot)";
if [[ $debian_chroot ]]; then
my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal
echo "($my_ps_chroot)"
fi
}
# show virtualenvwrapper
function my_ve {
if [ -n "$VIRTUAL_ENV" ]
then
my_ps_ve="${_omb_prompt_bold_purple}$ve${_omb_prompt_normal}";
echo "($my_ps_ve)";
if [[ $VIRTUAL_ENV ]]; then
my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal
echo "($my_ps_ve)"
fi
echo "";
echo ""
}
function _omb_theme_PROMPT_COMMAND {
my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}";
my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"
# yes, these are the the same for now ...
my_ps_host_root="${_omb_prompt_green}\h${_omb_prompt_normal}";
my_ps_host_root="${_omb_prompt_green}\h${_omb_prompt_normal}"
my_ps_user="${_omb_prompt_bold_green}\u${_omb_prompt_normal}"
my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}";
my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}"
if [ -n "$VIRTUAL_ENV" ]
then
ve=`basename "$VIRTUAL_ENV"`;
if [[ $VIRTUAL_ENV ]]; then
ve=$(basename "$VIRTUAL_ENV")
fi
# nice prompt
case "`id -u`" in
case $(id -u) in
0) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${_omb_prompt_teal}\w${_omb_prompt_normal}]$(is_vim_shell)
└─▪ "
;;