From 04c293e40d7480fc79d67033ac559c77fc550ab3 Mon Sep 17 00:00:00 2001 From: sthsieh Date: Fri, 23 May 2014 23:44:19 +0800 Subject: [PATCH 1/7] Add fish shell vi-mode support --- powerline/bindings/fish/powerline-setup.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/powerline/bindings/fish/powerline-setup.fish b/powerline/bindings/fish/powerline-setup.fish index ff0d42bc..0e9fde04 100644 --- a/powerline/bindings/fish/powerline-setup.fish +++ b/powerline/bindings/fish/powerline-setup.fish @@ -33,6 +33,9 @@ function powerline-setup if test -z "$POWERLINE_COMMAND" set -g POWERLINE_COMMAND (eval $POWERLINE_CONFIG shell command) end + function --on-variable fish_bind_mode _powerline_bind_mode + set -g -x _POWERLINE_MODE $fish_bind_mode + end function --on-variable POWERLINE_COMMAND _powerline_update set -l addargs "--last_exit_code=\$status" set -l addargs "$addargs --last_pipe_status=\$status" @@ -67,6 +70,7 @@ function powerline-setup " _powerline_set_columns end + _powerline_bind_mode _powerline_update end if eval $POWERLINE_CONFIG shell --shell=fish uses tmux From 9be2a2e39b97758e56b0c11f363820b53c419537 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Sat, 24 May 2014 03:17:14 +0800 Subject: [PATCH 2/7] add _POWERLINE_DEFAULT_MODE detection --- powerline/bindings/fish/powerline-setup.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/powerline/bindings/fish/powerline-setup.fish b/powerline/bindings/fish/powerline-setup.fish index 0e9fde04..ca9ef636 100644 --- a/powerline/bindings/fish/powerline-setup.fish +++ b/powerline/bindings/fish/powerline-setup.fish @@ -35,6 +35,11 @@ function powerline-setup end function --on-variable fish_bind_mode _powerline_bind_mode set -g -x _POWERLINE_MODE $fish_bind_mode + if test x$fish_key_bindings != xfish_vi_key_bindings + set -g -x _POWERLINE_DEFAULT_MODE default + else + set -g -e _POWERLINE_DEFAULT_MODE + end end function --on-variable POWERLINE_COMMAND _powerline_update set -l addargs "--last_exit_code=\$status" From 09b78884de47230afb9d96b63fe1d648fed2ecec Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Aug 2014 15:37:56 +0400 Subject: [PATCH 3/7] Set default mode in another function --- powerline/bindings/fish/powerline-setup.fish | 3 +++ 1 file changed, 3 insertions(+) diff --git a/powerline/bindings/fish/powerline-setup.fish b/powerline/bindings/fish/powerline-setup.fish index ca9ef636..fad70f7b 100644 --- a/powerline/bindings/fish/powerline-setup.fish +++ b/powerline/bindings/fish/powerline-setup.fish @@ -35,6 +35,8 @@ function powerline-setup end function --on-variable fish_bind_mode _powerline_bind_mode set -g -x _POWERLINE_MODE $fish_bind_mode + end + function --on-variable fish_key_bindings _powerline_set_default_mode if test x$fish_key_bindings != xfish_vi_key_bindings set -g -x _POWERLINE_DEFAULT_MODE default else @@ -76,6 +78,7 @@ function powerline-setup _powerline_set_columns end _powerline_bind_mode + _powerline_set_default_mode _powerline_update end if eval $POWERLINE_CONFIG shell --shell=fish uses tmux From 68ecd81edd7ca48d29a79c694231e4a8eaf2d9af Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Aug 2014 16:58:35 +0400 Subject: [PATCH 4/7] Wait until fish_update_completions finishes --- tests/test_shells/input.fish | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_shells/input.fish b/tests/test_shells/input.fish index eda074e9..84685a77 100644 --- a/tests/test_shells/input.fish +++ b/tests/test_shells/input.fish @@ -1,4 +1,7 @@ set fish_function_path "$PWD/powerline/bindings/fish" $fish_function_path +while jobs | grep fish_update_completions + sleep 1 +end powerline-setup set POWERLINE_COMMAND "$POWERLINE_COMMAND -p $PWD/powerline/config_files" set POWERLINE_COMMAND "$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false" @@ -22,4 +25,3 @@ cd ../'$(echo)' cd ../'`echo`' false true is the last line -exit From 54672aace05fe15351c50b1ca807be60032aae40 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Aug 2014 16:59:03 +0400 Subject: [PATCH 5/7] Make COMMAND_PATTERN consistent with other arguments --- tests/test_shells/input.fish | 1 + tests/test_shells/test.sh | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/test_shells/input.fish b/tests/test_shells/input.fish index 84685a77..673b720c 100644 --- a/tests/test_shells/input.fish +++ b/tests/test_shells/input.fish @@ -25,3 +25,4 @@ cd ../'$(echo)' cd ../'`echo`' false true is the last line +exit diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index 9104fa99..052797e0 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -7,9 +7,9 @@ if test "x$1" = "x--fast" ; then fi ONLY_SHELL="$1" ONLY_TEST_TYPE="$2" -COMMAND_PATTERN="$3" +ONLY_TEST_CLIENT="$3" -if ! test -z "$ONLY_SHELL$ONLY_TEST_TYPE$COMMAND_PATTERN" ; then +if ! test -z "$ONLY_SHELL$ONLY_TEST_TYPE$ONLY_TEST_CLIENT" ; then FAST= fi @@ -18,11 +18,11 @@ export PYTHON if test "x$ONLY_SHELL" = "x--help" ; then cat << EOF Usage: - $0 [[[ONLY_SHELL | ""] (ONLY_TEST_TYPE | "")] (COMMAND_PATTERN | "")] + $0 [[[ONLY_SHELL | ""] (ONLY_TEST_TYPE | "")] (ONLY_TEST_CLIENT | "")] ONLY_SHELL: execute only tests for given shell ONLY_TEST_TYPE: execute only "daemon" or "nodaemon" tests -COMMAND_PATTERN: use only commands that match given pattern for testing +ONLY_TEST_CLIENT: use only given test client (one of C, python, render, shell) EOF exit 0 fi @@ -276,9 +276,7 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te if test "$TEST_CLIENT" = "shell" && ! which socat >/dev/null ; then continue fi - if test "x$COMMAND_PATTERN" != "x" && ! ( - echo "$POWERLINE_COMMAND" | grep -e"$COMMAND_PATTERN" &>/dev/null) - then + if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then continue fi POWERLINE_COMMAND="$POWERLINE_COMMAND --socket $ADDRESS" From 0af5e2d2cae52de83cf78f57782e8a0f253b7239 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Aug 2014 17:09:40 +0400 Subject: [PATCH 6/7] Test mode support in fish WARNING: Requires development version of fish. Since fish is not tested in travis it is probably OK. --- tests/test_shells/fish.ok | 19 +++++++++++++++++++ tests/test_shells/input.fish | 3 +++ tests/test_shells/postproc.py | 12 ++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/test_shells/fish.ok b/tests/test_shells/fish.ok index 94c4e3fc..8364f6a9 100644 --- a/tests/test_shells/fish.ok +++ b/tests/test_shells/fish.ok @@ -14,3 +14,22 @@   HOSTNAME  USER   BRANCH  ⋯  shell  3rd  (echo)     HOSTNAME  USER   BRANCH  ⋯  shell  3rd  $(echo)     HOSTNAME  USER   BRANCH  ⋯  shell  3rd  `echo`   + USER  ⋯  shell  3rd  `echo`   +   BRANCH  +   BRANCH  +   BRANCH  + INSERT  USER  ⋯  shell  3rd  `echo`   +   BRANCH  + DEFAULT  USER  ⋯  shell  3rd  `echo`   +   BRANCH  + INSERT  USER  ⋯  shell  3rd  `echo`   +   BRANCH  + DEFAULT  USER  ⋯  shell  3rd  `echo`   +   BRANCH  + INSERT  USER  ⋯  shell  3rd  `echo`   +   BRANCH  +   BRANCH  + INSERT  USER  ⋯  shell  3rd  `echo`   +   BRANCH  +   BRANCH  +   BRANCH  diff --git a/tests/test_shells/input.fish b/tests/test_shells/input.fish index 673b720c..9d819cfc 100644 --- a/tests/test_shells/input.fish +++ b/tests/test_shells/input.fish @@ -23,6 +23,9 @@ cd ../'#[bold]' cd ../'(echo)' cd ../'$(echo)' cd ../'`echo`' +set POWERLINE_COMMAND "$POWERLINE_COMMAND -c ext.shell.theme=default" +set -g fish_key_bindings fish_vi_key_bindings +ii false true is the last line exit diff --git a/tests/test_shells/postproc.py b/tests/test_shells/postproc.py index d86fe6fc..ddacb8b1 100755 --- a/tests/test_shells/postproc.py +++ b/tests/test_shells/postproc.py @@ -41,12 +41,16 @@ with codecs.open(fname, 'r', encoding='utf-8') as R: if pid is not None: line = line.replace(pid, 'PID') if shell == 'fish': + res = '' try: - start = line.index('\033[0;') - end = line.index('\033[0m', start) - line = line[start:end + 4] + '\n' + while line.index('\033[0;'): + start = line.index('\033[0;') + end = line.index('\033[0m', start) + res += line[start:end + 4] + '\n' + line = line[end + 4:] except ValueError: - line = '' + pass + line = res elif shell == 'tcsh': try: start = line.index('\033[0;') From 58057c95b92d700a1e346c611bd649c98a5e3730 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Aug 2014 17:13:00 +0400 Subject: [PATCH 7/7] Add a directory that will make fish_update_completions not launch --- tests/test_shells/test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index 052797e0..f4872ccf 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -174,6 +174,8 @@ mkdir tests/shell/3rd/'$(echo)' mkdir tests/shell/3rd/'`echo`' mkdir tests/shell/fish_home +mkdir tests/shell/fish_home/fish +mkdir tests/shell/fish_home/fish/generated_completions cp -r tests/test_shells/ipython_home tests/shell mkdir tests/shell/path