[bobthefish] Use brackets instead of test.

pull/2/head
Justin Hileman 10 years ago committed by Bruno Pinto
parent 08f8217cbe
commit 1c38607b13

@ -139,7 +139,7 @@ function __bobthefish_start_segment -d 'Start a prompt segment'
end end
function __bobthefish_path_segment -d 'Display a shortened form of a directory' function __bobthefish_path_segment -d 'Display a shortened form of a directory'
if test -w "$argv[1]" if [ -w "$argv[1]" ]
__bobthefish_start_segment $__bobthefish_dk_grey $__bobthefish_med_grey __bobthefish_start_segment $__bobthefish_dk_grey $__bobthefish_med_grey
else else
__bobthefish_start_segment $__bobthefish_dk_red $__bobthefish_lt_red __bobthefish_start_segment $__bobthefish_dk_red $__bobthefish_lt_red
@ -159,7 +159,7 @@ function __bobthefish_path_segment -d 'Display a shortened form of a directory'
set directory (basename "$argv[1]") set directory (basename "$argv[1]")
end end
test "$parent"; and echo -n -s "$parent" [ "$parent" ]; and echo -n -s "$parent"
set_color fff --bold set_color fff --bold
echo -n "$directory " echo -n "$directory "
set_color normal set_color normal
@ -203,7 +203,7 @@ function __bobthefish_prompt_status -d 'Display symbols for a non zero exit stat
set -l status_flags "$nonzero$superuser$bg_jobs" set -l status_flags "$nonzero$superuser$bg_jobs"
if test "$nonzero" -o "$superuser" -o "$bg_jobs" if [ "$nonzero" -o "$superuser" -o "$bg_jobs" ]
__bobthefish_start_segment fff 000 __bobthefish_start_segment fff 000
if [ "$nonzero" ] if [ "$nonzero" ]
set_color $__bobthefish_med_red --bold set_color $__bobthefish_med_red --bold
@ -237,11 +237,11 @@ function __bobthefish_prompt_hg -d 'Display the actual hg state'
set -l dirty (command hg stat; or echo -n '*') set -l dirty (command hg stat; or echo -n '*')
set -l flags "$dirty" set -l flags "$dirty"
test "$flags"; and set flags "" [ "$flags" ]; and set flags ""
set -l flag_bg $__bobthefish_lt_green set -l flag_bg $__bobthefish_lt_green
set -l flag_fg $__bobthefish_dk_green set -l flag_fg $__bobthefish_dk_green
if test "$dirty" if [ "$dirty" ]
set flag_bg $__bobthefish_med_red set flag_bg $__bobthefish_med_red
set flag_fg fff set flag_fg fff
end end
@ -256,8 +256,8 @@ function __bobthefish_prompt_hg -d 'Display the actual hg state'
set_color normal set_color normal
set -l project_pwd (__bobthefish_project_pwd $argv[1]) set -l project_pwd (__bobthefish_project_pwd $argv[1])
if test "$project_pwd" if [ "$project_pwd" ]
if test -w "$PWD" if [ -w "$PWD" ]
__bobthefish_start_segment 333 999 __bobthefish_start_segment 333 999
else else
__bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red __bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red
@ -274,21 +274,19 @@ function __bobthefish_prompt_git -d 'Display the actual git state'
set -l ahead (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null | awk '/>/ {a += 1} /</ {b += 1} {if (a > 0) nextfile} END {if (a > 0 && b > 0) print "±"; else if (a > 0) print "+"; else if (b > 0) print "-"}') set -l ahead (command git rev-list --left-right '@{upstream}...HEAD' ^/dev/null | awk '/>/ {a += 1} /</ {b += 1} {if (a > 0) nextfile} END {if (a > 0 && b > 0) print "±"; else if (a > 0) print "+"; else if (b > 0) print "-"}')
set -l new (command git ls-files --other --exclude-standard); set -l new (command git ls-files --other --exclude-standard);
test "$new"; and set new '…' [ "$new" ]; and set new '…'
set -l flags "$dirty$staged$stashed$ahead$new" set -l flags "$dirty$staged$stashed$ahead$new"
test "$flags"; and set flags " $flags" [ "$flags" ]; and set flags " $flags"
set -l flag_bg $__bobthefish_lt_green set -l flag_bg $__bobthefish_lt_green
set -l flag_fg $__bobthefish_dk_green set -l flag_fg $__bobthefish_dk_green
if test "$dirty" -o "$staged" if [ "$dirty" -o "$staged" ]
set flag_bg $__bobthefish_med_red set flag_bg $__bobthefish_med_red
set flag_fg fff set flag_fg fff
else else if [ "$stashed" ]
if test "$stashed" set flag_bg $__bobthefish_lt_orange
set flag_bg $__bobthefish_lt_orange set flag_fg $__bobthefish_dk_orange
set flag_fg $__bobthefish_dk_orange
end
end end
__bobthefish_path_segment $argv[1] __bobthefish_path_segment $argv[1]
@ -298,8 +296,8 @@ function __bobthefish_prompt_git -d 'Display the actual git state'
set_color normal set_color normal
set -l project_pwd (__bobthefish_project_pwd $argv[1]) set -l project_pwd (__bobthefish_project_pwd $argv[1])
if test "$project_pwd" if [ "$project_pwd" ]
if test -w "$PWD" if [ -w "$PWD" ]
__bobthefish_start_segment 333 999 __bobthefish_start_segment 333 999
else else
__bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red __bobthefish_start_segment $__bobthefish_med_red $__bobthefish_lt_red
@ -328,7 +326,7 @@ end
function __bobthefish_prompt_virtualfish -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)" function __bobthefish_prompt_virtualfish -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)"
set -q VIRTUAL_ENV; or return set -q VIRTUAL_ENV; or return
set -l version_glyph (__bobthefish_virtualenv_python_version) set -l version_glyph (__bobthefish_virtualenv_python_version)
if test "$version_glyph" if [ "$version_glyph" ]
__bobthefish_start_segment $__bobthefish_med_blue $__bobthefish_lt_grey __bobthefish_start_segment $__bobthefish_med_blue $__bobthefish_lt_grey
echo -n -s $__bobthefish_virtualenv_glyph $version_glyph echo -n -s $__bobthefish_virtualenv_glyph $version_glyph
end end
@ -346,7 +344,7 @@ function __bobthefish_prompt_rubies -d 'Display current Ruby (rvm/rbenv)'
# Don't show global ruby version... # Don't show global ruby version...
[ "$ruby_version" = (rbenv global) ]; and return [ "$ruby_version" = (rbenv global) ]; and return
end end
test -w "$ruby_version"; and return [ -w "$ruby_version" ]; and return
__bobthefish_start_segment $__bobthefish_ruby_red $__bobthefish_lt_grey --bold __bobthefish_start_segment $__bobthefish_ruby_red $__bobthefish_lt_grey --bold
echo -n -s $ruby_version ' ' echo -n -s $ruby_version ' '
@ -366,9 +364,9 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
set -l git_root (__bobthefish_git_project_dir) set -l git_root (__bobthefish_git_project_dir)
set -l hg_root (__bobthefish_hg_project_dir) set -l hg_root (__bobthefish_hg_project_dir)
if test (echo "$hg_root" | wc -c) -gt (echo "$git_root" | wc -c) if [ (echo "$hg_root" | wc -c) -gt (echo "$git_root" | wc -c) ]
__bobthefish_prompt_hg $hg_root __bobthefish_prompt_hg $hg_root
else if test "$git_root" else if [ "$git_root" ]
__bobthefish_prompt_git $git_root __bobthefish_prompt_git $git_root
else else
__bobthefish_prompt_dir __bobthefish_prompt_dir

Loading…
Cancel
Save