Always show hostname (travis is ssh), fix jobnum in zsh

This commit is contained in:
ZyX 2014-01-14 00:18:34 +04:00
parent 0f0a5e92d3
commit 2e713269ae
6 changed files with 45 additions and 43 deletions

View File

@ -24,13 +24,28 @@ _powerline_tmux_set_columns() {
_powerline_tmux_setenv COLUMNS "$COLUMNS"
}
_powerline_install_precmd() {
_powerline_precmd() {
# If you are wondering why I am not using the same code as I use for bash
# ($(jobs|wc -l)): consider the following test:
# echo abc | less
# <C-z>
# . This way jobs will print
# [1] + done echo abc |
# suspended less -M
# ([ is in first column). You see: any line counting thingie will return
# wrong number of jobs. You need to filter the lines first. Or not use
# jobs built-in at all.
_POWERLINE_JOBNUM=${(%):-%j}
}
_powerline_setup_prompt() {
emulate -L zsh
for f in "${precmd_functions[@]}"; do
if [[ "$f" = "_powerline_precmd" ]]; then
return
fi
done
precmd_functions+=( _powerline_precmd )
chpwd_functions+=( _powerline_tmux_set_pwd )
if zmodload zsh/zpython &>/dev/null ; then
zpython 'from powerline.bindings.zsh import setup as powerline_setup'
@ -38,19 +53,7 @@ _powerline_install_precmd() {
zpython 'del powerline_setup'
else
local add_args='--last_exit_code=$? --last_pipe_status="$pipestatus"'
# If you are wondering why I am not using the same code as I use for
# bash ($(jobs|wc -l)): consider the following test:
# echo abc | less
# <C-z>
# . This way jobs will print
# [1] + done echo abc |
# suspended less -M
# ([ is in first column). You see: any line counting thingie will return
# wrong number of jobs. You need to filter the lines first. Or not use
# jobs built-in at all.
#
# This and above variants also do not use subshell.
add_args+=' --jobnum=${(%):-%j}'
add_args+=' --jobnum=$_POWERLINE_JOBNUM'
PS1='$($POWERLINE_COMMAND shell left -r zsh_prompt '$add_args')'
RPS1='$($POWERLINE_COMMAND shell right -r zsh_prompt '$add_args')'
fi
@ -62,4 +65,4 @@ _powerline_tmux_set_pwd
setopt promptpercent
setopt promptsubst
_powerline_install_precmd
_powerline_setup_prompt

View File

@ -1,14 +1,12 @@
 USER  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
 USER   BRANCH  ⋯  tests  shell  3rd  cd .git
 USER   BRANCH  ⋯  shell  3rd  .git  cd ..
 USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment"
 USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
 USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" &
  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  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" &
[1] PID
 USER   BRANCH  ⋯  tests  shell  3rd  1  false
 USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done"
 USER   BRANCH  ⋯  tests  shell  3rd  false
 USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  exit
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit
exit

View File

@ -1,7 +1,8 @@
POWERLINE_COMMAND="$PWD/scripts/powerline -p $PWD/powerline/config_files"
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
VIRTUAL_ENV=
source powerline/bindings/bash/powerline.sh ; cd tests/shell/3rd
POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
cd .git
cd ..
VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment"
@ -10,5 +11,4 @@ bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" &
false
kill `cat pid` ; sleep 1s
false
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
exit

View File

@ -1,7 +1,9 @@
unsetopt promptsp transientrprompt
POWERLINE_COMMAND=( $PWD/scripts/powerline -p $PWD/powerline/config_files ) ; VIRTUAL_ENV=
source powerline/bindings/zsh/powerline.zsh ; cd tests/shell/3rd
POWERLINE_COMMAND=( $PWD/scripts/powerline -p $PWD/powerline/config_files )
POWERLINE_COMMAND=( $POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false )
POWERLINE_COMMAND=( $POWERLINE_COMMAND -c ext.shell.theme=default_leftonly )
VIRTUAL_ENV=
source powerline/bindings/zsh/powerline.zsh ; cd tests/shell/3rd
cd .git
cd ..
VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment"
@ -10,5 +12,4 @@ bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" &
false
kill `cat pid` ; sleep 1s
false
POWERLINE_COMMAND=( $POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false )
exit

View File

@ -17,7 +17,7 @@ run_test() {
screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \
env LANG=en_US.UTF-8 BINDFILE="$BINDFILE" "$@"
screen -S "$SESNAME" -X readreg a tests/test_shells/input.$SH
sleep 5s
sleep 0.3s
screen -S "$SESNAME" -p 0 -X width 300 1
screen -S "$SESNAME" -p 0 -X logfile tests/shell/screen.log
screen -S "$SESNAME" -p 0 -X paste a
@ -39,12 +39,14 @@ if ! run_test bash --norc --noprofile -i ; then
echo "Failed bash"
FAILED=1
fi
cp tests/shell/screen.log tests/bash.log
rm tests/shell/screen.log
if ! run_test zsh -f -i ; then
echo "Failed zsh"
FAILED=1
fi
cp tests/shell/screen.log tests/zsh.log
rm tests/shell/screen.log
rm -r tests/shell

View File

@ -1,14 +1,12 @@
 USER  ⋯  tests  shell  3rd  POWERLINE_COMMAND=( $POWERLINE_COMMAND -c ext.shell.theme=default_leftonly )
 USER   BRANCH  ⋯  tests  shell  3rd  cd .git
 USER   BRANCH  ⋯  shell  3rd  .git  cd ..
 USER   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment"
 USER  ⓔ  some-virtual-environment   BRANCH  ⋯  tests  shell  3rd  VIRTUAL_ENV=
 USER   BRANCH  ⋯  tests  shell  3rd  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" &
  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  bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" &
[1] PID
 USER   BRANCH  ⋯  tests  shell  3rd  false
 USER   BRANCH  ⋯  tests  shell  3rd  1  kill `cat pid` ; sleep 1s
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1] + terminated bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done"
 USER   BRANCH  ⋯  tests  shell  3rd  false
 USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND=( $POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false )
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  exit
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  exit