Reformat with `fish_indent`

pull/189/head
Justin Hileman 5 years ago
parent 0688cd8e98
commit a2b56a33fb

@ -5,4 +5,5 @@
#
# set -g theme_display_vi no
function fish_mode_prompt; end
function fish_mode_prompt
end

@ -57,7 +57,8 @@ function __bobthefish_dirname -d 'basically dirname, but faster'
end
function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)'
set -l ref (command git symbolic-ref HEAD 2>/dev/null); and begin
set -l ref (command git symbolic-ref HEAD 2>/dev/null)
and begin
[ "$theme_display_git_master_branch" != 'yes' -a "$ref" = 'refs/heads/master' ]
and echo $branch_glyph
and return
@ -114,7 +115,8 @@ function __bobthefish_ignore_vcs_dir -d 'Check whether the current directory sho
end
function __bobthefish_git_project_dir -S -d 'Print the current git project base directory'
[ "$theme_display_git" = 'no' ]; and return
[ "$theme_display_git" = 'no' ]
and return
set -q theme_vcs_ignore_paths
and [ (__bobthefish_ignore_vcs_dir) ]
@ -125,7 +127,8 @@ function __bobthefish_git_project_dir -S -d 'Print the current git project base
return
end
set -l git_dir (command git rev-parse --git-dir 2>/dev/null); or return
set -l git_dir (command git rev-parse --git-dir 2>/dev/null)
or return
pushd $git_dir
set git_dir $PWD
@ -163,7 +166,8 @@ function __bobthefish_git_project_dir -S -d 'Print the current git project base
end
function __bobthefish_hg_project_dir -S -d 'Print the current hg project base directory'
[ "$theme_display_hg" = 'yes' ]; or return
[ "$theme_display_hg" = 'yes' ]
or return
set -q theme_vcs_ignore_paths
and [ (__bobthefish_ignore_vcs_dir) ]
@ -175,7 +179,10 @@ function __bobthefish_hg_project_dir -S -d 'Print the current hg project base di
command hg root --cwd "$d" 2>/dev/null
return
end
[ "$d" = '/' ]; and return
[ "$d" = '/' ]
and return
set d (__bobthefish_dirname $d)
end
end
@ -396,11 +403,15 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no
end
function __bobthefish_prompt_vi -S -d 'Display vi mode'
[ "$theme_display_vi" != 'no' ]; or return
[ "$theme_display_vi" != 'no' ]
or return
[ "$fish_key_bindings" = 'fish_vi_key_bindings' \
-o "$fish_key_bindings" = 'hybrid_bindings' \
-o "$fish_key_bindings" = 'fish_hybrid_key_bindings' \
-o "$theme_display_vi" = 'yes' ]; or return
-o "$theme_display_vi" = 'yes' ]
or return
switch $fish_bind_mode
case default
__bobthefish_start_segment $color_vi_mode_default
@ -423,7 +434,8 @@ end
# ==============================
function __bobthefish_prompt_vagrant -S -d 'Display Vagrant status'
[ "$theme_display_vagrant" = 'yes' -a -f Vagrantfile ]; or return
[ "$theme_display_vagrant" = 'yes' -a -f Vagrantfile ]
or return
# .vagrant/machines/$machine/$provider/id
for file in .vagrant/machines/*/*/id
@ -445,6 +457,7 @@ end
function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagrant status'
set -l vagrant_status
set -l vm_status (VBoxManage showvminfo --machinereadable $id 2>/dev/null | command grep 'VMState=' | tr -d '"' | cut -d '=' -f 2)
switch "$vm_status"
case 'running'
set vagrant_status "$vagrant_status$vagrant_running_glyph"
@ -459,7 +472,9 @@ function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagran
case ''
set vagrant_status "$vagrant_status$vagrant_unknown_glyph"
end
[ -z "$vagrant_status" ]; and return
[ -z "$vagrant_status" ]
and return
__bobthefish_start_segment $color_vagrant
echo -ns $vagrant_status ' '
@ -472,7 +487,9 @@ function __bobthefish_prompt_vagrant_vmware -S -a id -d 'Display VMWare Vagrant
else
set vagrant_status "$vagrant_status$vagrant_poweroff_glyph"
end
[ -z "$vagrant_status" ]; and return
[ -z "$vagrant_status" ]
and return
__bobthefish_start_segment $color_vagrant
echo -ns $vagrant_status ' '
@ -481,6 +498,7 @@ end
function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant status'
set -l vagrant_status
set -l vm_status (prlctl list $id -o status 2>/dev/null | command tail -1)
switch "$vm_status"
case 'running'
set vagrant_status "$vagrant_status$vagrant_running_glyph"
@ -495,38 +513,45 @@ function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant
case ''
set vagrant_status "$vagrant_status$vagrant_unknown_glyph"
end
[ -z "$vagrant_status" ]; and return
[ -z "$vagrant_status" ]
and return
__bobthefish_start_segment $color_vagrant
echo -ns $vagrant_status ' '
end
function __bobthefish_prompt_docker -S -d 'Display Docker machine name'
[ "$theme_display_docker_machine" = 'no' -o -z "$DOCKER_MACHINE_NAME" ]; and return
[ "$theme_display_docker_machine" = 'no' -o -z "$DOCKER_MACHINE_NAME" ]
and return
__bobthefish_start_segment $color_vagrant
echo -ns $DOCKER_MACHINE_NAME ' '
end
function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context'
[ "$theme_display_k8s_context" = 'yes' ]; or return
[ "$theme_display_k8s_context" = 'yes' ]
or return
set -l config_paths "$HOME/.kube/config"
[ -n "$KUBECONFIG" ]
and set config_paths (string split ':' "$KUBECONFIG") $config_paths
for file in $config_paths
[ -f "$file" ]; or continue
[ -f "$file" ]
or continue
while read -l key val
if [ "$key" = 'current-context:' ]
set -l context (string trim -c '"\' ' -- $val)
[ -z "$context" ]; and return
[ -z "$context" ]
and return
__bobthefish_start_segment $color_k8s
echo -ns $context ' '
return
end
end < $file
end <$file
end
end
@ -549,6 +574,7 @@ end
function __bobthefish_prompt_user -S -d 'Display current user and hostname'
[ "$theme_display_user" = 'yes' -o \( "$theme_display_user" != 'no' -a -n "$SSH_CLIENT" \) -o \( -n "$default_user" -a "$USER" != "$default_user" \) ]
and set -l display_user
[ "$theme_display_hostname" = 'yes' -o \( "$theme_display_hostname" != 'no' -a -n "$SSH_CLIENT" \) ]
and set -l display_hostname
@ -600,7 +626,9 @@ function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM'
# More `sed`/`grep`/`cut` magic...
set -l __rvm_default_ruby (grep GEM_HOME $rvm_path/environments/default 2>/dev/null | sed -e"s/'//g" | sed -e's/.*\///')
set -l __rvm_current_ruby (rvm-prompt i v g)
[ "$__rvm_default_ruby" = "$__rvm_current_ruby" ]; and return
[ "$__rvm_default_ruby" = "$__rvm_current_ruby" ]
and return
set -l __rvm_default_ruby_gemset
set -l __rvm_default_ruby_interpreter
@ -635,7 +663,8 @@ function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM'
end
function __bobthefish_prompt_rubies -S -d 'Display current Ruby information'
[ "$theme_display_ruby" = 'no' ]; and return
[ "$theme_display_ruby" = 'no' ]
and return
set -l ruby_version
if type -fq rvm-prompt
@ -652,7 +681,8 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information'
[ "$global_ruby_version" ]
or set -l global_ruby_version system
[ "$ruby_version" = "$global_ruby_version" ]; and return
[ "$ruby_version" = "$global_ruby_version" ]
and return
else if type -q chruby # chruby is implemented as a function, so omitting the -f is intentional
set ruby_version $RUBY_VERSION
else if type -fq asdf
@ -660,11 +690,15 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information'
or return
# If asdf changes their ruby version provenance format, update this to match
[ "$asdf_provenance" = "(set by $HOME/.tool-versions)" ]; and return
[ "$asdf_provenance" = "(set by $HOME/.tool-versions)" ]
and return
set ruby_version $asdf_ruby_version
end
[ -z "$ruby_version" ]; and return
[ -z "$ruby_version" ]
and return
__bobthefish_start_segment $color_rvm
echo -ns $ruby_glyph $ruby_version ' '
end
@ -683,12 +717,16 @@ function __bobthefish_virtualenv_python_version -S -d 'Get current Python versio
end
function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself) or conda environment."
[ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" -a -z "$CONDA_DEFAULT_ENV" ]; and return
[ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" -a -z "$CONDA_DEFAULT_ENV" ]
and return
set -l version_glyph (__bobthefish_virtualenv_python_version)
if [ "$version_glyph" ]
__bobthefish_start_segment $color_virtualfish
echo -ns $virtualenv_glyph $version_glyph ' '
end
if [ "$VIRTUAL_ENV" ]
echo -ns (basename "$VIRTUAL_ENV") ' '
else if [ "$CONDA_DEFAULT_ENV" ]
@ -697,14 +735,18 @@ function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual e
end
function __bobthefish_prompt_virtualgo -S -d 'Display current Go virtual environment'
[ "$theme_display_virtualgo" = 'no' -o -z "$VIRTUALGO" ]; and return
[ "$theme_display_virtualgo" = 'no' -o -z "$VIRTUALGO" ]
and return
__bobthefish_start_segment $color_virtualgo
echo -ns $go_glyph ' ' (basename "$VIRTUALGO") ' '
set_color normal
end
function __bobthefish_prompt_desk -S -d 'Display current desk environment'
[ "$theme_display_desk" = 'no' -o -z "$DESK_ENV" ]; and return
[ "$theme_display_desk" = 'no' -o -z "$DESK_ENV" ]
and return
__bobthefish_start_segment $color_desk
echo -ns $desk_glyph ' ' (basename -a -s ".fish" "$DESK_ENV") ' '
set_color normal
@ -776,6 +818,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
end
set -l flags "$dirty$staged$stashed$ahead$new"
[ "$flags" ]
and set flags " $flags"
@ -834,9 +877,11 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
if [ "$work_parent" ]
echo -n "$work_parent/"
end
set_color normal
set_color -b $color_repo_work_tree
echo -n (__bobthefish_basename $work_dir)
set_color normal
set_color -b $colors
[ "$project_pwd" ]
@ -846,8 +891,10 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
echo -ns $project_pwd ' '
else
set project_pwd $PWD
string match "$current_dir*" $project_pwd >/dev/null
and set project_pwd (string sub -s (math 1 + (string length $current_dir)) $project_pwd)
set project_pwd (string trim --left --chars=/ -- $project_pwd)
if [ "$project_pwd" ]
@ -878,6 +925,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_glyphs
__bobthefish_colors $theme_color_scheme
type -q bobthefish_colors
and bobthefish_colors

@ -2,8 +2,11 @@
# set -g theme_date_format "+%a %H:%M"
function __bobthefish_cmd_duration -S -d 'Show command duration'
[ "$theme_display_cmd_duration" = "no" ]; and return
[ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]; and return
[ "$theme_display_cmd_duration" = "no" ]
and return
[ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]
and return
if [ "$CMD_DURATION" -lt 5000 ]
echo -ns $CMD_DURATION 'ms'
@ -48,7 +51,9 @@ function __bobthefish_pretty_ms -S -a ms interval -d 'Millisecond formatting for
end
function __bobthefish_timestamp -S -d 'Show the current timestamp'
[ "$theme_display_date" = "no" ]; and return
[ "$theme_display_date" = "no" ]
and return
set -q theme_date_format
or set -l theme_date_format "+%c"

Loading…
Cancel
Save