Spaceship-prompt: Custom section not loading with NPM install

Created on 26 Jul 2018  路  5Comments  路  Source: denysdovhan/spaceship-prompt

Hi,

I have a custom section I would like to register. I installed Spaceship via npm. Looking my .zshrc looks like this:


SPACESHIP_WIP_SHOW="${SPACESHIP_WIP_SHOW=true}"
SPACESHIP_WIP_PREFIX="${SPACESHIP_WIP_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_WIP_SUFFIX="${SPACESHIP_WIP_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_WIP_SYMBOL="${SPACESHIP_WIP_SYMBOL="馃毀 "}"
SPACESHIP_WIP_COLOR="${SPACESHIP_WIP_COLOR="red"}"

spaceship_wip() {
  # If SPACESHIP_WIP_SHOW is false, don't show WIP section
  # [[ $SPACESHIP_WIP_SHOW == false ]] && return

  # spaceship::is_git || return
  # spaceship::exists work_in_progress || return

  # if [[ $(work_in_progress) == "WIP!!" ]]; then
    # Display WIP section
    spaceship::section \
      "$SPACESHIP_WIP_COLOR" \
      "$SPACESHIP_WIP_PREFIX" \
      "$SPACESHIP_WIP_SYMBOL" \
      "$SPACESHIP_WIP_SUFFIX"
  # fi
}

# Set Spaceship ZSH as a prompt
autoload -U promptinit; promptinit
prompt spaceship

Note I have a bunch of checks commented out as I just want to see the section working.

What am I missing?

Thanks!

question

All 5 comments

You've to add it to to SPACESHIP_PROMPT_ORDER along with other required sections on you configuration.

SPACESHIP_WIP_SHOW="${SPACESHIP_WIP_SHOW=true}"
SPACESHIP_WIP_PREFIX="${SPACESHIP_WIP_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_WIP_SUFFIX="${SPACESHIP_WIP_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_WIP_SYMBOL="${SPACESHIP_WIP_SYMBOL="馃毀 "}"
SPACESHIP_WIP_COLOR="${SPACESHIP_WIP_COLOR="red"}"

spaceship_wip() {
  # If SPACESHIP_WIP_SHOW is false, don't show WIP section
  # [[ $SPACESHIP_WIP_SHOW == false ]] && return

  # spaceship::is_git || return
  # spaceship::exists work_in_progress || return

  # if [[ $(work_in_progress) == "WIP!!" ]]; then
    # Display WIP section
    spaceship::section \
      "$SPACESHIP_WIP_COLOR" \
      "$SPACESHIP_WIP_PREFIX" \
      "$SPACESHIP_WIP_SYMBOL" \
      "$SPACESHIP_WIP_SUFFIX"
  # fi
}

SPACESHIP_PROMPT_ORDER=(user host dir git wip node line_sep char)

# Set Spaceship ZSH as a prompt
autoload -U promptinit; promptinit
prompt spaceship

Mind sharing your section on our wiki ??

Related #318

Is there a way I could push my section onto the front of the default SPACESHIP_PROMPT_ORDER?

Is there a way I could push my section onto the front of the default SPACESHIP_PROMPT_ORDER?

Yes, You can position custom section anywhere in SPACESHIP_PROMPT_ORDER. If you want to prepend custom section to existing sections you can use something like

autoload -U promptinit; promptinit
prompt spaceship

SPACESHIP_PROMPT_ORDER=(wip $SPACESHIP_PROMPT_ORDER)

Closing this now due to inactivity. Feel free to reopen if your issue is not resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwhipp picture jwhipp  路  3Comments

tbekaert picture tbekaert  路  3Comments

martincartledge picture martincartledge  路  4Comments

MatthiasJ picture MatthiasJ  路  4Comments

janjur picture janjur  路  3Comments