Merge pull request #696 from ZyX-I/fish
Add powerline/bindings/fish/powerline.fish
This commit is contained in:
commit
79c4d37814
|
@ -150,6 +150,16 @@ absolute path to your Powerline installation directory:
|
|||
|
||||
. {repository_root}/powerline/bindings/zsh/powerline.zsh
|
||||
|
||||
Fish prompt
|
||||
^^^^^^^^^^^
|
||||
|
||||
Add the following line to your :file:`config.fish`, where ``{repository_root}``
|
||||
is the absolute path to your Powerline installation directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
. {repository_root}/powerline/bindings/fish/powerline.fish
|
||||
|
||||
Tmux statusline
|
||||
---------------
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
function powerline
|
||||
if test -z "$POWERLINE_COMMAND"
|
||||
if which powerline-client >/dev/null
|
||||
set -g -x POWERLINE_COMMAND powerline-client
|
||||
else
|
||||
set -g -x POWERLINE_COMMAND powerline
|
||||
end
|
||||
end
|
||||
function --on-variable POWERLINE_COMMAND _powerline_update
|
||||
set -l addargs "--last_exit_code=\$status --last_pipe_status=\$status --jobnum=(jobs -p | wc -l)"
|
||||
eval "
|
||||
function fish_prompt
|
||||
$POWERLINE_COMMAND shell left $addargs
|
||||
end
|
||||
function fish_right_prompt
|
||||
$POWERLINE_COMMAND shell right $addargs
|
||||
end
|
||||
"
|
||||
end
|
||||
_powerline_update
|
||||
function _powerline_tmux_setenv
|
||||
if test -n "$TMUX"
|
||||
tmux setenv -g TMUX_$argv[1]_(tmux display -p "#D" | tr -d "%") "$argv[2]"
|
||||
tmux refresh -S
|
||||
end
|
||||
end
|
||||
function --on-variable PWD _powerline_tmux_set_pwd
|
||||
_powerline_tmux_setenv PWD "$PWD"
|
||||
end
|
||||
function --on-signal WINCH _powerline_tmux_set_columns
|
||||
_powerline_tmux_setenv COLUMNS "$COLUMNS"
|
||||
end
|
||||
_powerline_tmux_set_columns
|
||||
_powerline_tmux_set_pwd
|
||||
end
|
||||
powerline
|
|
@ -9,5 +9,7 @@ if python -c 'import sys; sys.exit(1 * (sys.version_info[0] != 2))' ; then
|
|||
pip install unittest2 argparse
|
||||
fi
|
||||
fi
|
||||
sudo apt-get install -qq zsh screen
|
||||
sudo apt-get install -qq screen zsh
|
||||
# Travis has too outdated fish. It cannot be used for tests.
|
||||
# sudo apt-get install fish
|
||||
true
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mtests [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m3rd [0;38;5;240;49;22m [0m
|
||||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240m3rd [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m.git [0;38;5;240;49;22m [0m
|
||||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mtests [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m3rd [0;38;5;240;49;22m [0m
|
||||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;74;22m [0;38;5;231;48;5;74mⓔ some-virtual-environment [0;38;5;74;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mtests [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m3rd [0;38;5;240;49;22m [0m
|
||||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mtests [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m3rd [0;38;5;240;49;22m [0m
|
||||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mtests [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m3rd [0;38;5;240;48;5;166;22m [0;38;5;220;48;5;166m1 [0;38;5;166;49;22m [0m
|
||||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mtests [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m3rd [0;38;5;240;48;5;166;22m [0;38;5;220;48;5;166m1 [0;38;5;166;48;5;52;22m [0;38;5;231;48;5;52m1 [0;38;5;52;49;22m [0m
|
||||
[0;38;5;220;48;5;166m HOSTNAME [0;38;5;166;48;5;31;22m [0;38;5;231;48;5;31;1mUSER [0;38;5;31;48;5;236;22m [0;38;5;250;48;5;236m BRANCH [0;38;5;236;48;5;240;22m [0;38;5;250;48;5;240m⋯ [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mtests [0;38;5;245;48;5;240;22m [0;38;5;250;48;5;240mshell [0;38;5;245;48;5;240;22m [0;38;5;252;48;5;240;1m3rd [0;38;5;240;49;22m [0m
|
|
@ -0,0 +1,15 @@
|
|||
set POWERLINE_COMMAND "$PWD/scripts/powerline -p $PWD/powerline/config_files"
|
||||
set POWERLINE_COMMAND "$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
|
||||
set POWERLINE_COMMAND "$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
|
||||
set VIRTUAL_ENV
|
||||
. powerline/bindings/fish/powerline.fish ; cd tests/shell/3rd
|
||||
cd .git
|
||||
cd ..
|
||||
set VIRTUAL_ENV "$HOME/.virtenvs/some-virtual-environment"
|
||||
set VIRTUAL_ENV
|
||||
bash -c "echo \$\$>pid ; while true ; do sleep 0.1s ; done" &
|
||||
false
|
||||
kill (cat pid) ; sleep 1s
|
||||
false
|
||||
true is the last line
|
||||
exit
|
|
@ -12,6 +12,8 @@ fname = sys.argv[1]
|
|||
new_fname = fname + '.new'
|
||||
pid_fname = 'tests/shell/3rd/pid'
|
||||
|
||||
shell = sys.argv[2]
|
||||
|
||||
with open(pid_fname, 'r') as P:
|
||||
pid = P.read().strip()
|
||||
hostname = socket.gethostname()
|
||||
|
@ -20,7 +22,7 @@ user = os.environ['USER']
|
|||
with codecs.open(fname, 'r', encoding='utf-8') as R:
|
||||
with codecs.open(new_fname, 'w', encoding='utf-8') as W:
|
||||
found_cd = False
|
||||
for line in R:
|
||||
for line in (R if shell != 'fish' else R.read().split('\n')):
|
||||
if not found_cd:
|
||||
found_cd = ('cd tests/shell/3rd' in line)
|
||||
continue
|
||||
|
@ -32,6 +34,13 @@ with codecs.open(fname, 'r', encoding='utf-8') as R:
|
|||
line = line.replace(hostname, 'HOSTNAME')
|
||||
line = line.replace(user, 'USER')
|
||||
line = line.replace(pid, 'PID')
|
||||
if shell == 'fish':
|
||||
try:
|
||||
start = line.index('\033[0;')
|
||||
end = line.index('\033[0m', start)
|
||||
line = line[start : end+4] + '\n'
|
||||
except ValueError:
|
||||
line = ''
|
||||
W.write(line)
|
||||
|
||||
os.rename(new_fname, fname)
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
#!/bin/sh
|
||||
FAILED=0
|
||||
|
||||
if [ "$(echo '\e')" != '\e' ] ; then
|
||||
safe_echo() {
|
||||
echo -E "$@"
|
||||
}
|
||||
else
|
||||
safe_echo() {
|
||||
echo "$@"
|
||||
}
|
||||
fi
|
||||
ONLY_SHELL="$1"
|
||||
|
||||
check_screen_log() {
|
||||
diff -u tests/test_shells/${1}.ok tests/shell/screen.log
|
||||
# Explicit is better then implicit
|
||||
return $?
|
||||
if test -e tests/test_shells/${1}.ok ; then
|
||||
diff -u tests/test_shells/${1}.ok tests/shell/screen.log
|
||||
return $?
|
||||
else
|
||||
cat tests/shell/screen.log
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_test() {
|
||||
SH="$1"
|
||||
SESNAME="powerline-shell-test-$$"
|
||||
SESNAME="powerline-shell-test-${SH}-$$"
|
||||
|
||||
test "x$ONLY_SHELL" = "x" || test "x$ONLY_SHELL" = "x$SH" || return 0
|
||||
|
||||
which "${SH}" || return 0
|
||||
|
||||
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
|
||||
# Wait for screen to initialize
|
||||
sleep 0.3s
|
||||
sleep 1s
|
||||
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
|
||||
|
@ -33,32 +33,50 @@ run_test() {
|
|||
while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do
|
||||
sleep 0.1s
|
||||
done
|
||||
./tests/test_shells/postproc.py tests/shell/screen.log
|
||||
cp tests/shell/screen.log tests/shell/${SH}.full.log
|
||||
./tests/test_shells/postproc.py tests/shell/screen.log ${SH}
|
||||
cp tests/shell/screen.log tests/shell/${SH}.log
|
||||
if ! check_screen_log ${SH} ; then
|
||||
echo '____________________________________________________________'
|
||||
# Repeat the diff to make it better viewable in travis output
|
||||
echo "Diff (cat -v):"
|
||||
echo '============================================================'
|
||||
check_screen_log ${SH} | cat -v
|
||||
echo '____________________________________________________________'
|
||||
echo "Failed ${SH}. Full output:"
|
||||
echo '============================================================'
|
||||
cat tests/shell/${SH}.full.log
|
||||
echo '____________________________________________________________'
|
||||
echo "Full output (cat -v):"
|
||||
echo '============================================================'
|
||||
cat -v tests/shell/${SH}.full.log
|
||||
echo '____________________________________________________________'
|
||||
${SH} --version
|
||||
rm tests/shell/screen.log
|
||||
return 1
|
||||
fi
|
||||
rm tests/shell/screen.log
|
||||
return 0
|
||||
}
|
||||
|
||||
test -d tests/shell && rm -r tests/shell
|
||||
mkdir tests/shell
|
||||
git init tests/shell/3rd
|
||||
git --git-dir=tests/shell/3rd/.git checkout -b BRANCH
|
||||
|
||||
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
|
||||
mkdir tests/shell/fish_home
|
||||
export XDG_CONFIG_HOME="$PWD/tests/shell/fish_home"
|
||||
if ! run_test fish -i ; then
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
test "x$ONLY_SHELL" = "x" && rm -r tests/shell
|
||||
exit $FAILED
|
||||
|
|
Loading…
Reference in New Issue