Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt slow to show when using Spaceship #161

Closed
dguay opened this issue Jul 1, 2017 · 4 comments

Comments

@dguay
Copy link
Contributor

commented Jul 1, 2017

Issue

My shell is kind of slow with the Spaceship theme and it's a bit annoying. I've tried switching to other themes to see if it was other plugins but it doesn't happen.

See the gifs with Pure theme compared to Spaceship.

Gifs

With Pure theme
With Spaceship theme

As you can see, Spaceship theme is a lot slower and not as fast as what I see in the README's gif.
Even at startup it takes ~0.5s more to load.

Environment

Operating system: macOS 10.12.5
Terminal emulator: iTerm2 3.0.15
ZSH version: 5.3.1
ZSH plugin manager: zplug 2.4.1

Relevant .zshrc

# Path to dotfiles directory.
export DOTFILES=$HOME/.dotfiles

# Initialize zplug.
source ~/.zplug/init.zsh

# Initialize aliases
source ~/.aliases

# 256 colors terminal
export TERM="xterm-256color"

#############################################################
# Env
#############################################################
if [[ -e /usr/libexec/java_home ]]; then
  export JAVA_HOME=`/usr/libexec/java_home`
fi

export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true'

#############################################################
# Plugins
#############################################################

# Themes
# zplug "sindresorhus/pure", as:theme, use:"*.zsh"
zplug "denysdovhan/spaceship-zsh-theme", use:spaceship.zsh, from:github, as:theme

# SPACESHIP Theme
SPACESHIP_PROMPT_SYMBOL=❯
#SPACESHIP_PROMPT_ADD_NEWLINE=false
#SPACESHIP_PROMPT_SEPARATE_LINE=false
SPACESHIP_DIR_COLOR="081"

zplug "lib/completion", from:oh-my-zsh
zplug "lib/history", from:oh-my-zsh
zplug "lib/key-bindings", from:oh-my-zsh
zplug "lib/theme-and-appearance", from:oh-my-zsh
zplug "lib/spectrum", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh, ignore:oh-my-zsh.sh
zplug "plugins/mercurial", from:oh-my-zsh, ignore:oh-my-zsh.sh
zplug "plugins/command-not-found", from:oh-my-zsh, ignore:oh-my-zsh.sh
zplug 'djui/alias-tips'
zplug "zsh-users/zsh-syntax-highlighting", defer:3
# zplug "zsh-users/zsh-autosuggestions"

# Check for uninstalled plugins.
if ! zplug check --verbose; then
  printf "Install? [y/N]: "
  if read -q; then
    echo; zplug install
  fi
fi

# Source plugins.
zplug load

Anything I can do to fix this? I really like the theme and would like to continue using it but not with this kind of lag.

@dguay dguay changed the title Slowing down my zsh a lot Prompt slow to show when using Spaceship Jul 1, 2017

@salmanulfarzy

This comment has been minimized.

Copy link
Collaborator

commented Jul 1, 2017

One of the main reason for increased load time is large set of features in spaceship-zsh-theme. We are working on improving the performance of theme in #148 .

For the time being, you could improve loading time by only loading sections relevant to you by specifying SPACESHIP_PROMPT_ORDER. For instance,

SPACESHIP_PROMPT_ORDER=(user host dir git node exec_time line_sep jobs exit_code char)

Please see prompt order, example and presets for more information.

@dguay

This comment has been minimized.

Copy link
Contributor Author

commented Jul 1, 2017

Ok I've tried different combinations with SPACESHIP_PROMPT_ORDER and discovered it's the hg section that slow down the prompt. We are using mercurial at work so I need this. Could you take a look at this?

# Check if the current directory is in a Git repository.
# USAGE:
#   _is_git
_is_git() {
  command git rev-parse --is-inside-work-tree &>/dev/null
}

# Check if the current direcotory is in a Mercurial repository
# USAGE:
#   _is_hg
_is_hg() {
  command hg --cwd $PWD root &>/dev/null
}

is_hg() is a bit slower than is_git()

@salmanulfarzy

This comment has been minimized.

Copy link
Collaborator

commented Jul 1, 2017

I did the hg section. I've limited knowledge about mercurial and I don't use that much. Highly appreciated if you could help improve hg section. Please take a look at #54, #65 and #156

@dguay

This comment has been minimized.

Copy link
Contributor Author

commented Jul 1, 2017

I'll see what I can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.