From 1a841a4ac8e68f2967e9369a03b38cb0d9a6a5ee Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Jan 2014 16:15:40 +0400 Subject: [PATCH 1/4] Replace POWERLINE_OLD_PROMPT_COMMAND with the code used by [z][1] Does not fix anything, but is three lines less and is probably the way other tools expect us to do. [1]: https://github.com/rupa/z --- powerline/bindings/bash/powerline.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 4e4d52de..f2fd7876 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -31,8 +31,6 @@ _powerline_tmux_set_columns() { _powerline_prompt() { local last_exit_code=$? - [[ -z "$POWERLINE_OLD_PROMPT_COMMAND" ]] || - eval $POWERLINE_OLD_PROMPT_COMMAND PS1="$($POWERLINE_COMMAND shell left -r bash_prompt --last_exit_code=$last_exit_code --jobnum="$(jobs|wc -l)")" _powerline_tmux_set_pwd return $last_exit_code @@ -42,5 +40,4 @@ trap "_powerline_tmux_set_columns" SIGWINCH _powerline_tmux_set_columns [[ "$PROMPT_COMMAND" != "${PROMPT_COMMAND/_powerline_prompt/}" ]] || - POWERLINE_OLD_PROMPT_COMMAND="$PROMPT_COMMAND" -export PROMPT_COMMAND="_powerline_prompt" + export PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n'"_powerline_prompt;" From c6324afbc5b06b49d63b78f3b83a955ce37b98b4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Jan 2014 16:19:23 +0400 Subject: [PATCH 2/4] Replace `jobs` with `jobs -p` If some long shell code is run in the background it may be shown as more then one job: bash-4.2$ { > echo abc | while read line ; do > sleep 1s > sleep 1s > done > } & [1] 9401 bash-4.2$ jobs [1]+ Running { echo abc | while read line; do sleep 1s; sleep 1s; done; } & `jobs -p` print exactly one job in this case. --- powerline/bindings/bash/powerline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index f2fd7876..16b295b2 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -31,7 +31,7 @@ _powerline_tmux_set_columns() { _powerline_prompt() { local last_exit_code=$? - PS1="$($POWERLINE_COMMAND shell left -r bash_prompt --last_exit_code=$last_exit_code --jobnum="$(jobs|wc -l)")" + PS1="$($POWERLINE_COMMAND shell left -r bash_prompt --last_exit_code=$last_exit_code --jobnum="$(jobs -p|wc -l)")" _powerline_tmux_set_pwd return $last_exit_code } From 49d837684519c537587f2c7206c85e02c6f8f8b1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Jan 2014 16:27:12 +0400 Subject: [PATCH 3/4] Document problem found when exploring #749 --- docs/source/installation/troubleshooting-common.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/source/installation/troubleshooting-common.rst b/docs/source/installation/troubleshooting-common.rst index a0142e38..c5b4b2e2 100644 --- a/docs/source/installation/troubleshooting-common.rst +++ b/docs/source/installation/troubleshooting-common.rst @@ -60,3 +60,15 @@ My vim statusline is not displayed completely and has too much spaces * Be sure you have ``ambiwidth`` option set to ``single``. * Alternative: set :ref:`ambiwidth ` to 2, remove fancy dividers (they suck when ``ambiwidth`` is set to double). + +When using `z ` powerline shows wrong number of jobs +------------------------------------------------------------------------------- + +This happens because `z ` is launching some jobs in +the background from ``$POWERLINE_COMMAND`` and these jobs fail to finish before +powerline prompt is run. + +Solution to this problem is simple: be sure that :file:`z.sh` is sourced +strictly after :file:`powerline/bindings/bash/powerline.sh`. This way background +jobs are spawned by `z ` after powerline has done its +job. From a590e100a23a0c225467b34b7c4481ece45905ad Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Jan 2014 17:26:31 +0400 Subject: [PATCH 4/4] Fix functional shell tests in travis Hostname in travis contains random numbers meaning that it occasionally may contain a PID as well. Thus it must be replaced first. --- tests/test_shells/postproc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_shells/postproc.py b/tests/test_shells/postproc.py index ae2e887a..5c1832f2 100755 --- a/tests/test_shells/postproc.py +++ b/tests/test_shells/postproc.py @@ -29,9 +29,9 @@ with codecs.open(fname, 'r', encoding='utf-8') as R: line = line.translate({ ord('\r'): None }) - line = line.replace(pid, 'PID') line = line.replace(hostname, 'HOSTNAME') line = line.replace(user, 'USER') + line = line.replace(pid, 'PID') W.write(line) os.rename(new_fname, fname)