Update fish update cmd and misc syntax fixes #fishshell

This commit is contained in:
Colin Powell
2019-01-13 23:30:27 -05:00
parent 39dad89597
commit 759c476f35
7 changed files with 770 additions and 689 deletions

View File

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

View File

@ -57,7 +57,8 @@ function __bobthefish_dirname -d 'basically dirname, but faster'
end end
function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' 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' ] [ "$theme_display_git_master_branch" != 'yes' -a "$ref" = 'refs/heads/master' ]
and echo $branch_glyph and echo $branch_glyph
and return and return
@ -80,13 +81,13 @@ function __bobthefish_hg_branch -S -d 'Get the current hg branch'
echo "$branch_glyph $branch @ $book" echo "$branch_glyph $branch @ $book"
end end
function __bobthefish_pretty_parent -S -a current_dir -d 'Print a parent directory, shortened to fit the prompt' function __bobthefish_pretty_parent -S -a child_dir -d 'Print a parent directory, shortened to fit the prompt'
set -q fish_prompt_pwd_dir_length set -q fish_prompt_pwd_dir_length
or set -l fish_prompt_pwd_dir_length 1 or set -l fish_prompt_pwd_dir_length 1
# Replace $HOME with ~ # Replace $HOME with ~
set -l real_home ~ set -l real_home ~
set -l parent_dir (string replace -r '^'"$real_home"'($|/)' '~$1' (__bobthefish_dirname $current_dir)) set -l parent_dir (string replace -r '^'"$real_home"'($|/)' '~$1' (__bobthefish_dirname $child_dir))
# Must check whether `$parent_dir = /` if using native dirname # Must check whether `$parent_dir = /` if using native dirname
if [ -z "$parent_dir" ] if [ -z "$parent_dir" ]
@ -103,9 +104,10 @@ function __bobthefish_pretty_parent -S -a current_dir -d 'Print a parent directo
end end
function __bobthefish_ignore_vcs_dir -d 'Check whether the current directory should be ignored as a VCS segment' function __bobthefish_ignore_vcs_dir -d 'Check whether the current directory should be ignored as a VCS segment'
set -l real_pwd (realpath $PWD)
for p in $theme_vcs_ignore_paths for p in $theme_vcs_ignore_paths
set ignore_path (realpath $p 2>/dev/null) set ignore_path (realpath $p 2>/dev/null)
switch $PWD/ switch $real_pwd/
case $ignore_path/\* case $ignore_path/\*
echo 1 echo 1
return return
@ -114,18 +116,44 @@ function __bobthefish_ignore_vcs_dir -d 'Check whether the current directory sho
end end
function __bobthefish_git_project_dir -S -d 'Print the current git project base directory' 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 set -q theme_vcs_ignore_paths
and [ (__bobthefish_ignore_vcs_dir) ] and [ (__bobthefish_ignore_vcs_dir) ]
and return and return
if [ "$theme_git_worktree_support" != 'yes' ] if [ "$theme_git_worktree_support" != 'yes' ]
command git rev-parse --show-toplevel 2>/dev/null set -l git_toplevel (command git rev-parse --show-toplevel 2>/dev/null)
[ -z "$git_toplevel" ]
and return
# If there are no symlinks, just use git toplevel
switch $PWD/
case $git_toplevel/\*
echo $git_toplevel
return return
end end
set -l git_dir (command git rev-parse --git-dir 2>/dev/null); or return # Otherwise, we need to find the equivalent directory in the $PWD
set -l d $PWD
while not [ -z "$d" ]
if [ (realpath "$d") = "$git_toplevel" ]
echo $d
return
end
[ "$d" = '/' ]
and return
set d (__bobthefish_dirname $d)
end
return
end
set -l git_dir (command git rev-parse --git-dir 2>/dev/null)
or return
pushd $git_dir pushd $git_dir
set git_dir $PWD set git_dir $PWD
@ -163,7 +191,8 @@ function __bobthefish_git_project_dir -S -d 'Print the current git project base
end end
function __bobthefish_hg_project_dir -S -d 'Print the current hg project base directory' 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 set -q theme_vcs_ignore_paths
and [ (__bobthefish_ignore_vcs_dir) ] and [ (__bobthefish_ignore_vcs_dir) ]
@ -175,16 +204,19 @@ function __bobthefish_hg_project_dir -S -d 'Print the current hg project base di
command hg root --cwd "$d" 2>/dev/null command hg root --cwd "$d" 2>/dev/null
return return
end end
[ "$d" = '/' ]; and return
[ "$d" = '/' ]
and return
set d (__bobthefish_dirname $d) set d (__bobthefish_dirname $d)
end end
end end
function __bobthefish_project_pwd -S -a current_dir -d 'Print the working directory relative to project root' function __bobthefish_project_pwd -S -a project_root_dir -d 'Print the working directory relative to project root'
set -q theme_project_dir_length set -q theme_project_dir_length
or set -l theme_project_dir_length 0 or set -l theme_project_dir_length 0
set -l project_dir (string replace -r '^'"$current_dir"'($|/)' '' $PWD) set -l project_dir (string replace -r '^'"$project_root_dir"'($|/)' '' $PWD)
if [ $theme_project_dir_length -eq 0 ] if [ $theme_project_dir_length -eq 0 ]
echo -n $project_dir echo -n $project_dir
@ -284,11 +316,11 @@ function __bobthefish_start_segment -S -d 'Start a prompt segment'
set __bobthefish_current_bg $bg set __bobthefish_current_bg $bg
end end
function __bobthefish_path_segment -S -a current_dir -d 'Display a shortened form of a directory' function __bobthefish_path_segment -S -a segment_dir -d 'Display a shortened form of a directory'
set -l segment_color $color_path set -l segment_color $color_path
set -l segment_basename_color $color_path_basename set -l segment_basename_color $color_path_basename
if not [ -w "$current_dir" ] if not [ -w "$segment_dir" ]
set segment_color $color_path_nowrite set segment_color $color_path_nowrite
set segment_basename_color $color_path_nowrite_basename set segment_basename_color $color_path_nowrite_basename
end end
@ -298,14 +330,14 @@ function __bobthefish_path_segment -S -a current_dir -d 'Display a shortened for
set -l directory set -l directory
set -l parent set -l parent
switch "$current_dir" switch "$segment_dir"
case / case /
set directory '/' set directory '/'
case "$HOME" case "$HOME"
set directory '~' set directory '~'
case '*' case '*'
set parent (__bobthefish_pretty_parent "$current_dir") set parent (__bobthefish_pretty_parent "$segment_dir")
set directory (__bobthefish_basename "$current_dir") set directory (__bobthefish_basename "$segment_dir")
end end
echo -n $parent echo -n $parent
@ -396,11 +428,15 @@ function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a no
end end
function __bobthefish_prompt_vi -S -d 'Display vi mode' 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' \ [ "$fish_key_bindings" = 'fish_vi_key_bindings' \
-o "$fish_key_bindings" = 'hybrid_bindings' \ -o "$fish_key_bindings" = 'hybrid_bindings' \
-o "$fish_key_bindings" = 'fish_hybrid_key_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 switch $fish_bind_mode
case default case default
__bobthefish_start_segment $color_vi_mode_default __bobthefish_start_segment $color_vi_mode_default
@ -423,7 +459,8 @@ end
# ============================== # ==============================
function __bobthefish_prompt_vagrant -S -d 'Display Vagrant status' 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 # .vagrant/machines/$machine/$provider/id
for file in .vagrant/machines/*/*/id for file in .vagrant/machines/*/*/id
@ -445,6 +482,7 @@ end
function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagrant status' function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagrant status'
set -l 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) set -l vm_status (VBoxManage showvminfo --machinereadable $id 2>/dev/null | command grep 'VMState=' | tr -d '"' | cut -d '=' -f 2)
switch "$vm_status" switch "$vm_status"
case 'running' case 'running'
set vagrant_status "$vagrant_status$vagrant_running_glyph" set vagrant_status "$vagrant_status$vagrant_running_glyph"
@ -459,7 +497,9 @@ function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagran
case '' case ''
set vagrant_status "$vagrant_status$vagrant_unknown_glyph" set vagrant_status "$vagrant_status$vagrant_unknown_glyph"
end end
[ -z "$vagrant_status" ]; and return
[ -z "$vagrant_status" ]
and return
__bobthefish_start_segment $color_vagrant __bobthefish_start_segment $color_vagrant
echo -ns $vagrant_status ' ' echo -ns $vagrant_status ' '
@ -472,7 +512,9 @@ function __bobthefish_prompt_vagrant_vmware -S -a id -d 'Display VMWare Vagrant
else else
set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" set vagrant_status "$vagrant_status$vagrant_poweroff_glyph"
end end
[ -z "$vagrant_status" ]; and return
[ -z "$vagrant_status" ]
and return
__bobthefish_start_segment $color_vagrant __bobthefish_start_segment $color_vagrant
echo -ns $vagrant_status ' ' echo -ns $vagrant_status ' '
@ -481,6 +523,7 @@ end
function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant status' function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant status'
set -l vagrant_status set -l vagrant_status
set -l vm_status (prlctl list $id -o status 2>/dev/null | command tail -1) set -l vm_status (prlctl list $id -o status 2>/dev/null | command tail -1)
switch "$vm_status" switch "$vm_status"
case 'running' case 'running'
set vagrant_status "$vagrant_status$vagrant_running_glyph" set vagrant_status "$vagrant_status$vagrant_running_glyph"
@ -495,32 +538,39 @@ function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant
case '' case ''
set vagrant_status "$vagrant_status$vagrant_unknown_glyph" set vagrant_status "$vagrant_status$vagrant_unknown_glyph"
end end
[ -z "$vagrant_status" ]; and return
[ -z "$vagrant_status" ]
and return
__bobthefish_start_segment $color_vagrant __bobthefish_start_segment $color_vagrant
echo -ns $vagrant_status ' ' echo -ns $vagrant_status ' '
end end
function __bobthefish_prompt_docker -S -d 'Display Docker machine name' 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 __bobthefish_start_segment $color_vagrant
echo -ns $DOCKER_MACHINE_NAME ' ' echo -ns $DOCKER_MACHINE_NAME ' '
end end
function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' 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" set -l config_paths "$HOME/.kube/config"
[ -n "$KUBECONFIG" ] [ -n "$KUBECONFIG" ]
and set config_paths (string split ':' "$KUBECONFIG") $config_paths and set config_paths (string split ':' "$KUBECONFIG") $config_paths
for file in $config_paths for file in $config_paths
[ -f "$file" ]; or continue [ -f "$file" ]
or continue
while read -l key val while read -l key val
if [ "$key" = 'current-context:' ] if [ "$key" = 'current-context:' ]
set -l context (string trim -c '"\' ' -- $val) set -l context (string trim -c '"\' ' -- $val)
[ -z "$context" ]; and return [ -z "$context" ]
and return
__bobthefish_start_segment $color_k8s __bobthefish_start_segment $color_k8s
echo -ns $context ' ' echo -ns $context ' '
@ -549,6 +599,7 @@ end
function __bobthefish_prompt_user -S -d 'Display current user and hostname' 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" \) ] [ "$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 and set -l display_user
[ "$theme_display_hostname" = 'yes' -o \( "$theme_display_hostname" != 'no' -a -n "$SSH_CLIENT" \) ] [ "$theme_display_hostname" = 'yes' -o \( "$theme_display_hostname" != 'no' -a -n "$SSH_CLIENT" \) ]
and set -l display_hostname and set -l display_hostname
@ -600,7 +651,9 @@ function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM'
# More `sed`/`grep`/`cut` magic... # 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_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) 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_gemset
set -l __rvm_default_ruby_interpreter set -l __rvm_default_ruby_interpreter
@ -635,7 +688,8 @@ function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM'
end end
function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' 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 set -l ruby_version
if type -fq rvm-prompt if type -fq rvm-prompt
@ -652,7 +706,8 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information'
[ "$global_ruby_version" ] [ "$global_ruby_version" ]
or set -l global_ruby_version system 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 else if type -q chruby # chruby is implemented as a function, so omitting the -f is intentional
set ruby_version $RUBY_VERSION set ruby_version $RUBY_VERSION
else if type -fq asdf else if type -fq asdf
@ -660,11 +715,15 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information'
or return or return
# If asdf changes their ruby version provenance format, update this to match # 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 set ruby_version $asdf_ruby_version
end end
[ -z "$ruby_version" ]; and return
[ -z "$ruby_version" ]
and return
__bobthefish_start_segment $color_rvm __bobthefish_start_segment $color_rvm
echo -ns $ruby_glyph $ruby_version ' ' echo -ns $ruby_glyph $ruby_version ' '
end end
@ -683,12 +742,16 @@ function __bobthefish_virtualenv_python_version -S -d 'Get current Python versio
end 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." 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) set -l version_glyph (__bobthefish_virtualenv_python_version)
if [ "$version_glyph" ] if [ "$version_glyph" ]
__bobthefish_start_segment $color_virtualfish __bobthefish_start_segment $color_virtualfish
echo -ns $virtualenv_glyph $version_glyph ' ' echo -ns $virtualenv_glyph $version_glyph ' '
end end
if [ "$VIRTUAL_ENV" ] if [ "$VIRTUAL_ENV" ]
echo -ns (basename "$VIRTUAL_ENV") ' ' echo -ns (basename "$VIRTUAL_ENV") ' '
else if [ "$CONDA_DEFAULT_ENV" ] else if [ "$CONDA_DEFAULT_ENV" ]
@ -697,14 +760,18 @@ function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual e
end end
function __bobthefish_prompt_virtualgo -S -d 'Display current Go virtual environment' 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 __bobthefish_start_segment $color_virtualgo
echo -ns $go_glyph ' ' (basename "$VIRTUALGO") ' ' echo -ns $go_glyph ' ' (basename "$VIRTUALGO") ' '
set_color normal set_color normal
end end
function __bobthefish_prompt_desk -S -d 'Display current desk environment' 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 __bobthefish_start_segment $color_desk
echo -ns $desk_glyph ' ' (basename -a -s ".fish" "$DESK_ENV") ' ' echo -ns $desk_glyph ' ' (basename -a -s ".fish" "$DESK_ENV") ' '
set_color normal set_color normal
@ -715,7 +782,7 @@ end
# VCS segments # VCS segments
# ============================== # ==============================
function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg state' function __bobthefish_prompt_hg -S -a hg_root_dir -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"
@ -727,7 +794,7 @@ function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg stat
set flag_colors $color_repo_dirty set flag_colors $color_repo_dirty
end end
__bobthefish_path_segment $current_dir __bobthefish_path_segment $hg_root_dir
__bobthefish_start_segment $flag_colors __bobthefish_start_segment $flag_colors
echo -ns $hg_glyph ' ' echo -ns $hg_glyph ' '
@ -736,7 +803,7 @@ function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg stat
echo -ns (__bobthefish_hg_branch) $flags ' ' echo -ns (__bobthefish_hg_branch) $flags ' '
set_color normal set_color normal
set -l project_pwd (__bobthefish_project_pwd $current_dir) set -l project_pwd (__bobthefish_project_pwd $hg_root_dir)
if [ "$project_pwd" ] if [ "$project_pwd" ]
if [ -w "$PWD" ] if [ -w "$PWD" ]
__bobthefish_start_segment $color_path __bobthefish_start_segment $color_path
@ -748,7 +815,7 @@ function __bobthefish_prompt_hg -S -a current_dir -d 'Display the actual hg stat
end end
end end
function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git state' function __bobthefish_prompt_git -S -a git_root_dir -d 'Display the actual git state'
set -l dirty '' set -l dirty ''
if [ "$theme_display_git_dirty" != 'no' ] if [ "$theme_display_git_dirty" != 'no' ]
set -l show_dirty (command git config --bool bash.showDirtyState 2>/dev/null) set -l show_dirty (command git config --bool bash.showDirtyState 2>/dev/null)
@ -776,6 +843,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
end end
set -l flags "$dirty$staged$stashed$ahead$new" set -l flags "$dirty$staged$stashed$ahead$new"
[ "$flags" ] [ "$flags" ]
and set flags " $flags" and set flags " $flags"
@ -786,14 +854,14 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
set flag_colors $color_repo_staged set flag_colors $color_repo_staged
end end
__bobthefish_path_segment $current_dir __bobthefish_path_segment $git_root_dir
__bobthefish_start_segment $flag_colors __bobthefish_start_segment $flag_colors
echo -ns (__bobthefish_git_branch) $flags ' ' echo -ns (__bobthefish_git_branch) $flags ' '
set_color normal set_color normal
if [ "$theme_git_worktree_support" != 'yes' ] if [ "$theme_git_worktree_support" != 'yes' ]
set -l project_pwd (__bobthefish_project_pwd $current_dir) set -l project_pwd (__bobthefish_project_pwd $git_root_dir)
if [ "$project_pwd" ] if [ "$project_pwd" ]
if [ -w "$PWD" ] if [ -w "$PWD" ]
__bobthefish_start_segment $color_path __bobthefish_start_segment $color_path
@ -813,8 +881,8 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
if [ "$work_dir" ] if [ "$work_dir" ]
switch $PWD/ switch $PWD/
case $work_dir/\* case $work_dir/\*
string match "$current_dir*" $work_dir >/dev/null string match "$git_root_dir*" $work_dir >/dev/null
and set work_dir (string sub -s (math 1 + (string length $current_dir)) $work_dir) and set work_dir (string sub -s (math 1 + (string length $git_root_dir)) $work_dir)
case \* case \*
set -e work_dir set -e work_dir
end end
@ -834,9 +902,11 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
if [ "$work_parent" ] if [ "$work_parent" ]
echo -n "$work_parent/" echo -n "$work_parent/"
end end
set_color normal set_color normal
set_color -b $color_repo_work_tree set_color -b $color_repo_work_tree
echo -n (__bobthefish_basename $work_dir) echo -n (__bobthefish_basename $work_dir)
set_color normal set_color normal
set_color -b $colors set_color -b $colors
[ "$project_pwd" ] [ "$project_pwd" ]
@ -846,8 +916,10 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st
echo -ns $project_pwd ' ' echo -ns $project_pwd ' '
else else
set project_pwd $PWD 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) string match "$git_root_dir*" $project_pwd >/dev/null
and set project_pwd (string sub -s (math 1 + (string length $git_root_dir)) $project_pwd)
set project_pwd (string trim --left --chars=/ -- $project_pwd) set project_pwd (string trim --left --chars=/ -- $project_pwd)
if [ "$project_pwd" ] if [ "$project_pwd" ]
@ -878,6 +950,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_glyphs __bobthefish_glyphs
__bobthefish_colors $theme_color_scheme __bobthefish_colors $theme_color_scheme
type -q bobthefish_colors type -q bobthefish_colors
and bobthefish_colors and bobthefish_colors
@ -903,21 +976,21 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
__bobthefish_prompt_virtualgo __bobthefish_prompt_virtualgo
# VCS # VCS
set -l git_root (__bobthefish_git_project_dir) set -l git_root_dir (__bobthefish_git_project_dir)
set -l hg_root (__bobthefish_hg_project_dir) set -l hg_root_dir (__bobthefish_hg_project_dir)
if [ "$git_root" -a "$hg_root" ] if [ "$git_root_dir" -a "$hg_root_dir" ]
# only show the closest parent # only show the closest parent
switch $git_root switch $git_root_dir
case $hg_root\* case $hg_root_dir\*
__bobthefish_prompt_git $git_root __bobthefish_prompt_git $git_root_dir
case \* case \*
__bobthefish_prompt_hg $hg_root __bobthefish_prompt_hg $hg_root_dir
end end
else if [ "$git_root" ] else if [ "$git_root_dir" ]
__bobthefish_prompt_git $git_root __bobthefish_prompt_git $git_root_dir
else if [ "$hg_root" ] else if [ "$hg_root_dir" ]
__bobthefish_prompt_hg $hg_root __bobthefish_prompt_hg $hg_root_dir
else else
__bobthefish_prompt_dir __bobthefish_prompt_dir
end end

View File

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

View File

@ -0,0 +1,8 @@
function update
pushd ~/dotfiles
git stash
git pull --rebase
fisher
git stash apply
popd
end

View File

@ -1,6 +0,0 @@
function updot
pushd ~/devel/dotfiles
git pull --rebase
fisher
popd
end