Merge pull request #1012 from ZyX-I/fish-vi-mode

Add fish vi mode support

Closes #879
Fixes #878
This commit is contained in:
Nikolai Aleksandrovich Pavlov 2014-08-24 17:22:14 +04:00
commit cd9811806c
5 changed files with 52 additions and 11 deletions

View File

@ -33,6 +33,16 @@ 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 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
set -g -e _POWERLINE_DEFAULT_MODE
end
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 +77,8 @@ 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

View File

@ -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 

View File

@ -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"
@ -20,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

View File

@ -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;')

View File

@ -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
@ -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
@ -276,9 +278,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"