Merge pull request #978 from ZyX-I/other-shell-local-themes

Add support for PS2 and PS3 prompts outside of zsh
This commit is contained in:
Nikolai Aleksandrovich Pavlov 2014-08-12 08:26:13 +04:00
commit b8c61c1d78
25 changed files with 415 additions and 105 deletions

View File

@ -2,6 +2,16 @@
Shell prompts
*************
.. note::
Powerline daemon is not run automatically by any of my bindings. It is
advised that you add
.. code-block:: bash
powerline-daemon -q
before any other powerline-related code in your shell configuration file.
Bash prompt
===========
@ -12,6 +22,28 @@ the absolute path to your Powerline installation directory:
. {repository_root}/powerline/bindings/bash/powerline.sh
.. note::
Since without powerline daemon bash bindings are very slow PS2
(continuation) and PS3 (select) prompts are not set up. Thus it is advised
to use
.. code-block:: bash
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. {repository_root}/powerline/bindings/bash/powerline.sh
in your bash configuration file. Without ``POWERLINE_BASH_*`` variables PS2
and PS3 prompts are computed exactly once at bash startup.
.. warning::
At maximum bash continuation PS2 and select PS3 prompts are computed each
time main PS1 prompt is computed. Do not expect it to work properly if you
e.g. put current time there.
At minimum they are computed once on startup.
Zsh prompt
==========
@ -59,6 +91,20 @@ following in ``~/.profile``:
will source (using ``.`` command) both former ``$ENV`` file and
:file:`powerline.sh` files and set ``$ENV`` to the path of this new file.
.. warning::
Mksh users have to set ``$POWERLINE_SHELL_CONTINUATION`` and
``$POWERLINE_SHELL_SELECT`` to 1 to get PS2 and PS3 (continuation and
select) prompts support respectively: as command substitution is not
performed in these shells for these prompts they are updated once each time
PS1 prompt is displayed which may be slow.
It is also known that while PS2 and PS3 update is triggered at PS1 update it
is *actually performed* only *next* time PS1 is displayed which means that
PS2 and PS3 prompts will be outdated and may be incorrect for this reason.
Without these variables PS2 and PS3 prompts will be set once at startup.
This only touches mksh users: busybox and dash both have no such problem.
.. warning::
Job count is using some weird hack that uses signals and temporary files for
interprocess communication. It may be wrong sometimes. Not the case in mksh.

View File

@ -39,6 +39,16 @@ _powerline_init_tmux_support() {
fi
}
_powerline_local_prompt() {
# Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme
$POWERLINE_COMMAND shell $1 \
$2 \
--last_exit_code=$3 \
--jobnum=$4 \
--renderer_arg="client_id=$$" \
--renderer_arg="local_theme=$5"
}
_powerline_prompt() {
# Arguments: side, last_exit_code, jobnum
$POWERLINE_COMMAND shell $1 \
@ -53,6 +63,12 @@ _powerline_set_prompt() {
local last_exit_code=$?
local jobnum="$(jobs -p|wc -l)"
PS1="$(_powerline_prompt aboveleft $last_exit_code $jobnum)"
if test -n "$POWERLINE_SHELL_CONTINUATION$POWERLINE_BASH_CONTINUATION" ; then
PS2="$(_powerline_local_prompt left -rbash_prompt $last_exit_code $jobnum continuation)"
fi
if test -n "$POWERLINE_SHELL_SELECT$POWERLINE_BASH_SELECT" ; then
PS3="$(_powerline_local_prompt left '' $last_exit_code $jobnum select)"
fi
return $last_exit_code
}
@ -63,6 +79,8 @@ _powerline_setup_prompt() {
fi
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND%_powerline_set_prompt*}" ||
PROMPT_COMMAND=$'_powerline_set_prompt\n'"${PROMPT_COMMAND}"
PS2="$(_powerline_local_prompt left -rbash_prompt 0 0 continuation)"
PS3="$(_powerline_local_prompt left '' 0 0 select)"
}
if test -z "${POWERLINE_CONFIG}" ; then

View File

@ -41,6 +41,8 @@ _powerline_set_append_trap() {
if echo "$_powerline_traps" | grep -cm1 $2'$' >/dev/null ; then
_powerline_traps="$(echo "$_powerline_traps" | sed "s/ $2/'\\n$1' $2/")"
eval "$_powerline_traps"
else
trap "$1" $2
fi
}
else
@ -131,6 +133,17 @@ _powerline_set_jobs() {
_powerline_set_jobs
}
_powerline_local_prompt() {
# Arguments: side, exit_code, local theme
_powerline_set_jobs
$POWERLINE_COMMAND shell $1 \
$_POWERLINE_RENDERER_ARG \
--renderer_arg="client_id=$$" \
--last_exit_code=$2 \
--jobnum=$_POWERLINE_JOBS \
--renderer_arg="local_theme=$3"
}
_powerline_prompt() {
# Arguments: side, exit_code
_powerline_set_jobs
@ -140,6 +153,37 @@ _powerline_prompt() {
--renderer_arg="client_id=$$" \
--last_exit_code=$2 \
--jobnum=$_POWERLINE_JOBS
_powerline_update_psN
}
_powerline_setup_psN() {
case "$1" in
mksh|ksh|bash)
_POWERLINE_PID=$$
_powerline_update_psN() {
kill -USR1 $_POWERLINE_PID
}
# No command substitution in PS2 and PS3
_powerline_set_psN() {
if test -n "$POWERLINE_SHELL_CONTINUATION" ; then
PS2="$(_powerline_local_prompt left $? continuation)"
fi
if test -n "$POWERLINE_SHELL_SELECT" ; then
PS3="$(_powerline_local_prompt left $? select)"
fi
}
_powerline_append_trap '_powerline_set_psN' USR1
_powerline_set_psN
;;
bb|ash|dash)
_powerline_update_psN() {
# Do nothing
return
}
PS2='$(_powerline_local_prompt left $? continuation)'
# No select support
;;
esac
}
_powerline_setup_prompt() {
@ -149,6 +193,9 @@ _powerline_setup_prompt() {
_powerline_set_command "$@"
_powerline_set_renderer_arg "$@"
PS1='$(_powerline_prompt aboveleft $?)'
PS2="$(_powerline_local_prompt left 0 continuation)"
PS3="$(_powerline_local_prompt left 0 select)"
_powerline_setup_psN "$@"
}
_powerline_init_tmux_support() {

View File

@ -3,6 +3,7 @@
from __future__ import absolute_import, unicode_literals, division, print_function
from powerline.renderer import Renderer
from powerline.theme import Theme
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
@ -120,5 +121,19 @@ class ShellRenderer(Renderer):
r = '\033P' + r.replace('\033', '\033\033') + '\033\\'
return self.escape_hl_start + r + self.escape_hl_end
def get_theme(self, matcher_info):
if not matcher_info:
return self.theme
match = self.local_themes[matcher_info]
try:
return match['theme']
except KeyError:
match['theme'] = Theme(
theme_config=match['config'],
main_theme_config=self.theme_config,
**self.theme_kwargs
)
return match['theme']
renderer = ShellRenderer

View File

@ -3,7 +3,6 @@
from __future__ import absolute_import, unicode_literals
from powerline.renderers.shell import ShellRenderer
from powerline.theme import Theme
class ZshPromptRenderer(ShellRenderer):
@ -14,19 +13,5 @@ class ZshPromptRenderer(ShellRenderer):
character_translations = ShellRenderer.character_translations.copy()
character_translations[ord('%')] = '%%'
def get_theme(self, matcher_info):
if not matcher_info:
return self.theme
match = self.local_themes[matcher_info]
try:
return match['theme']
except KeyError:
match['theme'] = Theme(
theme_config=match['config'],
main_theme_config=self.theme_config,
**self.theme_kwargs
)
return match['theme']
renderer = ZshPromptRenderer

View File

@ -89,7 +89,11 @@ def continuation(pl, segment_info, omit_cmdsubst=True, right_align=False, rename
Highlight groups used: ``continuation``, ``continuation:current``.
'''
if not segment_info.get('parser_state'):
return None
return [{
'contents': '',
'width': 'auto',
'highlight_group': ['continuation:current', 'continuation'],
}]
ret = []
for state in segment_info['parser_state'].split():
@ -97,7 +101,7 @@ def continuation(pl, segment_info, omit_cmdsubst=True, right_align=False, rename
if state:
ret.append({
'contents': state,
'highlight_group': 'continuation',
'highlight_group': ['continuation'],
'draw_inner_divider': True,
})
@ -111,8 +115,8 @@ def continuation(pl, segment_info, omit_cmdsubst=True, right_align=False, rename
if right_align:
ret[0].update(width='auto', align='r')
ret[-1]['highlight_group'] = 'continuation:current'
ret[-1]['highlight_group'] = ['continuation:current', 'continuation']
else:
ret[-1].update(width='auto', align='l', highlight_group='continuation:current')
ret[-1].update(width='auto', align='l', highlight_group=['continuation:current', 'continuation'])
return ret

View File

@ -62,13 +62,17 @@ class TestShell(TestCase):
def test_continuation(self):
pl = Pl()
self.assertEqual(shell.continuation(pl=pl, segment_info={}), None)
self.assertEqual(shell.continuation(pl=pl, segment_info={}), [{
'contents': '',
'width': 'auto',
'highlight_group': ['continuation:current', 'continuation'],
}])
segment_info = {'parser_state': 'if cmdsubst'}
self.assertEqual(shell.continuation(pl=pl, segment_info=segment_info), [
{
'contents': 'if',
'draw_inner_divider': True,
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
'width': 'auto',
'align': 'l',
},
@ -77,7 +81,7 @@ class TestShell(TestCase):
{
'contents': 'if',
'draw_inner_divider': True,
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
'width': 'auto',
'align': 'r',
},
@ -86,12 +90,12 @@ class TestShell(TestCase):
{
'contents': 'if',
'draw_inner_divider': True,
'highlight_group': 'continuation',
'highlight_group': ['continuation'],
},
{
'contents': 'cmdsubst',
'draw_inner_divider': True,
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
'width': 'auto',
'align': 'l',
},
@ -100,21 +104,21 @@ class TestShell(TestCase):
{
'contents': 'if',
'draw_inner_divider': True,
'highlight_group': 'continuation',
'highlight_group': ['continuation'],
'width': 'auto',
'align': 'r',
},
{
'contents': 'cmdsubst',
'draw_inner_divider': True,
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
},
])
self.assertEqual(shell.continuation(pl=pl, segment_info=segment_info, omit_cmdsubst=True, right_align=True), [
{
'contents': 'if',
'draw_inner_divider': True,
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
'width': 'auto',
'align': 'r',
},
@ -123,7 +127,7 @@ class TestShell(TestCase):
{
'contents': 'IF',
'draw_inner_divider': True,
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
'width': 'auto',
'align': 'r',
},
@ -131,7 +135,7 @@ class TestShell(TestCase):
self.assertEqual(shell.continuation(pl=pl, segment_info=segment_info, omit_cmdsubst=True, right_align=True, renames={'if': None}), [
{
'contents': '',
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
'width': 'auto',
'align': 'r',
},
@ -141,17 +145,17 @@ class TestShell(TestCase):
{
'contents': 'then',
'draw_inner_divider': True,
'highlight_group': 'continuation',
'highlight_group': ['continuation'],
},
{
'contents': 'then',
'draw_inner_divider': True,
'highlight_group': 'continuation',
'highlight_group': ['continuation'],
},
{
'contents': 'then',
'draw_inner_divider': True,
'highlight_group': 'continuation:current',
'highlight_group': ['continuation:current', 'continuation'],
'width': 'auto',
'align': 'l',
},

View File

@ -0,0 +1,28 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
[1] PID
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc
                                     def
                                     '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -0,0 +1,28 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
[1] PID
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo '
   abc
   def
   '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -1,18 +0,0 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
[1] PID
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -0,0 +1,27 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc
                                     def
                                     '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -0,0 +1,27 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo '
   abc
   def
   '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -1,17 +0,0 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  cd "$DIR1"
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -0,0 +1,26 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1   USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc
                                     def
                                     '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -0,0 +1,26 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1   USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo '
   abc
   def
   '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -1,17 +0,0 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1] + Terminated bgscript.sh
cd "$DIR1"
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1    HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -11,6 +11,12 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh
false
kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
echo '
abc
def
'
cd "$DIR1"
cd ../"$DIR2"
cd ../'\[\]'

View File

@ -11,6 +11,12 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh
false
kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
echo '
abc
def
'
cd "$DIR1"
cd ../"$DIR2"
cd ../'\[\]'

View File

@ -11,6 +11,12 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh
false
kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
echo '
abc
def
'
cd "$DIR1"
cd ../"$DIR2"
cd ../'\[\]'

View File

@ -11,6 +11,13 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh
false
kill `cat pid` ; sleep 1
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
echo -n
echo '
abc
def
'
cd "$DIR1"
cd ../"$DIR2"
cd ../'\[\]'

View File

@ -0,0 +1,30 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
[1] PID
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1
[1] + Terminated bash -c ...
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo -n
  BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc
                                     def
                                     '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -0,0 +1,30 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
[1] PID
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1
[1] + Terminated bash -c ...
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"
  BRANCH  ⋯  tests  shell  3rd  echo -n
  BRANCH  ⋯  tests  shell  3rd  echo '
   abc
   def
   '
abc
def
  BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -1,19 +0,0 @@
  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  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
[1] PID
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1
[1] + Terminated bash -c ...
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  cd "$DIR1"
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^[[32m  cd ../"$DIR2"
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  ^H  cd ../'\[\]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  \[\]  cd ../'%%'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  %%  cd ../'#[bold]'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  #[bold]  cd ../'(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  HOSTNAME  USER   BRANCH  ⋯  shell  3rd  `echo`  false

View File

@ -58,4 +58,9 @@ with codecs.open(fname, 'r', encoding='utf-8') as R:
# command, in travis it is truncated just after `true`.
if line.startswith('[1] + Terminated'):
line = '[1] + Terminated bash -c ...\n'
elif shell == 'dash':
# Position of this line is not stable: it may go both before and
# after the next line
if line.startswith('[1] + Terminated'):
continue
W.write(line)

View File

@ -22,6 +22,11 @@ run() {
if test "x$SH" = "xfish" ; then
local_path="${local_path}:/usr/bin:/bin"
fi
if test $TEST_TYPE = daemon ; then
local additional_prompts=1
else
local additional_prompts=
fi
env -i \
PATH="$local_path" \
TERM="${TERM}" \
@ -33,6 +38,8 @@ run() {
DIR2="${DIR2}" \
XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" \
IPYTHONDIR="$PWD/tests/shell/ipython_home" \
POWERLINE_SHELL_CONTINUATION=$additional_prompts \
POWERLINE_SHELL_SELECT=$additional_prompts \
"$@"
}
@ -156,6 +163,9 @@ ln -s "$(which cut)" tests/shell/path
ln -s "$(which bc)" tests/shell/path
ln -s "$(which expr)" tests/shell/path
ln -s "$(which mktemp)" tests/shell/path
ln -s "$(which grep)" tests/shell/path
ln -s "$(which sed)" tests/shell/path
ln -s "$(which rm)" tests/shell/path
ln -s ../../test_shells/bgscript.sh tests/shell/path
ln -s ../../test_shells/waitpid.sh tests/shell/path
for pexe in powerline powerline-config ; do
@ -169,7 +179,7 @@ for pexe in powerline powerline-config ; do
fi
done
for exe in bash zsh bb busybox fish tcsh mksh dash ipython ; do
for exe in bash zsh busybox fish tcsh mksh dash ipython ; do
if which $exe >/dev/null ; then
ln -s "$(which $exe)" tests/shell/path
fi
@ -177,7 +187,7 @@ done
unset ENV
if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || test "x${ONLY_SHELL}" = xbb ; then
if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || test "x${ONLY_SHELL}" = xbusybox ; then
powerline-daemon -k || true
sleep 1s