mirror of
https://github.com/starship/starship
synced 2024-11-02 12:57:23 +00:00
style(init): tidy-up init scripts (#1269)
* style: fix indent & spacing * chore: use consistent function definition style * chore: remove extra semicolon * chore: flip comparison expression
This commit is contained in:
parent
a3470bf9fb
commit
cf87ce5f50
2 changed files with 13 additions and 14 deletions
|
@ -43,7 +43,7 @@ starship_precmd() {
|
|||
else
|
||||
PS1="$(::STARSHIP:: prompt --status=$STATUS --jobs="$(jobs -p | wc -l)")"
|
||||
fi
|
||||
PREEXEC_READY=true; # Signal that we can safely restart the timer
|
||||
PREEXEC_READY=true # Signal that we can safely restart the timer
|
||||
}
|
||||
|
||||
# If the user appears to be using https://github.com/rcaloras/bash-preexec,
|
||||
|
@ -52,14 +52,14 @@ if [[ $preexec_functions ]]; then
|
|||
preexec_functions+=('starship_preexec "$_"')
|
||||
precmd_functions+=(starship_precmd)
|
||||
else
|
||||
# We want to avoid destroying an existing DEBUG hook. If we detect one, create
|
||||
# a new function that runs both the existing function AND our function, then
|
||||
# re-trap DEBUG to use this new function. This prevents a trap clobber.
|
||||
# We want to avoid destroying an existing DEBUG hook. If we detect one, create
|
||||
# a new function that runs both the existing function AND our function, then
|
||||
# re-trap DEBUG to use this new function. This prevents a trap clobber.
|
||||
dbg_trap="$(trap -p DEBUG | cut -d' ' -f3 | tr -d \')"
|
||||
if [[ -z "$dbg_trap" ]]; then
|
||||
trap 'starship_preexec "$_"' DEBUG
|
||||
elif [[ "$dbg_trap" != 'starship_preexec "$_"' && "$dbg_trap" != 'starship_preexec_all "$_"' ]]; then
|
||||
function starship_preexec_all(){
|
||||
starship_preexec_all() {
|
||||
local PREV_LAST_ARG=$1 ; $dbg_trap; starship_preexec; : "$PREV_LAST_ARG";
|
||||
}
|
||||
trap 'starship_preexec_all "$_"' DEBUG
|
||||
|
|
|
@ -18,7 +18,7 @@ starship_precmd() {
|
|||
# quotes so we set it here and then use the value later on.
|
||||
NUM_JOBS=$#jobstates
|
||||
# Compute cmd_duration, if we have a time to consume
|
||||
if [[ ! -z "${STARSHIP_START_TIME+1}" ]]; then
|
||||
if [[ -n "${STARSHIP_START_TIME+1}" ]]; then
|
||||
STARSHIP_END_TIME=$(::STARSHIP:: time)
|
||||
STARSHIP_DURATION=$((STARSHIP_END_TIME - STARSHIP_START_TIME))
|
||||
PROMPT="$(::STARSHIP:: prompt --status=$STATUS --cmd-duration=$STARSHIP_DURATION --jobs="$NUM_JOBS")"
|
||||
|
@ -27,7 +27,7 @@ starship_precmd() {
|
|||
PROMPT="$(::STARSHIP:: prompt --status=$STATUS --jobs="$NUM_JOBS")"
|
||||
fi
|
||||
}
|
||||
starship_preexec(){
|
||||
starship_preexec() {
|
||||
STARSHIP_START_TIME=$(::STARSHIP:: time)
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,8 @@ if [[ ${preexec_functions[(ie)starship_preexec]} -gt ${#preexec_functions} ]]; t
|
|||
fi
|
||||
|
||||
# Set up a function to redraw the prompt if the user switches vi modes
|
||||
function zle-keymap-select
|
||||
{
|
||||
PROMPT=$(::STARSHIP:: prompt --keymap=$KEYMAP --jobs="$(jobs | wc -l)")
|
||||
zle-keymap-select() {
|
||||
PROMPT=$(::STARSHIP:: prompt --keymap="$KEYMAP" --jobs="$(jobs | wc -l)")
|
||||
zle reset-prompt
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue