Pure: Error when sourcing .zshrc: shift count must be <= $#

Created on 12 Feb 2017  路  2Comments  路  Source: sindresorhus/pure

General information

  • Pure version: 1.5.0
  • ZSH version: 5.2
  • Terminal program & version: Hyper 1.1.0
  • Operating system: macOS Sierra 10.12.3
  • ZSH framework: oh-my-zsh

I have:

  • [x] Tested with another terminal program and can reproduce the issue:
    iTerm 3.0.13
  • [x] Followed the Integration instructions for my framework

Problem description

I get this error on Hyper and iTerm when I try to source my .zshrc file.

prompt_pure_setup:shift:1: shift count must be <= $#

Any insight would be appreciated! Thanks!

Reproduction steps

  1. npm install -g pure-prompt
  2. source ~/.zshrc

I've also tried uninstalling the global node_module of pure-prompt and removing the directory. And then removing async and pure from zsh_functions. Then installing pure manually by cloning the repo and linking the pure.zsh and async.zsh. But I get the same error when I source my .zshrc.

My .zshrc:

ZSH_THEME=""

plugins=(git)

export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

source $ZSH/oh-my-zsh.sh

autoload -U promptinit; promptinit
prompt pure
source /Users/username/Downloads/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Most helpful comment

Thanks for the report.

Interestingly I was able to reproduce thanks to your mention of source ~ /.zshrc. The underlying issue seems to be that when you source your rc-file, prompt pure gets run a second time. This time around it has already been autoloaded and, turns out, not called with any parameters.

This means our initial assumption about the loading beahavior is incorrect and the code must change, I'll push a fix tomorrow.

Meanwhile, I would strongly discourage the usage of source ~/.zshrc to reload shell configuration simply because this re-evaluates everything while not erasing the old. This means you could end up with duplicate states. A simple exec zsh would suffice. What exec does is it replaces your shell with the command following, since it's zsh it replaces your shell with a clean instance.

All 2 comments

Thanks for the report.

Interestingly I was able to reproduce thanks to your mention of source ~ /.zshrc. The underlying issue seems to be that when you source your rc-file, prompt pure gets run a second time. This time around it has already been autoloaded and, turns out, not called with any parameters.

This means our initial assumption about the loading beahavior is incorrect and the code must change, I'll push a fix tomorrow.

Meanwhile, I would strongly discourage the usage of source ~/.zshrc to reload shell configuration simply because this re-evaluates everything while not erasing the old. This means you could end up with duplicate states. A simple exec zsh would suffice. What exec does is it replaces your shell with the command following, since it's zsh it replaces your shell with a clean instance.

Landed in 1.5.1 馃帀.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

d3lm picture d3lm  路  3Comments

harukizaemon picture harukizaemon  路  10Comments

opticalgenesis picture opticalgenesis  路  9Comments

ebsen picture ebsen  路  10Comments

julenpardo picture julenpardo  路  5Comments