Coding style adjustments
This commit is contained in:
parent
feb3e4d3d9
commit
350f350e34
|
@ -35,24 +35,24 @@ function prompt_minimal2_vcs {
|
|||
|
||||
function prompt_minimal2_env {
|
||||
# python virtual env
|
||||
if [ -n "$VIRTUAL_ENV" ]; then
|
||||
_venv="$(basename $VIRTUAL_ENV)"
|
||||
if [ -n "${VIRTUAL_ENV}" ]; then
|
||||
_venv="$(basename ${VIRTUAL_ENV})"
|
||||
echo -n "${_venv%%.*} "
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_minimal2_ssh_hostname {
|
||||
if [[ "${MINIMAL_SSH_HOSTNAME}" == "yes" ]] && ([[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]); then
|
||||
if [[ "${MINIMAL_SSH_HOSTNAME}" == "yes" ]] && ([[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_TTY}" ]]); then
|
||||
echo -n "$(hostname -s) "
|
||||
fi
|
||||
}
|
||||
|
||||
# Left Prompt
|
||||
function prompt_minimal2_lprompt {
|
||||
local user_status="%{\e[%(1j.4.0);3%(0?.$MINIMAL_OK_COLOR.1)m%}\
|
||||
%(!.#.$MINIMAL_USER_CHAR)"
|
||||
local kmstatus="$MINIMAL_INSERT_CHAR"
|
||||
[ "$KEYMAP" = 'vicmd' ] && kmstatus="$MINIMAL_NORMAL_CHAR"
|
||||
local user_status="%{\e[%(1j.4.0);3%(0?.${MINIMAL_OK_COLOR}.1)m%}\
|
||||
%(!.#.${MINIMAL_USER_CHAR})"
|
||||
local kmstatus="${MINIMAL_INSERT_CHAR}"
|
||||
[ "$KEYMAP" = 'vicmd' ] && kmstatus="${MINIMAL_NORMAL_CHAR}"
|
||||
|
||||
echo -n "$user_status%{\e[0m%} $kmstatus"
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ function prompt_minimal2_lprompt {
|
|||
function prompt_minimal2_ps2 {
|
||||
local kmstatus="$MINIMAL_INSERT_CHAR"
|
||||
local offset="$((${#_venv} + 2))"
|
||||
[ "$KEYMAP" = 'vicmd' ] && kmstatus="$MINIMAL_NORMAL_CHAR"
|
||||
[ "$KEYMAP" = 'vicmd' ] && kmstatus="${MINIMAL_NORMAL_CHAR}"
|
||||
|
||||
printf " %.0s" {1..$offset}
|
||||
echo -n "$kmstatus"
|
||||
printf " %.0s" {1..${offset}}
|
||||
echo -n "${kmstatus}"
|
||||
}
|
||||
|
||||
# Right Prompt
|
||||
|
@ -71,7 +71,7 @@ function prompt_minimal2_path {
|
|||
local w="%{\e[0m%}"
|
||||
local cwd="%${MINIMAL_PWD_LEN}~"
|
||||
local pi=""
|
||||
local len="$MINIMAL_PWD_CHAR_LEN"
|
||||
local len="${MINIMAL_PWD_CHAR_LEN}"
|
||||
[ "$len" -lt 4 ] && len=4
|
||||
local hlen=$((len / 2 - 1))
|
||||
cwd="${(%)cwd}"
|
||||
|
@ -92,22 +92,22 @@ function prompt_minimal2_infoline {
|
|||
local rn="\e[0;31m"
|
||||
local rb="\e[1;31m"
|
||||
|
||||
local user_host_pwd="$_grey%n$w@$_grey%m$w:$_grey%~$w"
|
||||
user_host_pwd="${${(%)user_host_pwd}//\//$w/$_grey}"
|
||||
local user_host_pwd="${_grey}%n$w@${_grey}%m$w:${_grey}%~$w"
|
||||
user_host_pwd="${${(%)user_host_pwd}//\//$w/${_grey}}"
|
||||
|
||||
local v_files="$(ls -1 | sed -n '$=')"
|
||||
local h_files="$(ls -1A | sed -n '$=')"
|
||||
|
||||
local job_n="$(jobs | sed -n '$=')"
|
||||
|
||||
local iline="[$user_host_pwd] [$_grey${v_files:-0}$w ($_grey${h_files:-0}$w)]"
|
||||
[ "$job_n" -gt 0 ] && iline="$iline [$_grey$job_n$w&]"
|
||||
local iline="[$user_host_pwd] [${_grey}${v_files:-0}$w (${_grey}${h_files:-0}$w)]"
|
||||
[ "${job_n}" -gt 0 ] && iline="${iline} [${_grey}${job_n}$w&]"
|
||||
|
||||
if [ "$last_err" != "0" ]; then
|
||||
iline="$iline \e[1;31m[\e[0;31m$last_err\e[1;31m]$w"
|
||||
iline="${iline} \e[1;31m[\e[0;31m$last_err\e[1;31m]$w"
|
||||
fi
|
||||
|
||||
echo "$iline"
|
||||
echo "${iline}"
|
||||
}
|
||||
|
||||
function prompt_minimal2_magic_output_base {
|
||||
|
@ -131,10 +131,10 @@ function prompt_minimal2_wrap_output {
|
|||
local output="$1"
|
||||
local output_len="$(echo "$output" | sed -n '$=')"
|
||||
if [ -n "$output" ]; then
|
||||
if [ "$output_len" -gt "$((LINES - 2))" -a -n "$PAGER" ]; then
|
||||
printf "$output\n" | "$PAGER" -R
|
||||
if [ "$output_len" -gt "$((LINES - 2))" -a -n "${PAGER}" ]; then
|
||||
printf "$output\n" | "${PAGER}" -R
|
||||
else
|
||||
printf "$output\n" | sed "s/^/$MINIMAL_MAGIC_ENTER_MARGIN/"
|
||||
printf "$output\n" | sed "s/^/${MINIMAL_MAGIC_ENTER_MARGIN}/"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue