diff --git a/powerline/bindings/zsh/__init__.py b/powerline/bindings/zsh/__init__.py index 46940c80..3f91012a 100644 --- a/powerline/bindings/zsh/__init__.py +++ b/powerline/bindings/zsh/__init__.py @@ -129,6 +129,7 @@ class Prompt(object): def __str__(self): zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"') + zsh.eval('_POWERLINE_SHORTENED_PATH="${(%):-%~}"') segment_info = { 'args': self.args, 'environ': environ, @@ -137,6 +138,8 @@ class Prompt(object): 'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'), 'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'), } + zsh.setvalue('_POWERLINE_PARSER_STATE', None) + zsh.setvalue('_POWERLINE_SHORTENED_PATH', None) r = '' if self.above: for line in self.powerline.render_above_lines( diff --git a/powerline/bindings/zsh/powerline.zsh b/powerline/bindings/zsh/powerline.zsh index 0c097b66..162d44f9 100644 --- a/powerline/bindings/zsh/powerline.zsh +++ b/powerline/bindings/zsh/powerline.zsh @@ -103,10 +103,6 @@ _powerline_set_jobnum() { _POWERLINE_JOBNUM=${(%):-%j} } -_powerline_set_shortened_path() { - _POWERLINE_SHORTENED_PATH="${(%):-%~}" -} - _powerline_update_counter() { zpython '_powerline.precmd()' } @@ -120,8 +116,6 @@ _powerline_setup_prompt() { fi done precmd_functions+=( _powerline_set_jobnum ) - chpwd_functions+=( _powerline_set_shortened_path ) - _powerline_set_shortened_path VIRTUAL_ENV_DISABLE_PROMPT=1 @@ -144,7 +138,7 @@ _powerline_setup_prompt() { add_args+=' --last_exit_code=$?' add_args+=' --last_pipe_status="$pipestatus"' add_args+=' --renderer_arg="client_id=$$"' - add_args+=' --renderer_arg="shortened_path=$_POWERLINE_SHORTENED_PATH"' + add_args+=' --renderer_arg="shortened_path=${(%):-%~}"' add_args+=' --jobnum=$_POWERLINE_JOBNUM' local new_args_2=' --renderer_arg="parser_state=${(%%):-%_}"' new_args_2+=' --renderer_arg="local_theme=continuation"' diff --git a/tests/test_shells/input.zsh b/tests/test_shells/input.zsh index b4fa6487..4aa6789d 100644 --- a/tests/test_shells/input.zsh +++ b/tests/test_shells/input.zsh @@ -1,5 +1,7 @@ +unset HOME unsetopt promptsp notransientrprompt setopt interactivecomments +setopt autonamedirs # POWERLINE_CONFIG_PATH=$PWD/powerline/config_files # POWERLINE_THEME_CONFIG=( default_leftonly.segment_data.hostname.args.only_if_ssh=false ) # POWERLINE_CONFIG=( ext.shell.theme=default_leftonly ) @@ -11,7 +13,7 @@ export VIRTUAL_ENV= cd tests/shell/3rd cd .git cd .. -VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" VIRTUAL_ENV= bgscript.sh & waitpid.sh false @@ -38,6 +40,8 @@ do break done 1 +cd . +cd . hash -d foo=$PWD:h ; cd . POWERLINE_COMMAND="$POWERLINE_COMMAND -t default.dividers.left.hard=\$ABC" true diff --git a/tests/test_shells/zsh.daemon.ok b/tests/test_shells/zsh.daemon.ok index d0259c4a..2a431ec0 100644 --- a/tests/test_shells/zsh.daemon.ok +++ b/tests/test_shells/zsh.daemon.ok @@ -1,7 +1,7 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment"   HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh [1] PID @@ -33,6 +33,8 @@ abc 1) def 2) ghi 3) jkl                    Select variant  1 def + INSERT  ⋯  tests  shell  3rd  cd . + INSERT  ⋯  tests  shell  3rd  cd .  INSERT  ⋯  tests  shell  3rd  hash -d foo=$PWD:h ; cd .  INSERT  ~foo  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default.dividers.left.hard=\$ABC"  INSERT $ABC~foo  3rd $ABCtrue diff --git a/tests/test_shells/zsh.nodaemon.ok b/tests/test_shells/zsh.nodaemon.ok index f3edbcdc..5a4c75d2 100644 --- a/tests/test_shells/zsh.nodaemon.ok +++ b/tests/test_shells/zsh.nodaemon.ok @@ -1,7 +1,7 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  ⋯  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment"   HOSTNAME  USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh [1] PID @@ -33,6 +33,8 @@ abc 1) def 2) ghi 3) jkl  Select variant  1 def + INSERT  ⋯  tests  shell  3rd  cd . + INSERT  ⋯  tests  shell  3rd  cd .  INSERT  ⋯  tests  shell  3rd  hash -d foo=$PWD:h ; cd .  INSERT  ~foo  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default.dividers.left.hard=\$ABC"  INSERT $ABC~foo  3rd $ABCtrue