Skip to content

Instantly share code, notes, and snippets.

@Fingel
Created October 31, 2019 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fingel/7c2292a54977c06321f7daf72d81bca6 to your computer and use it in GitHub Desktop.
Save Fingel/7c2292a54977c06321f7daf72d81bca6 to your computer and use it in GitHub Desktop.
Fish profile
Time Sum Command
1133 5053 > builtin source /usr/local/Cellar/fish/3.0.2/share/fish/config.fish
50 50 -> set -g IFS \n\ \t
23 23 -> set -qg __fish_added_user_paths
19 19 -> set -g __fish_added_user_paths
17 17 -> function __fish_default_command_not_found_handler
printf "fish: Unknown command %s\n" (string escape -- $argv[1]) >&2
...
9 425 -> if status --is-interactive
# The user has seemingly explicitly launched an old fish with too-new scripts installed.
if not contains -- "string" (builtin -n)
set -g __is_launched_without_string 1
# XXX nostring - fix old fish binaries with no `string' builtin.
# When executed on fish 2.2.0, the `else' block after this would
# force on 24-bit mode due to changes to in test behavior.
# These "XXX nostring" hacks were added for 2.3.1
set_color --bold
echo "You appear to be trying to launch an old fish binary with newer scripts "
echo "installed into" (set_color --underline)"$__fish_data_dir"
set_color normal
echo -e "\nThis is an unsupported configuration.\n"
set_color yellow
echo "You may need to uninstall and reinstall fish!"
set_color normal
# Remove this code when we've made it safer to upgrade fish.
else
# Enable truecolor/24-bit support for select terminals
# Ignore Screen and emacs' ansi-term as they swallow the sequences, rendering the text white.
if not set -q STY
and not string match -q -- 'eterm*' $TERM
and begin
set -q KONSOLE_PROFILE_NAME # KDE's konsole
or string match -q -- "*:*" $ITERM_SESSION_ID # Supporting versions of iTerm2 will include a colon here
or string match -q -- "st-*" $TERM # suckless' st
or test -n "$VTE_VERSION" -a "$VTE_VERSION" -ge 3600 # Should be all gtk3-vte-based terms after version 3.6.0.0
or test "$COLORTERM" = truecolor -o "$COLORTERM" = 24bit # slang expects this
end
# Only set it if it isn't to allow override by setting to 0
set -q fish_term24bit
or set -g fish_term24bit 1
end
end
else
# Hook up the default as the principal command_not_found handler
# in case we are not interactive
function __fish_command_not_found_handler --on-event fish_command_not_found
__fish_default_command_not_found_handler $argv
end
...
21 21 --> status --is-interactive
6 395 --> if not contains -- "string" (builtin -n)
set -g __is_launched_without_string 1
# XXX nostring - fix old fish binaries with no `string' builtin.
# When executed on fish 2.2.0, the `else' block after this would
# force on 24-bit mode due to changes to in test behavior.
# These "XXX nostring" hacks were added for 2.3.1
set_color --bold
echo "You appear to be trying to launch an old fish binary with newer scripts "
echo "installed into" (set_color --underline)"$__fish_data_dir"
set_color normal
echo -e "\nThis is an unsupported configuration.\n"
set_color yellow
echo "You may need to uninstall and reinstall fish!"
set_color normal
# Remove this code when we've made it safer to upgrade fish.
else
# Enable truecolor/24-bit support for select terminals
# Ignore Screen and emacs' ansi-term as they swallow the sequences, rendering the text white.
if not set -q STY
and not string match -q -- 'eterm*' $TERM
and begin
set -q KONSOLE_PROFILE_NAME # KDE's konsole
or string match -q -- "*:*" $ITERM_SESSION_ID # Supporting versions of iTerm2 will include a colon here
or string match -q -- "st-*" $TERM # suckless' st
or test -n "$VTE_VERSION" -a "$VTE_VERSION" -ge 3600 # Should be all gtk3-vte-based terms after version 3.6.0.0
or test "$COLORTERM" = truecolor -o "$COLORTERM" = 24bit # slang expects this
end
# Only set it if it isn't to allow override by setting to 0
set -q fish_term24bit
or set -g fish_term24bit 1
end
...
173 225 ---> not contains -- "string" (builtin -n)
52 52 ----> builtin -n
11 164 ---> if not set -q STY
and not string match -q -- 'eterm*' $TERM
and begin
set -q KONSOLE_PROFILE_NAME # KDE's konsole
or string match -q -- "*:*" $ITERM_SESSION_ID # Supporting versions of iTerm2 will include a colon here
or string match -q -- "st-*" $TERM # suckless' st
or test -n "$VTE_VERSION" -a "$VTE_VERSION" -ge 3600 # Should be all gtk3-vte-based terms after version 3.6.0.0
or test "$COLORTERM" = truecolor -o "$COLORTERM" = 24bit # slang expects this
end
# Only set it if it isn't to allow override by setting to 0
set -q fish_term24bit
or set -g fish_term24bit 1
...
17 17 ----> not set -q STY
43 43 ----> not string match -q -- 'eterm*' $TERM
10 55 ----> begin
set -q KONSOLE_PROFILE_NAME # KDE's konsole
or string match -q -- "*:*" $ITERM_SESSION_ID # Supporting versions of iTerm2 will include a colon here
or string match -q -- "st-*" $TERM # suckless' st
or test -n "$VTE_VERSION" -a "$VTE_VERSION" -ge 3600 # Should be all gtk3-vte-based terms after version 3.6.0.0
or test "$COLORTERM" = truecolor -o "$COLORTERM" = 24bit # slang expects this
...
17 17 -----> set -q KONSOLE_PROFILE_NAME
28 28 -----> string match -q -- "*:*" $ITERM_SESSION_ID
16 16 ----> set -q fish_term24bit
22 22 ----> set -g fish_term24bit 1
32 32 -> set -g __fish_config_dir ~/.config/fish
2 18 -> if set -q XDG_CONFIG_HOME
set __fish_config_dir $XDG_CONFIG_HOME/fish
...
16 16 --> set -q XDG_CONFIG_HOME
24 24 -> set -l userdatadir ~/.local/share
1 17 -> if set -q XDG_DATA_HOME
set userdatadir $XDG_DATA_HOME
...
16 16 --> set -q XDG_DATA_HOME
17 17 -> set -l __extra_completionsdir
17 17 -> set -l __extra_functionsdir
16 16 -> set -l __extra_confdir
9 253 -> if test -f $__fish_data_dir/__fish_build_paths.fish
source $__fish_data_dir/__fish_build_paths.fish
...
64 64 --> test -f $__fish_data_dir/__fish_build_paths.fish
120 180 --> source $__fish_data_dir/__fish_build_paths.fish
24 24 ---> set __extra_completionsdir /usr/local/share/fish/vendor_completions.d
19 19 ---> set __extra_functionsdir /usr/local/share/fish/vendor_functions.d
17 17 ---> set __extra_confdir /usr/local/share/fish/vendor_conf.d
6 68 -> if not set -q fish_function_path
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $__extra_functionsdir $__fish_data_dir/functions
...
17 17 --> not set -q fish_function_path
45 45 --> set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $__extra_functionsdir $__fish_data_dir/functions
2 94 -> if not contains -- $__fish_data_dir/functions $fish_function_path
set fish_function_path $fish_function_path $__fish_data_dir/functions
...
92 92 --> not contains -- $__fish_data_dir/functions $fish_function_path
6 73 -> if not set -q fish_complete_path
set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $__extra_completionsdir $__fish_data_dir/completions $userdatadir/fish/generated_completions
...
17 17 --> not set -q fish_complete_path
50 50 --> set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $__extra_completionsdir $__fish_data_dir/completions $userdatadir/fish/generated_completions
2 41 -> if not contains -- $__fish_data_dir/completions $fish_complete_path
set fish_complete_path $fish_complete_path $__fish_data_dir/completions
...
39 39 --> not contains -- $__fish_data_dir/completions $fish_complete_path
6 6 -> function :
# no-op function for compatibility with sh, bash, and others.
# Often used to insert a comment into a chain of commands without having
# it eat up the remainder of the line, handy in Makefiles.
...
3 44 -> if test -d /usr/xpg4/bin
if not contains -- /usr/xpg4/bin $PATH
set PATH /usr/xpg4/bin $PATH
end
...
41 41 --> test -d /usr/xpg4/bin
17 17 -> function __fish_reconstruct_path -d "Update PATH when fish_user_paths changes" --on-variable fish_user_paths
set -l local_path $PATH
for x in $__fish_added_user_paths
set -l idx (contains --index -- $x $local_path)
and set -e local_path[$idx]
end
set -g __fish_added_user_paths
if set -q fish_user_paths
for x in $fish_user_paths[-1..1]
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -g __fish_added_user_paths $__fish_added_user_paths $x
end
set local_path $x $local_path
end
end
set -xg PATH $local_path
...
31 31 -> function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description "Signal handler for the TRAP signal. Launches a debug prompt."
breakpoint
...
10 10 -> function __fish_on_interactive --on-event fish_prompt
__fish_config_interactive
functions -e __fish_on_interactive
...
121 698 -> __fish_set_locale
381 389 --> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_set_locale.fish
8 8 ---> function __fish_set_locale
set -l LOCALE_VARS
set -a LOCALE_VARS LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE
set -a LOCALE_VARS LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS
set -a LOCALE_VARS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
# We check LC_ALL to figure out if we have a locale but we don't set it later. That is because
# locale.conf doesn't allow it so we should not set it.
for locale_var in $LOCALE_VARS LC_ALL
if set -q $locale_var
return 0
end
end
# Try to extract the locale from the kernel boot commandline. The splitting here is a bit weird,
# but we operate under the assumption that the locale can't include whitespace. Other whitespace
# shouldn't concern us, but a quoted "locale.LANG=SOMETHING" as a value to something else might.
# Here the last definition of a variable takes precedence.
if test -r /proc/cmdline
for var in (string match -ra 'locale.[^=]+=\S+' < /proc/cmdline)
set -l kv (string replace 'locale.' '' -- $var | string split '=')
# Only set locale variables, not other stuff contained in these files - this also
# automatically ignores comments.
if contains -- $kv[1] $LOCALE_VARS
and set -q kv[2]
set -gx $kv[1] (string trim -c '\'"' -- $kv[2])
end
end
end
# Now read the config files we know are used by various OS distros.
#
# /etc/sysconfig/i18n is for old Red Hat derivatives (and possibly of no use anymore).
#
# /etc/env.d/02locale is from OpenRC.
#
# The rest are systemd inventions but also used elsewhere (e.g. Void Linux). systemd's
# documentation is a bit unclear on this. We merge all the config files (and the commandline),
# which seems to be what systemd itself does. (I.e. the value for a variable will be taken from
# the highest-precedence source) We read the systemd files first since they are a newer
# invention and therefore the rest are likely to be accumulated cruft.
#
# NOTE: Slackware puts the locale in /etc/profile.d/lang.sh, which we can't use because it's a
# full POSIX-shell script.
set -l user_cfg_dir (set -q XDG_CONFIG_HOME; and echo $XDG_CONFIG_HOME; or echo ~/.config)
for f in $user_cfg_dir/locale.conf /etc/locale.conf /etc/env.d/02locale /etc/sysconfig/i18n
if test -r $f
while read -l kv
set kv (string split '=' -- $kv)
if contains -- $kv[1] $LOCALE_VARS
and set -q kv[2]
# Do not set already set variables again - this makes the merging happen.
if not set -q $kv[1]
set -gx $kv[1] (string trim -c '\'"' -- $kv[2])
end
end
end <$f
end
end
# If we really cannot get anything, at least set character encoding to UTF-8.
for locale_var in $LOCALE_VARS LC_ALL
if set -q $locale_var
return 0
end
end
set -gx LC_CTYPE en_US.UTF-8
...
23 23 --> set -l LOCALE_VARS
25 25 --> set -a LOCALE_VARS LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE
27 27 --> set -a LOCALE_VARS LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS
37 37 --> set -a LOCALE_VARS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
32 76 --> for locale_var in $LOCALE_VARS LC_ALL
if set -q $locale_var
return 0
end
...
7 44 ---> if set -q $locale_var
return 0
...
22 22 ----> set -q $locale_var
15 15 ----> return 0
13 13 -> function . --description 'Evaluate contents of file (deprecated, see "source")' --no-scope-shadowing
if test (count $argv) -eq 0
# Uses tty directly, as isatty depends on "."
and tty 0>&0 >/dev/null
echo "source: '.' command is deprecated, and doesn't work with STDIN anymore. Did you mean 'source' or './'?" >&2
return 1
else
source $argv
end
...
3 19 -> if not set -q __fish_init_2_3_0
if set -q fish_user_abbreviations
set -l fab
for abbr in $fish_user_abbreviations
set fab $fab (string replace -r '^([^ =]+)=(.*)$' '$1 $2' -- $abbr)
end
set fish_user_abbreviations $fab
end
set -U __fish_init_2_3_0
...
16 16 --> not set -q __fish_init_2_3_0
10 1357 -> if command -sq /usr/libexec/path_helper
# Adapt construct_path from the macOS /usr/libexec/path_helper
# executable for fish; see
# https://opensource.apple.com/source/shell_cmds/shell_cmds-203/path_helper/path_helper.c.auto.html .
function __fish_macos_set_env -d "set an environment variable like path_helper does (macOS only)"
set -l result
for path_file in $argv[2] $argv[3]/*
if test -f $path_file
while read -l entry
if not contains $entry $result
set result $result $entry
end
end <$path_file
end
end
for entry in $$argv[1]
if not contains $entry $result
set result $result $entry
end
end
set -xg $argv[1] $result
end
__fish_macos_set_env 'PATH' '/etc/paths' '/etc/paths.d'
if [ -n "$MANPATH" ]
__fish_macos_set_env 'MANPATH' '/etc/manpaths' '/etc/manpaths.d'
end
functions -e __fish_macos_set_env
...
46 46 --> command -sq /usr/libexec/path_helper
13 13 --> function __fish_macos_set_env -d "set an environment variable like path_helper does (macOS only)"
set -l result
for path_file in $argv[2] $argv[3]/*
if test -f $path_file
while read -l entry
if not contains $entry $result
set result $result $entry
end
end <$path_file
end
end
for entry in $$argv[1]
if not contains $entry $result
set result $result $entry
end
end
set -xg $argv[1] $result
...
36 1203 --> __fish_macos_set_env 'PATH' '/etc/paths' '/etc/paths.d'
20 20 ---> set -l result
151 655 ---> for path_file in $argv[2] $argv[3]/*
if test -f $path_file
while read -l entry
if not contains $entry $result
set result $result $entry
end
end <$path_file
end
...
12 504 ----> if test -f $path_file
while read -l entry
if not contains $entry $result
set result $result $entry
end
end <$path_file
...
37 37 -----> test -f $path_file
95 455 -----> while read -l entry
if not contains $entry $result
set result $result $entry
end
end <$path_file
39 39 ------> read -l entry
23 58 ------> if not contains $entry $result
set result $result $entry
...
18 18 -------> not contains $entry $result
17 17 -------> set result $result $entry
17 17 ------> read -l entry
11 43 ------> if not contains $entry $result
set result $result $entry
...
16 16 -------> not contains $entry $result
16 16 -------> set result $result $entry
15 15 ------> read -l entry
10 46 ------> if not contains $entry $result
set result $result $entry
...
17 17 -------> not contains $entry $result
19 19 -------> set result $result $entry
14 14 ------> read -l entry
10 51 ------> if not contains $entry $result
set result $result $entry
...
21 21 -------> not contains $entry $result
20 20 -------> set result $result $entry
15 15 ------> read -l entry
10 50 ------> if not contains $entry $result
set result $result $entry
...
19 19 -------> not contains $entry $result
21 21 -------> set result $result $entry
12 12 ------> read -l entry
50 449 ---> for entry in $$argv[1]
if not contains $entry $result
set result $result $entry
end
...
10 86 ----> if not contains $entry $result
set result $result $entry
...
32 32 -----> not contains $entry $result
44 44 -----> set result $result $entry
9 73 ----> if not contains $entry $result
set result $result $entry
...
30 30 -----> not contains $entry $result
34 34 -----> set result $result $entry
10 78 ----> if not contains $entry $result
set result $result $entry
...
30 30 -----> not contains $entry $result
38 38 -----> set result $result $entry
1 35 ----> if not contains $entry $result
set result $result $entry
...
34 34 -----> not contains $entry $result
2 32 ----> if not contains $entry $result
set result $result $entry
...
30 30 -----> not contains $entry $result
3 32 ----> if not contains $entry $result
set result $result $entry
...
29 29 -----> not contains $entry $result
2 32 ----> if not contains $entry $result
set result $result $entry
...
30 30 -----> not contains $entry $result
1 31 ----> if not contains $entry $result
set result $result $entry
...
30 30 -----> not contains $entry $result
43 43 ---> set -xg $argv[1] $result
2 22 --> if [ -n "$MANPATH" ]
__fish_macos_set_env 'MANPATH' '/etc/manpaths' '/etc/manpaths.d'
...
20 20 ---> [ -n "$MANPATH" ]
63 63 --> functions -e __fish_macos_set_env
3 21 -> if status --is-login
#
# Put linux consoles in unicode mode.
#
if test "$TERM" = linux
if string match -qir '\.UTF' -- $LANG
if command -sq unicode_start
unicode_start
end
end
end
...
18 18 --> status --is-login
26 154 -> __fish_reconstruct_path
36 36 --> set -l local_path $PATH
19 19 --> for x in $__fish_added_user_paths
set -l idx (contains --index -- $x $local_path)
and set -e local_path[$idx]
...
17 17 --> set -g __fish_added_user_paths
1 16 --> if set -q fish_user_paths
for x in $fish_user_paths[-1..1]
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -g __fish_added_user_paths $__fish_added_user_paths $x
end
set local_path $x $local_path
end
...
15 15 ---> set -q fish_user_paths
40 40 --> set -xg PATH $local_path
7 7 -> function __fish_expand_pid_args
for arg in $argv
if string match -qr '^%\d+$' -- $arg
# set newargv $newargv (jobs -p $arg)
jobs -p $arg
if not test $status -eq 0
return 1
end
else
printf "%s\n" $arg
end
end
...
4 4 -> function bg
builtin bg (__fish_expand_pid_args $argv)
...
3 3 -> function fg
builtin fg (__fish_expand_pid_args $argv)
...
4 4 -> function kill
command kill (__fish_expand_pid_args $argv)
...
4 4 -> function wait
builtin wait (__fish_expand_pid_args $argv)
...
5 5 -> function disown
builtin disown (__fish_expand_pid_args $argv)
...
20 20 -> set -l sourcelist
299 299 -> for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish $__extra_confdir/*.fish
set -l basename (string replace -r '^.*/' '' -- $file)
contains -- $basename $sourcelist
and continue
set sourcelist $sourcelist $basename
# Also skip non-files or unreadable files.
# This allows one to use e.g. symlinks to /dev/null to "mask" something (like in systemd).
[ -f $file -a -r $file ]
and source $file
...
71 71 > builtin source /usr/local/Cellar/fish/3.0.2/etc/fish/config.fish
117 169928 > builtin source /Users/austin/.config/fish/config.fish
183 167066 -> eval (python3 -m virtualfish auto_activation)
209 226 --> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/eval.fish
17 17 ---> function eval -S -d "Evaluate parameters as a command"
# keep a copy of the previous $status and use restore_status
# to preserve the status in case the block that is evaluated
# does not modify the status itself.
set -l status_copy $status
function __fish_restore_status
return $argv[1]
end
if not set -q argv[2]
# like most builtins, we only check for -h/--help
# if we only have a single argument
switch "$argv[1]"
case -h --help
__fish_print_help eval
return 0
end
end
# If we are in an interactive shell, eval should enable full
# job control since it should behave like the real code was
# executed. If we don't do this, commands that expect to be
# used interactively, like less, wont work using eval.
set -l mode
if status --is-interactive-job-control
set mode interactive
else
if status --is-full-job-control
set mode full
else
set mode none
end
end
if status --is-interactive
status --job-control full
end
__fish_restore_status $status_copy
# To eval 'foo', we construct a block "begin ; foo; end <&3 3<&-"
# Note the redirections are also within the quotes.
#
# We then pipe this to 'source 3<&0’.
#
# You might expect that the dup2(3, stdin) should overwrite stdin,
# and therefore prevent 'source' from reading the piped-in block. This doesn't happen
# because when you pipe to a builtin, we don't overwrite stdin with the read end
# of the block; instead we set a separate fd in a variable 'builtin_stdin', which is
# what it reads from. So builtins are magic in that, in pipes, their stdin
# is not fd 0.
#
# ‘source’ does not apply the redirections to itself. Instead it saves them and passes
# them as block-level redirections to parser.eval(). Ultimately the eval’d code sees
# the following redirections (in the following order):
# dup2 0 -> 3
# dup2 pipe -> 0
# dup2 3 -> 0
# where the pipe is the pipe we get from piping ‘echo’ to ‘source’. Thus the redirection
# effectively makes stdin fd0, instead of the thing that was piped to ‘source’
echo "begin; $argv "\n" ;end <&3 3<&-" | source 3<&0
set -l res $status
status --job-control $mode
return $res
...
131479 131479 --> python3 -m virtualfish auto_activation
40 40 --> set -l status_copy $status
7 7 --> function __fish_restore_status
return $argv[1]
...
7 35 --> if not set -q argv[2]
# like most builtins, we only check for -h/--help
# if we only have a single argument
switch "$argv[1]"
case -h --help
__fish_print_help eval
return 0
end
...
16 16 ---> not set -q argv[2]
12 12 ---> switch "$argv[1]"
case -h --help
__fish_print_help eval
return 0
...
14 14 --> set -l mode
5 32 --> if status --is-interactive-job-control
set mode interactive
else
if status --is-full-job-control
set mode full
else
set mode none
end
...
13 13 ---> status --is-interactive-job-control
14 14 ---> set mode interactive
4 26 --> if status --is-interactive
status --job-control full
...
11 11 ---> status --is-interactive
11 11 ---> status --job-control full
18 31 --> __fish_restore_status $status_copy
13 13 ---> return $argv[1]
786 34943 --> echo "begin; $argv "\n" ;end <&3 3<&-" | source 3<&0
38 34157 ---> begin; set -g VIRTUALFISH_VERSION 1.0.6;set -g VIRTUALFISH_PYTHON_EXEC /usr/local/opt/python/bin/python3.7;source /usr/local/lib/python3.7/site-packages/virtualfish/virtual.fish;source /usr/local/lib/python3.7/site-packages/virtualfish/auto_activation.fish;emit virtualfish_did_setup_plugins
;end <&3 3<&-
30 30 ----> set -g VIRTUALFISH_VERSION 1.0.6
19 19 ----> set -g VIRTUALFISH_PYTHON_EXEC /usr/local/opt/python/bin/python3.7
1027 1320 ----> source /usr/local/lib/python3.7/site-packages/virtualfish/virtual.fish
6 65 -----> if not set -q VIRTUALFISH_HOME
set -g VIRTUALFISH_HOME $HOME/.virtualenvs
...
35 35 ------> not set -q VIRTUALFISH_HOME
24 24 ------> set -g VIRTUALFISH_HOME $HOME/.virtualenvs
11 11 -----> function vf --description "VirtualFish: fish plugin to manage virtualenvs"
# Check for existence of $VIRTUALFISH_HOME
if not test -d $VIRTUALFISH_HOME
echo "The directory $VIRTUALFISH_HOME does not exist."
echo "Would you like to create it?"
echo "Tip: To use a different directory, set the variable \$VIRTUALFISH_HOME."
read -n1 -p "echo 'y/n> '" -l do_create
if test $do_create = "y"
mkdir $VIRTUALFISH_HOME
else
return 1
end
end
# copy all but the first argument to $scargs
set -l sc $argv[1]
set -l funcname "__vf_$sc"
set -l scargs
if begin; [ (count $argv) -eq 0 ]; or [ $sc = "--help" ]; or [ $sc = "-h" ]; end
# If called without arguments, print usage
vf help
return
end
if test (count $argv) -gt 1
set scargs $argv[2..-1]
end
if functions -q $funcname
eval $funcname $scargs
else
echo "The subcommand $sc is not defined"
end
...
8 8 -----> function __vf_activate --description "Activate a virtualenv"
# check arguments
if [ (count $argv) -lt 1 ]
echo "You need to specify a virtualenv."
return 1
end
if not [ -d $VIRTUALFISH_HOME/$argv[1] ]
echo "The virtualenv $argv[1] does not exist."
echo "You can create it with mkvirtualenv."
return 2
end
#Check if a different env is being used
if set -q VIRTUAL_ENV
vf deactivate
end
# Set VIRTUAL_ENV before the others so that the will_activate event knows
# which virtualenv is about to be activated
set -gx VIRTUAL_ENV $VIRTUALFISH_HOME/$argv[1]
emit virtualenv_will_activate
emit virtualenv_will_activate:$argv[1]
set -g _VF_EXTRA_PATH $VIRTUAL_ENV/bin
set -gx PATH $_VF_EXTRA_PATH $PATH
# hide PYTHONHOME, PIP_USER
if set -q PYTHONHOME
set -g _VF_OLD_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if set -q PIP_USER
set -g _VF_OLD_PIP_USER $PIP_USER
set -e PIP_USER
end
emit virtualenv_did_activate
emit virtualenv_did_activate:(basename $VIRTUAL_ENV)
...
7 7 -----> function __vf_deactivate --description "Deactivate this virtualenv"
if not set -q VIRTUAL_ENV
echo "No virtualenv is activated."
return
end
emit virtualenv_will_deactivate
emit virtualenv_will_deactivate:(basename $VIRTUAL_ENV)
# find elements to remove from PATH
set to_remove
for i in (seq (count $PATH))
if contains $PATH[$i] $_VF_EXTRA_PATH
set to_remove $to_remove $i
end
end
# remove them
for i in $to_remove
set -e PATH[$i]
end
# restore PYTHONHOME, PIP_USER
if set -q _VF_OLD_PYTHONHOME
set -gx PYTHONHOME $_VF_OLD_PYTHONHOME
set -e _VF_OLD_PYTHONHOME
end
if set -q _VF_OLD_PIP_USER
set -gx PIP_USER $_VF_OLD_PIP_USER
set -e _VF_OLD_PIP_USER
end
emit virtualenv_did_deactivate
emit virtualenv_did_deactivate:(basename $VIRTUAL_ENV)
set -e VIRTUAL_ENV
...
7 7 -----> function __vf_new --description "Create a new virtualenv"
# Deactivate the current virtualenv, if one is active
if set -q VIRTUAL_ENV
vf deactivate
end
emit virtualenv_will_create
set envname $argv[-1]
set -e argv[-1]
if set -q VIRTUALFISH_DEFAULT_PYTHON
set argv "--python" $VIRTUALFISH_DEFAULT_PYTHON $argv
end
set -lx PIP_USER 0
eval $VIRTUALFISH_PYTHON_EXEC -m virtualenv $argv $VIRTUALFISH_HOME/$envname
set vestatus $status
if begin; [ $vestatus -eq 0 ]; and [ -d $VIRTUALFISH_HOME/$envname ]; end
vf activate $envname
emit virtualenv_did_create
emit virtualenv_did_create:(basename $VIRTUAL_ENV)
else
echo "Error: The virtualenv wasn't created properly."
echo "virtualenv returned status $vestatus."
if test (count $argv) -ge 1
echo "Make sure you put any option flags before the virtualenv name."
echo "Good example: "(set_color green)"vf new -p python3.5 myproject" (set_color normal)
echo "Bad example: "(set_color red)"vf new myproject -p python3.5" (set_color normal)
end
return 1
end
...
6 6 -----> function __vf_rm --description "Delete a virtualenv"
if not [ (count $argv) -eq 1 ]
echo "You need to specify exactly one virtualenv."
return 1
end
if begin; set -q VIRTUAL_ENV; and [ $argv[1] = (basename $VIRTUAL_ENV) ]; end
echo "You can't delete a virtualenv you're currently using."
return 1
end
echo "Removing $VIRTUALFISH_HOME/$argv[1]"
rm -rf $VIRTUALFISH_HOME/$argv[1]
...
7 7 -----> function __vf_ls --description "List all of the available virtualenvs"
pushd $VIRTUALFISH_HOME
for i in */bin/python
echo $i
end | sed "s|/bin/python||"
popd
...
7 7 -----> function __vf_cd --description "Change directory to this virtualenv"
if set -q VIRTUAL_ENV
cd $VIRTUAL_ENV
else
echo "Cannot locate an active virtualenv."
end
...
7 7 -----> function __vf_cdpackages --description "Change to the site-packages directory of this virtualenv"
vf cd
cd (find . -name site-packages -type d | head -n1)
...
11 11 -----> function __vf_tmp --description "Create a virtualenv that will be removed when deactivated"
set -l env_name (printf "%s%.4x" "tempenv-" (random) (random) (random))
vf new $argv $env_name
set -g VF_TEMPORARY_ENV
...
28 28 -----> function __vfsupport_remove_env_on_deactivate_or_exit --on-event virtualenv_did_deactivate --on-process %self
if set -q VF_TEMPORARY_ENV
echo "Removing temporary virtualenv" (basename $VIRTUAL_ENV)
rm -rf $VIRTUAL_ENV
set -e VF_TEMPORARY_ENV
end
...
8 8 -----> function __vf_addpath --description "Adds a path to sys.path in this virtualenv"
if set -q VIRTUAL_ENV
set -l site_packages (eval "$VIRTUAL_ENV/bin/python -c 'import distutils; print(distutils.sysconfig.get_python_lib())'")
set -l path_file $site_packages/_virtualenv_path_extensions.pth
set -l remove 0
if test $argv[1] = "-d"
set remove 1
set -e argv[1]
end
if not test -f $path_file
echo "import sys; sys.__plen = len(sys.path)" > $path_file
echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> $path_file
end
for pydir in $argv
set -l absolute_path (eval "$VIRTUAL_ENV/bin/python -c 'import os,sys; sys.stdout.write(os.path.abspath(\"$pydir\")+\"\n\")'")
if not test $pydir = $absolute_path
echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2
end
if test $remove -eq 1
sed -i.tmp "\:^$absolute_path\$: d" "$path_file"
else
sed -i.tmp '1 a\
'"$absolute_path"'
' "$path_file"
end
rm -f "$path_file.tmp"
end
return 0
else
echo "No virtualenv is active."
end
...
7 7 -----> function __vf_all --description "Run a command in all virtualenvs sequentially"
if test (count $argv) -lt 1
echo "You need to supply a command."
return 1
end
if set -q VIRTUAL_ENV
set -l old_env (basename $VIRTUAL_ENV)
end
for env in (vf ls)
vf activate $env
eval $argv
end
if set -q old_env
vf activate $old_env
else
vf deactivate
end
...
15 49 -----> if not set -q VIRTUALFISH_ACTIVATION_FILE
set -g VIRTUALFISH_ACTIVATION_FILE .venv
...
17 17 ------> not set -q VIRTUALFISH_ACTIVATION_FILE
17 17 ------> set -g VIRTUALFISH_ACTIVATION_FILE .venv
4 33 -----> if not set -q VIRTUALFISH_GLOBAL_SITE_PACKAGES_FILE
set -g VIRTUALFISH_GLOBAL_SITE_PACKAGES_FILE "no-global-site-packages.txt"
...
13 13 ------> not set -q VIRTUALFISH_GLOBAL_SITE_PACKAGES_FILE
16 16 ------> set -g VIRTUALFISH_GLOBAL_SITE_PACKAGES_FILE "no-global-site-packages.txt"
8 8 -----> function __vf_connect --description "Connect this virtualenv to the current directory"
if set -q VIRTUAL_ENV
basename $VIRTUAL_ENV > $VIRTUALFISH_ACTIVATION_FILE
else
echo "No virtualenv is active."
end
...
8 8 -----> function __vf_help --description "Print VirtualFish usage information"
echo "virtualfish $VIRTUALFISH_VERSION"
echo
echo "Usage: vf <command> [<args>]"
echo
echo "Available commands:"
echo
for sc in (functions -a | sed -n '/__vf_/{s///g;p;}')
set -l helptext (functions "__vf_$sc" | grep '^function ' | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
printf " %-15s %s\n" $sc (set_color 555)$helptext(set_color normal)
end
echo
if set -q VIRTUALFISH_VERSION
set help_url "http://virtualfish.readthedocs.org/en/$VIRTUALFISH_VERSION/"
else
set help_url "http://virtualfish.readthedocs.org/en/latest/"
end
echo "For full documentation, see: $help_url"
...
9 9 -----> function __vf_globalpackages --description "Toggle global site packages"
if set -q VIRTUAL_ENV
vf cd
# use site-packages/.. to avoid ending up in python-wheels
cd lib/python*/site-packages/..
if test -e $VIRTUALFISH_GLOBAL_SITE_PACKAGES_FILE
echo "Enabling global site packages"
rm $VIRTUALFISH_GLOBAL_SITE_PACKAGES_FILE
else
echo "Disabling global site packages"
touch $VIRTUALFISH_GLOBAL_SITE_PACKAGES_FILE
end
else
echo "No virtualenv is active."
end
...
7 7 -----> function __vfsupport_setup_autocomplete --on-event virtualfish_did_setup_plugins
function __vfcompletion_needs_command
set cmd (commandline -opc)
if test (count $cmd) -eq 1 -a $cmd[1] = 'vf'
return 0
end
return 1
end
function __vfcompletion_using_command
set cmd (commandline -opc)
if test (count $cmd) -gt 1
if test $argv[1] = $cmd[2]
return 0
end
end
return 1
end
# add completion for subcommands
for sc in (functions -a | sed -n '/__vf_/{s///g;p;}')
set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
end
complete -x -c vf -n '__vfcompletion_using_command activate' -a "(vf ls)"
complete -x -c vf -n '__vfcompletion_using_command rm' -a "(vf ls)"
...
195 4325 ----> source /usr/local/lib/python3.7/site-packages/virtualfish/auto_activation.fish
9 9 -----> function __vfsupport_auto_activate --on-variable PWD
if status --is-command-substitution
return
end
# find an auto-activation file
set -l activation_root $PWD
set -l new_virtualenv_name ""
while test $activation_root != ""
if test -f "$activation_root/$VIRTUALFISH_ACTIVATION_FILE"
set new_virtualenv_name (cat "$activation_root/$VIRTUALFISH_ACTIVATION_FILE")
break
end
# this strips the last path component from the path.
set activation_root (echo $activation_root | sed 's|/[^/]*$||')
end
if test $new_virtualenv_name != ""
# if the virtualenv in the file is different, switch to it
if begin; not set -q VIRTUAL_ENV; or test $new_virtualenv_name != (basename $VIRTUAL_ENV); end
vf activate $new_virtualenv_name
set -g VF_AUTO_ACTIVATED $activation_root
end
else
# if there's an auto-activated virtualenv, deactivate it
if set -q VIRTUAL_ENV VF_AUTO_ACTIVATED
vf deactivate
end
end
...
8 8 -----> function __vfsupport_deactivate_remove_flag --on-event virtualenv_did_deactivate
# remove autoactivated flag
if set -q VF_AUTO_ACTIVATED
set -e VF_AUTO_ACTIVATED
end
...
26 4113 -----> __vfsupport_auto_activate
1 18 ------> if status --is-command-substitution
return
...
17 17 -------> status --is-command-substitution
24 24 ------> set -l activation_root $PWD
17 17 ------> set -l new_virtualenv_name ""
17 2174 ------> while test $activation_root != ""
if test -f "$activation_root/$VIRTUALFISH_ACTIVATION_FILE"
set new_virtualenv_name (cat "$activation_root/$VIRTUALFISH_ACTIVATION_FILE")
break
end
# this strips the last path component from the path.
set activation_root (echo $activation_root | sed 's|/[^/]*$||')
...
21 21 -------> test $activation_root != ""
10 2136 -------> if test -f "$activation_root/$VIRTUALFISH_ACTIVATION_FILE"
set new_virtualenv_name (cat "$activation_root/$VIRTUALFISH_ACTIVATION_FILE")
break
...
33 33 --------> test -f "$activation_root/$VIRTUALFISH_ACTIVATION_FILE"
68 2078 --------> set new_virtualenv_name (cat "$activation_root/$VIRTUALFISH_ACTIVATION_FILE")
2010 2010 ---------> cat "$activation_root/$VIRTUALFISH_ACTIVATION_FILE"
15 15 --------> break
11 1854 ------> if test $new_virtualenv_name != ""
# if the virtualenv in the file is different, switch to it
if begin; not set -q VIRTUAL_ENV; or test $new_virtualenv_name != (basename $VIRTUAL_ENV); end
vf activate $new_virtualenv_name
set -g VF_AUTO_ACTIVATED $activation_root
end
else
# if there's an auto-activated virtualenv, deactivate it
if set -q VIRTUAL_ENV VF_AUTO_ACTIVATED
vf deactivate
end
...
23 23 -------> test $new_virtualenv_name != ""
2 1820 -------> if begin; not set -q VIRTUAL_ENV; or test $new_virtualenv_name != (basename $VIRTUAL_ENV); end
vf activate $new_virtualenv_name
set -g VF_AUTO_ACTIVATED $activation_root
...
6 1818 --------> begin; not set -q VIRTUAL_ENV; or test $new_virtualenv_name != (basename $VIRTUAL_ENV); ...
15 15 ---------> not set -q VIRTUAL_ENV
68 1797 ---------> test $new_virtualenv_name != (basename $VIRTUAL_ENV)
1729 1729 ----------> basename $VIRTUAL_ENV
74 28425 ----> emit virtualfish_did_setup_plugins
38 28351 -----> __vfsupport_setup_autocomplete
7 7 ------> function __vfcompletion_needs_command
set cmd (commandline -opc)
if test (count $cmd) -eq 1 -a $cmd[1] = 'vf'
return 0
end
return 1
...
4 4 ------> function __vfcompletion_using_command
set cmd (commandline -opc)
if test (count $cmd) -gt 1
if test $argv[1] = $cmd[2]
return 0
end
end
return 1
...
224 28244 ------> for sc in (functions -a | sed -n '/__vf_/{s///g;p;}')
set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
...
2886 2886 -------> functions -a | sed -n '/__vf_/{s///g;p;}'
100 2280 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
2180 2180 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
90 90 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
99 2157 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
2058 2058 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
43 43 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
88 1948 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1860 1860 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
49 49 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
87 1779 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1692 1692 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
40 40 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
85 1770 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1685 1685 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
39 39 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
89 1774 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1685 1685 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
40 40 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
84 1819 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1735 1735 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
41 41 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
89 1847 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1758 1758 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
42 42 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
87 1902 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1815 1815 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
39 39 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
85 1799 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1714 1714 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
37 37 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
84 1890 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1806 1806 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
37 37 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
83 1803 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1720 1720 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
38 38 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
75 1793 -------> set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
1718 1718 --------> functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|"
38 38 -------> complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
32 32 ------> complete -x -c vf -n '__vfcompletion_using_command activate' -a "(vf ls)"
26 26 ------> complete -x -c vf -n '__vfcompletion_using_command rm' -a "(vf ls)"
22 22 --> set -l res $status
15 15 --> status --job-control $mode
13 13 --> return $res
42 42 -> set PATH /Users/austin/bin /Users/austin/.cargo/bin $PATH
16 16 -> set -xg NVIM_TUI_ENABLE_TRUECOLOR 1
13 13 -> set -xg EDITOR nvim
124 2645 -> alias vim=nvim
289 301 --> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/alias.fish
12 12 ---> function alias --description 'Creates a function wrapping a command'
set -l options 'h/help' 's/save'
argparse -n alias --max-args=2 $options -- $argv
or return
if set -q _flag_help
__fish_print_help alias
return 0
end
set -l name
set -l body
set -l prefix
set -l first_word
set -l wrapped_cmd
if not set -q argv[1]
# Print the known aliases.
for func in (functions -n)
set -l output (functions $func | string match -r -- "^function .* --description 'alias (.*)'")
if set -q output[2]
set output (string replace -r -- '^'$func'[= ]' '' $output[2])
echo alias $func (string escape -- $output[1])
end
end
return 0
else if not set -q argv[2]
# Alias definition of the form "name=value".
set -l tmp (string split -m 1 "=" -- $argv) ""
set name $tmp[1]
set body $tmp[2]
else
# Alias definition of the form "name value".
set name $argv[1]
set body $argv[2]
end
# sanity check
if test -z "$name"
printf ( _ "%s: Name cannot be empty\n") alias
return 1
else if test -z "$body"
printf ( _ "%s: Body cannot be empty\n") alias
return 1
end
# Extract the first command from the body. This is supposed to replace all non-escaped (i.e.
# preceded by an odd number of `\`) spaces with a newline so it splits on them. See issue #2220
# for why the following borderline incomprehensible code exists.
set -l tmp (string replace -ra -- "([^\\\ ])((\\\\\\\)*) " '$1\n' $body)
set first_word (string trim -- $tmp[1])
# If the user does something like `alias x 'foo; bar'` we need to strip the semicolon.
set base_command (string trim -c ';' -- $first_word)
if set -q tmp[2]
set body $tmp[2..-1]
else
set body
end
# Prevent the alias from immediately running into an infinite recursion if
# $body starts with the same command as $name.
if test $base_command = $name
if contains $name (builtin --names)
set prefix builtin
else
set prefix command
end
end
set -l cmd_string (string escape -- "alias $argv")
set wrapped_cmd (string join ' ' -- $first_word $body | string escape)
echo "function $name --wraps $wrapped_cmd --description $cmd_string; $prefix $first_word $body \$argv; end" | source
if set -q _flag_save
funcsave $name
end
#echo "function $name --wraps $wrapped_cmd --description $cmd_string; $prefix $first_word $body \$argv; end"
...
22 22 --> set -l options 'h/help' 's/save'
34 34 --> argparse -n alias --max-args=2 $options -- $argv
1 25 --> if set -q _flag_help
__fish_print_help alias
return 0
...
24 24 ---> set -q _flag_help
13 13 --> set -l name
11 11 --> set -l body
11 11 --> set -l prefix
11 11 --> set -l first_word
12 12 --> set -l wrapped_cmd
10 444 --> if not set -q argv[1]
# Print the known aliases.
for func in (functions -n)
set -l output (functions $func | string match -r -- "^function .* --description 'alias (.*)'")
if set -q output[2]
set output (string replace -r -- '^'$func'[= ]' '' $output[2])
echo alias $func (string escape -- $output[1])
end
end
return 0
else if not set -q argv[2]
# Alias definition of the form "name=value".
set -l tmp (string split -m 1 "=" -- $argv) ""
set name $tmp[1]
set body $tmp[2]
else
# Alias definition of the form "name value".
set name $argv[1]
set body $argv[2]
...
12 12 ---> not set -q argv[1]
11 11 ---> not set -q argv[2]
37 382 ---> set -l tmp (string split -m 1 "=" -- $argv) ""
88 345 ----> string split -m 1 "=" -- $argv
125 257 -----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/string.fish
3 132 ------> if not contains string (builtin -n)
function string
if not set -q __is_launched_without_string
if status --is-interactive
# We've been autoloaded after fish < 2.3.0 upgraded to >= 2.3.1 - no string builtin
set_color --bold >&2
echo "Fish has been upgraded, and the scripts on your system are not compatible" >&2
echo "with this prior instance of fish. You can probably run:" >&2
set_color green >&2
echo -e "\n exec fish" >&2
set_color normal >&2
echo "… to replace this process with a new one in-place." >&2
set -g __is_launched_without_string 1
end
end
set -p PATH $__fish_bin_dir
set string_cmd string \'$argv\'
if fish -c 'contains string (builtin -n)'
fish -c "$string_cmd"
else
return 127
end
end
...
96 129 -------> not contains string (builtin -n)
33 33 --------> builtin -n
16 16 ---> set name $tmp[1]
13 13 ---> set body $tmp[2]
2 31 --> if test -z "$name"
printf ( _ "%s: Name cannot be empty\n") alias
return 1
else if test -z "$body"
printf ( _ "%s: Body cannot be empty\n") alias
return 1
...
16 16 ---> test -z "$name"
13 13 ---> test -z "$body"
39 138 --> set -l tmp (string replace -ra -- "([^\\\ ])((\\\\\\\)*) " '$1\n' $body)
99 99 ---> string replace -ra -- "([^\\\ ])((\\\\\\\)*) " '$1\n' $body
35 54 --> set first_word (string trim -- $tmp[1])
19 19 ---> string trim -- $tmp[1]
33 53 --> set base_command (string trim -c ';' -- $first_word)
20 20 ---> string trim -c ';' -- $first_word
5 27 --> if set -q tmp[2]
set body $tmp[2..-1]
else
set body
...
12 12 ---> set -q tmp[2]
10 10 ---> set body
1 18 --> if test $base_command = $name
if contains $name (builtin --names)
set prefix builtin
else
set prefix command
end
...
17 17 ---> test $base_command = $name
36 56 --> set -l cmd_string (string escape -- "alias $argv")
20 20 ---> string escape -- "alias $argv"
54 609 --> set wrapped_cmd (string join ' ' -- $first_word $body | string escape)
555 555 ---> string join ' ' -- $first_word $body | string escape
599 627 --> echo "function $name --wraps $wrapped_cmd --description $cmd_string; $prefix $first_word $body \$argv; end" | source
28 28 ---> function vim --wraps nvim --description 'alias vim=nvim'; nvim $argv; ...
1 24 --> if set -q _flag_save
funcsave $name
...
23 23 ---> set -q _flag_save
29 29 -> set fish_greeting
87 93 > source /usr/local/Cellar/fish/3.0.2/share/fish/functions/fish_title.fish
6 6 -> function fish_title
echo (status current-command) (__fish_pwd)
...
14 1658 > fish_title
57 1644 -> echo (status current-command) (__fish_pwd)
17 17 --> status current-command
78 1570 --> __fish_pwd
85 1440 ---> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_pwd.fish
32 1355 ----> switch (uname)
case 'CYGWIN_*'
function __fish_pwd --description "Show current path"
pwd | sed -e 's-^/cygdrive/\(.\)/\?-\u\1:/-'
end
case '*'
function __fish_pwd --description "Show current path"
pwd
end
...
1313 1313 -----> uname
10 10 -----> function __fish_pwd --description "Show current path"
pwd
...
52 52 ---> pwd
16 9929 > __fish_on_interactive
147 9891 -> __fish_config_interactive
965 976 --> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_config_interactive.fish
11 11 ---> function __fish_config_interactive -d "Initializations that should be performed when entering interactive mode"
if not set -q __fish_init_3_x
# Perform transitions relevant to going from fish 2.x to 3.x.
# Migrate old universal abbreviations to the new scheme.
__fish_abbr_old | source
set -U __fish_init_3_x
end
# Make sure this function is only run once.
if set -q __fish_config_interactive_done
return
end
set -g __fish_config_interactive_done
set -g __fish_active_key_bindings
# Set the correct user data directory
set -l userdatadir ~/.local/share
if set -q XDG_DATA_HOME
set userdatadir $XDG_DATA_HOME
end
if not set -q fish_greeting
set -l line1 (_ 'Welcome to fish, the friendly interactive shell')
set -l line2 ''
if not set -q __fish_init_2_3_0
set line2 \n(_ 'Type `help` for instructions on how to use fish')
end
set -U fish_greeting "$line1$line2"
end
if set -q fish_private_mode
set -l line (_ "fish is running in private mode, history will not be persisted.")
set -g fish_greeting $fish_greeting.\n$line
end
#
# If we are starting up for the first time, set various defaults.
#
# bump this to 2_4_0 when rolling release if anything changes after 9/10/2016
if not set -q __fish_init_2_39_8
# Regular syntax highlighting colors
set -q fish_color_normal
or set -U fish_color_normal normal
set -q fish_color_command
or set -U fish_color_command 005fd7
set -q fish_color_param
or set -U fish_color_param 00afff
set -q fish_color_redirection
or set -U fish_color_redirection 00afff
set -q fish_color_comment
or set -U fish_color_comment 990000
set -q fish_color_error
or set -U fish_color_error ff0000
set -q fish_color_escape
or set -U fish_color_escape 00a6b2
set -q fish_color_operator
or set -U fish_color_operator 00a6b2
set -q fish_color_end
or set -U fish_color_end 009900
set -q fish_color_quote
or set -U fish_color_quote 999900
set -q fish_color_autosuggestion
or set -U fish_color_autosuggestion 555 brblack
set -q fish_color_user
or set -U fish_color_user brgreen
set -q fish_color_host
or set -U fish_color_host normal
set -q fish_color_valid_path
or set -U fish_color_valid_path --underline
set -q fish_color_cwd
or set -U fish_color_cwd green
set -q fish_color_cwd_root
or set -U fish_color_cwd_root red
# Background color for matching quotes and parenthesis
set -q fish_color_match
or set -U fish_color_match --background=brblue
# Background color for search matches
set -q fish_color_search_match
or set -U fish_color_search_match bryellow --background=brblack
# Background color for selections
set -q fish_color_selection
or set -U fish_color_selection white --bold --background=brblack
set -q fish_color_cancel
or set -U fish_color_cancel -r
# Pager colors
set -q fish_pager_color_prefix
or set -U fish_pager_color_prefix white --bold --underline
set -q fish_pager_color_completion
or set -U fish_pager_color_completion
set -q fish_pager_color_description
or set -U fish_pager_color_description B3A06D yellow
set -q fish_pager_color_progress
or set -U fish_pager_color_progress brwhite --background=cyan
#
# Directory history colors
#
set -q fish_color_history_current
or set -U fish_color_history_current --bold
set -U __fish_init_2_39_8
end
#
# Generate man page completions if not present.
#
# Don't do this if we're being invoked as part of running unit tests.
if not set -q FISH_UNIT_TESTS_RUNNING
if not test -d $userdatadir/fish/generated_completions
# Generating completions from man pages needs python (see issue #3588).
# We cannot simply do `fish_update_completions &` because it is a function.
# We cannot do `eval` since it is a function.
# We don't want to call `fish -c` since that is unnecessary and sources config.fish again.
# Hence we'll call python directly.
# c_m_p.py should work with any python version.
set -l update_args -B $__fish_data_dir/tools/create_manpage_completions.py --manpath --cleanup-in '~/.config/fish/completions' --cleanup-in '~/.config/fish/generated_completions'
for py in python{3,2,}
if command -sq $py
$py $update_args >/dev/null 2>&1 &
break
end
end
end
end
#
# Print a greeting.
# fish_greeting can be a function (preferred) or a variable.
#
if status --is-interactive
if functions -q fish_greeting
fish_greeting
else
# The greeting used to be skipped when fish_greeting was empty (not just undefined)
# Keep it that way to not print superfluous newlines on old configuration
test -n "$fish_greeting"
and echo $fish_greeting
end
end
#
# This event handler makes sure the prompt is repainted when
# fish_color_cwd changes value. Like all event handlers, it can't be
# autoloaded.
#
function __fish_repaint --on-variable fish_color_cwd --description "Event handler, repaints the prompt when fish_color_cwd changes"
if status --is-interactive
set -e __fish_prompt_cwd
commandline -f repaint 2>/dev/null
end
end
function __fish_repaint_root --on-variable fish_color_cwd_root --description "Event handler, repaints the prompt when fish_color_cwd_root changes"
if status --is-interactive
set -e __fish_prompt_cwd
commandline -f repaint 2>/dev/null
end
end
#
# Completions for SysV startup scripts. These aren't bound to any
# specific command, so they can't be autoloaded.
#
if test -d /etc/init.d
complete -x -p "/etc/init.d/*" -a start --description 'Start service'
complete -x -p "/etc/init.d/*" -a stop --description 'Stop service'
complete -x -p "/etc/init.d/*" -a status --description 'Print service status'
complete -x -p "/etc/init.d/*" -a restart --description 'Stop and then start service'
complete -x -p "/etc/init.d/*" -a reload --description 'Reload service configuration'
end
#
# We want to show our completions for the [ (test) builtin, but
# we don't want to create a [.fish. test.fish will not be loaded until
# the user tries [ interactively.
#
complete -c [ --wraps test
# Reload key bindings when binding variable change
function __fish_reload_key_bindings -d "Reload key bindings when binding variable change" --on-variable fish_key_bindings
# Make sure some key bindings are set
if not set -q fish_key_bindings
set -U fish_key_bindings fish_default_key_bindings
end
# Do nothing if the key bindings didn't actually change.
# This could be because the variable was set to the existing value
# or because it was a local variable.
# If fish_key_bindings is empty on the first run, we still need to set the defaults.
if test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
return
end
# Check if fish_key_bindings is a valid function.
# If not, either keep the previous bindings (if any) or revert to default.
# Also print an error so the user knows.
if not functions -q "$fish_key_bindings"
echo "There is no fish_key_bindings function called: '$fish_key_bindings'" >&2
# We need to see if this is a defined function, otherwise we'd be in an endless loop.
if functions -q $__fish_active_key_bindings
echo "Keeping $__fish_active_key_bindings" >&2
# Set the variable to the old value so this error doesn't happen again.
set fish_key_bindings $__fish_active_key_bindings
return 1
else if functions -q fish_default_key_bindings
echo "Reverting to default bindings" >&2
set fish_key_bindings fish_default_key_bindings
# Return because we are called again
return 0
else
# If we can't even find the default bindings, something is broken.
# Without it, we would eventually run into the stack size limit, but that'd print hundreds of duplicate lines
# so we should give up earlier.
echo "Cannot find fish_default_key_bindings, falling back to very simple bindings." >&2
echo "Most likely something is wrong with your installation." >&2
return 0
end
end
set -g __fish_active_key_bindings "$fish_key_bindings"
set -g fish_bind_mode default
if test "$fish_key_bindings" = fish_default_key_bindings
# Redirect stderr per #1155
fish_default_key_bindings 2>/dev/null
else
$fish_key_bindings 2>/dev/null
end
# Load user key bindings if they are defined
if functions --query fish_user_key_bindings >/dev/null
fish_user_key_bindings 2>/dev/null
end
end
# Load key bindings
__fish_reload_key_bindings
if not set -q FISH_UNIT_TESTS_RUNNING
# Enable bracketed paste before every prompt (see __fish_shared_bindings for the bindings).
# Disable it for unit tests so we don't have to add the sequences to bind.expect
function __fish_enable_bracketed_paste --on-event fish_prompt
printf "\e[?2004h"
end
# Disable BP before every command because that might not support it.
function __fish_disable_bracketed_paste --on-event fish_preexec --on-event fish_exit
printf "\e[?2004l"
end
# Tell the terminal we support BP. Since we are in __f_c_i, the first fish_prompt
# has already fired.
__fish_enable_bracketed_paste
end
function __fish_winch_handler --on-signal WINCH -d "Repaint screen when window changes size"
commandline -f repaint >/dev/null 2>/dev/null
end
# Notify terminals when $PWD changes (issue #906).
# VTE based terminals, Terminal.app, and iTerm.app support this.
set -q VTE_VERSION
or set -l VTE_VERSION 0
set -q TERM_PROGRAM
or set -l TERM_PROGRAM
if test "$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal"
function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes'
if status --is-command-substitution
or set -q INSIDE_EMACS
return
end
printf \e\]7\;file://\%s\%s\a $hostname (string escape --style=url $PWD)
end
__update_cwd_osc # Run once because we might have already inherited a PWD from an old tab
end
### Command-not-found handlers
# This can be overridden by defining a new __fish_command_not_found_handler function
if not type -q __fish_command_not_found_handler
# Read the OS/Distro from /etc/os-release.
# This has a "ID=" line that defines the exact distribution,
# and an "ID_LIKE=" line that defines what it is derived from or otherwise like.
# For our purposes, we use both.
set -l os
if test -r /etc/os-release
set os (string match -r '^ID(?:_LIKE)?\s*=.*' < /etc/os-release | \
string replace -r '^ID(?:_LIKE)?\s*=(.*)' '$1' | string trim -c '\'"' | string split " ")
end
# First check if we are on OpenSUSE since SUSE's handler has no options
# but the same name and path as Ubuntu's.
if contains -- suse $os
or contains -- sles $os
and type -q command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/bin/command-not-found $argv[1]
end
# Check for Fedora's handler
else if test -f /usr/libexec/pk-command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/libexec/pk-command-not-found $argv[1]
end
# Check in /usr/lib, this is where modern Ubuntus place this command
else if test -f /usr/lib/command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/lib/command-not-found -- $argv[1]
end
# Check for NixOS handler
else if test -f /run/current-system/sw/bin/command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/run/current-system/sw/bin/command-not-found $argv
end
# Ubuntu Feisty places this command in the regular path instead
else if type -q command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
command-not-found -- $argv[1]
end
# pkgfile is an optional, but official, package on Arch Linux
# it ships with example handlers for bash and zsh, so we'll follow that format
else if type -p -q pkgfile
function __fish_command_not_found_handler --on-event fish_command_not_found
set -l __packages (pkgfile --binaries --verbose -- $argv[1] 2>/dev/null)
if test $status -eq 0
printf "%s may be found in the following packages:\n" "$argv[1]"
printf " %s\n" $__packages
else
__fish_default_command_not_found_handler $argv[1]
end
end
# Use standard fish command not found handler otherwise
else
function __fish_command_not_found_handler --on-event fish_command_not_found
__fish_default_command_not_found_handler $argv[1]
end
end
end
...
7 1017 --> if not set -q __fish_init_3_x
# Perform transitions relevant to going from fish 2.x to 3.x.
# Migrate old universal abbreviations to the new scheme.
__fish_abbr_old | source
set -U __fish_init_3_x
...
18 18 ---> not set -q __fish_init_3_x
131 966 ---> __fish_abbr_old | source
575 591 ----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_abbr_old.fish
11 11 -----> function __fish_abbr_old --description "Manage abbreviations using old fish 2.x scheme."
# parse arguments
set -l mode
set -l mode_flag # the flag that was specified, for better errors
set -l mode_arg
set -l needs_arg no
while set -q argv[1]
set -l new_mode
switch $argv[1]
case '-h' '--help'
__fish_print_help abbr
return 0
case '-a' '--add'
set new_mode add
set needs_arg multi
case '-r' '--rename'
set new_mode rename
set needs_arg double
case '-e' '--erase'
set new_mode erase
set needs_arg single
case '-l' '--list'
set new_mode list
case '-s' '--show'
set new_mode show
case '--'
set -e argv[1]
break
case '-*'
printf ( _ "%s: invalid option -- %s\n" ) abbr $argv[1] >&2
return 1
case '*'
break
end
if test -n "$mode" -a -n "$new_mode"
# we're trying to set two different modes
printf ( _ "%s: %s cannot be specified along with %s\n" ) abbr $argv[1] $mode_flag >&2
return 1
end
set mode $new_mode
set mode_flag $argv[1]
set -e argv[1]
end
# If run with no options, treat it like --add if we have an argument, or
# --show if we do not have an argument
if not set -q mode[1]
if set -q argv[1]
set mode add
set needs_arg multi
else
set mode show
end
end
if test $needs_arg = single
set mode_arg $argv[1]
set needs_arg no
set -e argv[1]
else if test $needs_arg = double
# Pull the two parameters from argv.
# * leave argv non-empty, if there are more than two arguments
# * leave needs_arg set to double if there is not enough arguments
if set -q argv[1]
set param1 $argv[1]
set -e argv[1]
if set -q argv[1]
set param2 $argv[1]
set needs_arg no
set -e argv[1]
end
end
else if test $needs_arg = multi
set mode_arg $argv
set needs_arg no
set -e argv
end
if test $needs_arg != no
printf ( _ "%s: option requires an argument -- %s\n" ) abbr $mode_flag >&2
return 1
end
# none of our modes want any excess arguments
if set -q argv[1]
printf ( _ "%s: Unexpected argument -- %s\n" ) abbr $argv[1] >&2
return 1
end
switch $mode
case 'add'
# Convert from old "key=value" syntax
# TODO: This should be removed later
if not set -q mode_arg[2]
and string match -qr '^[^ ]+=' -- $mode_arg
set mode_arg (string split "=" -- $mode_arg)
end
# Bail out early if the exact abbr is already in
set -q fish_user_abbreviations
and contains -- "$mode_arg" $fish_user_abbreviations
and return 0
set -l key $mode_arg[1]
set -e mode_arg[1]
set -l value "$mode_arg"
# Because we later store "$key $value", there can't be any spaces in the key
if string match -q "* *" -- $key
printf ( _ "%s: abbreviation cannot have spaces in the key\n" ) abbr >&2
return 1
end
if test -z "$value"
printf ( _ "%s: abbreviation must have a value\n" ) abbr >&2
return 1
end
if set -l idx (__fish_abbr_get_by_key $key)
# erase the existing abbreviation
set -e fish_user_abbreviations[$idx]
end
if not set -q fish_user_abbreviations
# initialize as a universal variable, so we can skip the -U later
# and therefore work properly if someone sets this as a global variable
set -U fish_user_abbreviations
end
set fish_user_abbreviations $fish_user_abbreviations "$key $value"
return 0
case 'rename'
set -l old_name $param1
set -l new_name $param2
# if the target name already exists, throw an error
if set -l idx (__fish_abbr_get_by_key $new_name)
printf ( _ "%s: abbreviation '%s' already exists, cannot rename\n" ) abbr $new_name >&2
return 2
end
# Because we later store "$key $value", there can't be any spaces in the key
if string match -q "* *" -- $new_name
printf ( _ "%s: abbreviation cannot have spaces in the key\n" ) abbr >&2
return 1
end
set -l idx (__fish_abbr_get_by_key $old_name)
or begin
printf ( _ "%s: no such abbreviation '%s'\n" ) abbr $old_name >&2
return 2
end
set -l value (string split " " -m 1 -- $fish_user_abbreviations[$idx])[2]
set fish_user_abbreviations[$idx] "$new_name $value"
return 0
case 'erase'
if set -l idx (__fish_abbr_get_by_key $mode_arg)
set -e fish_user_abbreviations[$idx]
return 0
else
printf ( _ "%s: no such abbreviation '%s'\n" ) abbr $mode_arg >&2
return 2
end
case 'show'
for i in $fish_user_abbreviations
set -l opt_double_dash
set -l kv (string split " " -m 1 -- $i)
set -l key $kv[1]
set -l value $kv[2]
# Check to see if either key or value has a leading dash
# If so, we need to write --
string match -q -- '-*' $key $value
and set opt_double_dash '--'
echo abbr $opt_double_dash (string escape -- $key $value)
end
return 0
case 'list'
for i in $fish_user_abbreviations
set -l key (string split " " -m 1 -- $i)[1]
printf "%s\n" $key
end
return 0
end
...
5 5 -----> function __fish_abbr_get_by_key
if not set -q argv[1]
echo "__fish_abbr_get_by_key: expected one argument, got none" >&2
return 2
end
set -q fish_user_abbreviations
or return 1
# Going through all entries is still quicker than calling `seq`
set -l keys
for kv in $fish_user_abbreviations
# If this does not match, we have screwed up before and the error should be reported
set keys $keys (string split " " -m 1 -- $kv)[1]
end
if set -l idx (contains -i -- $argv[1] $keys)
echo $idx
return 0
end
return 1
...
19 19 ----> set -l mode
16 16 ----> set -l mode_flag
13 13 ----> set -l mode_arg
14 14 ----> set -l needs_arg no
1 14 ----> while set -q argv[1]
set -l new_mode
switch $argv[1]
case '-h' '--help'
__fish_print_help abbr
return 0
case '-a' '--add'
set new_mode add
set needs_arg multi
case '-r' '--rename'
set new_mode rename
set needs_arg double
case '-e' '--erase'
set new_mode erase
set needs_arg single
case '-l' '--list'
set new_mode list
case '-s' '--show'
set new_mode show
case '--'
set -e argv[1]
break
case '-*'
printf ( _ "%s: invalid option -- %s\n" ) abbr $argv[1] >&2
return 1
case '*'
break
end
if test -n "$mode" -a -n "$new_mode"
# we're trying to set two different modes
printf ( _ "%s: %s cannot be specified along with %s\n" ) abbr $argv[1] $mode_flag >&2
return 1
end
set mode $new_mode
set mode_flag $argv[1]
set -e argv[1]
...
13 13 -----> set -q argv[1]
7 47 ----> if not set -q mode[1]
if set -q argv[1]
set mode add
set needs_arg multi
else
set mode show
end
...
12 12 -----> not set -q mode[1]
5 28 -----> if set -q argv[1]
set mode add
set needs_arg multi
else
set mode show
...
11 11 ------> set -q argv[1]
12 12 ------> set mode show
4 51 ----> if test $needs_arg = single
set mode_arg $argv[1]
set needs_arg no
set -e argv[1]
else if test $needs_arg = double
# Pull the two parameters from argv.
# * leave argv non-empty, if there are more than two arguments
# * leave needs_arg set to double if there is not enough arguments
if set -q argv[1]
set param1 $argv[1]
set -e argv[1]
if set -q argv[1]
set param2 $argv[1]
set needs_arg no
set -e argv[1]
end
end
else if test $needs_arg = multi
set mode_arg $argv
set needs_arg no
set -e argv
...
18 18 -----> test $needs_arg = single
15 15 -----> test $needs_arg = double
14 14 -----> test $needs_arg = multi
2 16 ----> if test $needs_arg != no
printf ( _ "%s: option requires an argument -- %s\n" ) abbr $mode_flag >&2
return 1
...
14 14 -----> test $needs_arg != no
1 13 ----> if set -q argv[1]
printf ( _ "%s: Unexpected argument -- %s\n" ) abbr $argv[1] >&2
return 1
...
12 12 -----> set -q argv[1]
18 41 ----> switch $mode
case 'add'
# Convert from old "key=value" syntax
# TODO: This should be removed later
if not set -q mode_arg[2]
and string match -qr '^[^ ]+=' -- $mode_arg
set mode_arg (string split "=" -- $mode_arg)
end
# Bail out early if the exact abbr is already in
set -q fish_user_abbreviations
and contains -- "$mode_arg" $fish_user_abbreviations
and return 0
set -l key $mode_arg[1]
set -e mode_arg[1]
set -l value "$mode_arg"
# Because we later store "$key $value", there can't be any spaces in the key
if string match -q "* *" -- $key
printf ( _ "%s: abbreviation cannot have spaces in the key\n" ) abbr >&2
return 1
end
if test -z "$value"
printf ( _ "%s: abbreviation must have a value\n" ) abbr >&2
return 1
end
if set -l idx (__fish_abbr_get_by_key $key)
# erase the existing abbreviation
set -e fish_user_abbreviations[$idx]
end
if not set -q fish_user_abbreviations
# initialize as a universal variable, so we can skip the -U later
# and therefore work properly if someone sets this as a global variable
set -U fish_user_abbreviations
end
set fish_user_abbreviations $fish_user_abbreviations "$key $value"
return 0
case 'rename'
set -l old_name $param1
set -l new_name $param2
# if the target name already exists, throw an error
if set -l idx (__fish_abbr_get_by_key $new_name)
printf ( _ "%s: abbreviation '%s' already exists, cannot rename\n" ) abbr $new_name >&2
return 2
end
# Because we later store "$key $value", there can't be any spaces in the key
if string match -q "* *" -- $new_name
printf ( _ "%s: abbreviation cannot have spaces in the key\n" ) abbr >&2
return 1
end
set -l idx (__fish_abbr_get_by_key $old_name)
or begin
printf ( _ "%s: no such abbreviation '%s'\n" ) abbr $old_name >&2
return 2
end
set -l value (string split " " -m 1 -- $fish_user_abbreviations[$idx])[2]
set fish_user_abbreviations[$idx] "$new_name $value"
return 0
case 'erase'
if set -l idx (__fish_abbr_get_by_key $mode_arg)
set -e fish_user_abbreviations[$idx]
return 0
else
printf ( _ "%s: no such abbreviation '%s'\n" ) abbr $mode_arg >&2
return 2
end
case 'show'
for i in $fish_user_abbreviations
set -l opt_double_dash
set -l kv (string split " " -m 1 -- $i)
set -l key $kv[1]
set -l value $kv[2]
# Check to see if either key or value has a leading dash
# If so, we need to write --
string match -q -- '-*' $key $value
and set opt_double_dash '--'
echo abbr $opt_double_dash (string escape -- $key $value)
end
return 0
case 'list'
for i in $fish_user_abbreviations
set -l key (string split " " -m 1 -- $i)[1]
printf "%s\n" $key
end
return 0
...
10 10 -----> for i in $fish_user_abbreviations
set -l opt_double_dash
set -l kv (string split " " -m 1 -- $i)
set -l key $kv[1]
set -l value $kv[2]
# Check to see if either key or value has a leading dash
# If so, we need to write --
string match -q -- '-*' $key $value
and set opt_double_dash '--'
echo abbr $opt_double_dash (string escape -- $key $value)
...
13 13 -----> return 0
26 26 ---> set -U __fish_init_3_x
2 15 --> if set -q __fish_config_interactive_done
return
...
13 13 ---> set -q __fish_config_interactive_done
14 14 --> set -g __fish_config_interactive_done
12 12 --> set -g __fish_active_key_bindings
19 19 --> set -l userdatadir ~/.local/share
2 13 --> if set -q XDG_DATA_HOME
set userdatadir $XDG_DATA_HOME
...
11 11 ---> set -q XDG_DATA_HOME
1 12 --> if not set -q fish_greeting
set -l line1 (_ 'Welcome to fish, the friendly interactive shell')
set -l line2 ''
if not set -q __fish_init_2_3_0
set line2 \n(_ 'Type `help` for instructions on how to use fish')
end
set -U fish_greeting "$line1$line2"
...
11 11 ---> not set -q fish_greeting
2 12 --> if set -q fish_private_mode
set -l line (_ "fish is running in private mode, history will not be persisted.")
set -g fish_greeting $fish_greeting.\n$line
...
10 10 ---> set -q fish_private_mode
33 323 --> if not set -q __fish_init_2_39_8
# Regular syntax highlighting colors
set -q fish_color_normal
or set -U fish_color_normal normal
set -q fish_color_command
or set -U fish_color_command 005fd7
set -q fish_color_param
or set -U fish_color_param 00afff
set -q fish_color_redirection
or set -U fish_color_redirection 00afff
set -q fish_color_comment
or set -U fish_color_comment 990000
set -q fish_color_error
or set -U fish_color_error ff0000
set -q fish_color_escape
or set -U fish_color_escape 00a6b2
set -q fish_color_operator
or set -U fish_color_operator 00a6b2
set -q fish_color_end
or set -U fish_color_end 009900
set -q fish_color_quote
or set -U fish_color_quote 999900
set -q fish_color_autosuggestion
or set -U fish_color_autosuggestion 555 brblack
set -q fish_color_user
or set -U fish_color_user brgreen
set -q fish_color_host
or set -U fish_color_host normal
set -q fish_color_valid_path
or set -U fish_color_valid_path --underline
set -q fish_color_cwd
or set -U fish_color_cwd green
set -q fish_color_cwd_root
or set -U fish_color_cwd_root red
# Background color for matching quotes and parenthesis
set -q fish_color_match
or set -U fish_color_match --background=brblue
# Background color for search matches
set -q fish_color_search_match
or set -U fish_color_search_match bryellow --background=brblack
# Background color for selections
set -q fish_color_selection
or set -U fish_color_selection white --bold --background=brblack
set -q fish_color_cancel
or set -U fish_color_cancel -r
# Pager colors
set -q fish_pager_color_prefix
or set -U fish_pager_color_prefix white --bold --underline
set -q fish_pager_color_completion
or set -U fish_pager_color_completion
set -q fish_pager_color_description
or set -U fish_pager_color_description B3A06D yellow
set -q fish_pager_color_progress
or set -U fish_pager_color_progress brwhite --background=cyan
#
# Directory history colors
#
set -q fish_color_history_current
or set -U fish_color_history_current --bold
set -U __fish_init_2_39_8
...
11 11 ---> not set -q __fish_init_2_39_8
10 10 ---> set -q fish_color_normal
10 10 ---> set -q fish_color_command
10 10 ---> set -q fish_color_param
11 11 ---> set -q fish_color_redirection
10 10 ---> set -q fish_color_comment
10 10 ---> set -q fish_color_error
10 10 ---> set -q fish_color_escape
10 10 ---> set -q fish_color_operator
10 10 ---> set -q fish_color_end
10 10 ---> set -q fish_color_quote
11 11 ---> set -q fish_color_autosuggestion
10 10 ---> set -q fish_color_user
10 10 ---> set -q fish_color_host
11 11 ---> set -q fish_color_valid_path
10 10 ---> set -q fish_color_cwd
10 10 ---> set -q fish_color_cwd_root
10 10 ---> set -q fish_color_match
11 11 ---> set -q fish_color_search_match
11 11 ---> set -q fish_color_selection
10 10 ---> set -q fish_color_cancel
11 11 ---> set -q fish_pager_color_prefix
11 11 ---> set -q fish_pager_color_completion
11 11 ---> set -q fish_pager_color_description
10 10 ---> set -q fish_pager_color_progress
11 11 ---> set -q fish_color_history_current
20 20 ---> set -U __fish_init_2_39_8
11 49 --> if not set -q FISH_UNIT_TESTS_RUNNING
if not test -d $userdatadir/fish/generated_completions
# Generating completions from man pages needs python (see issue #3588).
# We cannot simply do `fish_update_completions &` because it is a function.
# We cannot do `eval` since it is a function.
# We don't want to call `fish -c` since that is unnecessary and sources config.fish again.
# Hence we'll call python directly.
# c_m_p.py should work with any python version.
set -l update_args -B $__fish_data_dir/tools/create_manpage_completions.py --manpath --cleanup-in '~/.config/fish/completions' --cleanup-in '~/.config/fish/generated_completions'
for py in python{3,2,}
if command -sq $py
$py $update_args >/dev/null 2>&1 &
break
end
end
end
...
12 12 ---> not set -q FISH_UNIT_TESTS_RUNNING
2 26 ---> if not test -d $userdatadir/fish/generated_completions
# Generating completions from man pages needs python (see issue #3588).
# We cannot simply do `fish_update_completions &` because it is a function.
# We cannot do `eval` since it is a function.
# We don't want to call `fish -c` since that is unnecessary and sources config.fish again.
# Hence we'll call python directly.
# c_m_p.py should work with any python version.
set -l update_args -B $__fish_data_dir/tools/create_manpage_completions.py --manpath --cleanup-in '~/.config/fish/completions' --cleanup-in '~/.config/fish/generated_completions'
for py in python{3,2,}
if command -sq $py
$py $update_args >/dev/null 2>&1 &
break
end
end
...
24 24 ----> not test -d $userdatadir/fish/generated_completions
5 84 --> if status --is-interactive
if functions -q fish_greeting
fish_greeting
else
# The greeting used to be skipped when fish_greeting was empty (not just undefined)
# Keep it that way to not print superfluous newlines on old configuration
test -n "$fish_greeting"
and echo $fish_greeting
end
...
14 14 ---> status --is-interactive
6 65 ---> if functions -q fish_greeting
fish_greeting
else
# The greeting used to be skipped when fish_greeting was empty (not just undefined)
# Keep it that way to not print superfluous newlines on old configuration
test -n "$fish_greeting"
and echo $fish_greeting
...
44 44 ----> functions -q fish_greeting
15 15 ----> test -n "$fish_greeting"
17 17 --> function __fish_repaint --on-variable fish_color_cwd --description "Event handler, repaints the prompt when fish_color_cwd changes"
if status --is-interactive
set -e __fish_prompt_cwd
commandline -f repaint 2>/dev/null
end
...
12 12 --> function __fish_repaint_root --on-variable fish_color_cwd_root --description "Event handler, repaints the prompt when fish_color_cwd_root changes"
if status --is-interactive
set -e __fish_prompt_cwd
commandline -f repaint 2>/dev/null
end
...
2 22 --> if test -d /etc/init.d
complete -x -p "/etc/init.d/*" -a start --description 'Start service'
complete -x -p "/etc/init.d/*" -a stop --description 'Stop service'
complete -x -p "/etc/init.d/*" -a status --description 'Print service status'
complete -x -p "/etc/init.d/*" -a restart --description 'Stop and then start service'
complete -x -p "/etc/init.d/*" -a reload --description 'Reload service configuration'
...
20 20 ---> test -d /etc/init.d
17 17 --> complete -c [ --wraps test
14 14 --> function __fish_reload_key_bindings -d "Reload key bindings when binding variable change" --on-variable fish_key_bindings
# Make sure some key bindings are set
if not set -q fish_key_bindings
set -U fish_key_bindings fish_default_key_bindings
end
# Do nothing if the key bindings didn't actually change.
# This could be because the variable was set to the existing value
# or because it was a local variable.
# If fish_key_bindings is empty on the first run, we still need to set the defaults.
if test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
return
end
# Check if fish_key_bindings is a valid function.
# If not, either keep the previous bindings (if any) or revert to default.
# Also print an error so the user knows.
if not functions -q "$fish_key_bindings"
echo "There is no fish_key_bindings function called: '$fish_key_bindings'" >&2
# We need to see if this is a defined function, otherwise we'd be in an endless loop.
if functions -q $__fish_active_key_bindings
echo "Keeping $__fish_active_key_bindings" >&2
# Set the variable to the old value so this error doesn't happen again.
set fish_key_bindings $__fish_active_key_bindings
return 1
else if functions -q fish_default_key_bindings
echo "Reverting to default bindings" >&2
set fish_key_bindings fish_default_key_bindings
# Return because we are called again
return 0
else
# If we can't even find the default bindings, something is broken.
# Without it, we would eventually run into the stack size limit, but that'd print hundreds of duplicate lines
# so we should give up earlier.
echo "Cannot find fish_default_key_bindings, falling back to very simple bindings." >&2
echo "Most likely something is wrong with your installation." >&2
return 0
end
end
set -g __fish_active_key_bindings "$fish_key_bindings"
set -g fish_bind_mode default
if test "$fish_key_bindings" = fish_default_key_bindings
# Redirect stderr per #1155
fish_default_key_bindings 2>/dev/null
else
$fish_key_bindings 2>/dev/null
end
# Load user key bindings if they are defined
if functions --query fish_user_key_bindings >/dev/null
fish_user_key_bindings 2>/dev/null
end
...
28 4452 --> __fish_reload_key_bindings
1 14 ---> if not set -q fish_key_bindings
set -U fish_key_bindings fish_default_key_bindings
...
13 13 ----> not set -q fish_key_bindings
1 28 ---> if test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
return
...
27 27 ----> test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
2 461 ---> if not functions -q "$fish_key_bindings"
echo "There is no fish_key_bindings function called: '$fish_key_bindings'" >&2
# We need to see if this is a defined function, otherwise we'd be in an endless loop.
if functions -q $__fish_active_key_bindings
echo "Keeping $__fish_active_key_bindings" >&2
# Set the variable to the old value so this error doesn't happen again.
set fish_key_bindings $__fish_active_key_bindings
return 1
else if functions -q fish_default_key_bindings
echo "Reverting to default bindings" >&2
set fish_key_bindings fish_default_key_bindings
# Return because we are called again
return 0
else
# If we can't even find the default bindings, something is broken.
# Without it, we would eventually run into the stack size limit, but that'd print hundreds of duplicate lines
# so we should give up earlier.
echo "Cannot find fish_default_key_bindings, falling back to very simple bindings." >&2
echo "Most likely something is wrong with your installation." >&2
return 0
end
...
99 459 ----> not functions -q "$fish_key_bindings"
350 360 -----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/fish_default_key_bindings.fish
10 10 ------> function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish"
if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
end
if not set -q argv[1]
bind --erase --all --preset # clear earlier bindings, if any
if test "$fish_key_bindings" != "fish_default_key_bindings"
# Allow the user to set the variable universally
set -q fish_key_bindings
or set -g fish_key_bindings
# This triggers the handler, which calls us again and ensures the user_key_bindings
# are executed.
set fish_key_bindings fish_default_key_bindings
return
end
end
# Silence warnings about unavailable keys. See #4431, 4188
if not contains -- -s $argv
set argv "-s" $argv
end
# These are shell-specific bindings that we share with vi mode.
__fish_shared_key_bindings $argv
or return # protect against invalid $argv
# This is the default binding, i.e. the one used if no other binding matches
bind --preset $argv "" self-insert
or exit # protect against invalid $argv
bind --preset $argv \n execute
bind --preset $argv \r execute
bind --preset $argv \ck kill-line
bind --preset $argv \eOC forward-char
bind --preset $argv \eOD backward-char
bind --preset $argv \e\[C forward-char
bind --preset $argv \e\[D backward-char
bind --preset $argv -k right forward-char
bind --preset $argv -k left backward-char
bind --preset $argv -k dc delete-char
bind --preset $argv -k backspace backward-delete-char
bind --preset $argv \x7f backward-delete-char
# for PuTTY
# https://github.com/fish-shell/fish-shell/issues/180
bind --preset $argv \e\[1~ beginning-of-line
bind --preset $argv \e\[3~ delete-char
bind --preset $argv \e\[4~ end-of-line
# OS X SnowLeopard doesn't have these keys. Don't show an annoying error message.
bind --preset $argv -k home beginning-of-line 2>/dev/null
bind --preset $argv -k end end-of-line 2>/dev/null
bind --preset $argv \e\[3\;2~ backward-delete-char # Mavericks Terminal.app shift-ctrl-delete
bind --preset $argv \ca beginning-of-line
bind --preset $argv \ce end-of-line
bind --preset $argv \ch backward-delete-char
bind --preset $argv \cp up-or-search
bind --preset $argv \cn down-or-search
bind --preset $argv \cf forward-char
bind --preset $argv \cb backward-char
bind --preset $argv \ct transpose-chars
bind --preset $argv \et transpose-words
bind --preset $argv \eu upcase-word
# This clashes with __fish_list_current_token
# bind --preset $argv \el downcase-word
bind --preset $argv \ec capitalize-word
# One of these is alt+backspace.
bind --preset $argv \e\x7f backward-kill-word
bind --preset $argv \e\b backward-kill-word
bind --preset $argv \eb backward-word
bind --preset $argv \ef forward-word
bind --preset $argv \e\[1\;5C forward-word
bind --preset $argv \e\[1\;5D backward-word
bind --preset $argv \e\< beginning-of-buffer
bind --preset $argv \e\> end-of-buffer
bind --preset $argv \ed kill-word
# Ignore some known-bad control sequences
# https://github.com/fish-shell/fish-shell/issues/1917
bind --preset $argv \e\[I 'begin;end'
bind --preset $argv \e\[O 'begin;end'
# term-specific special bindings
switch "$TERM"
case 'rxvt*'
bind --preset $argv \e\[8~ end-of-line
bind --preset $argv \eOc forward-word
bind --preset $argv \eOd backward-word
case 'xterm-256color'
# Microsoft's conemu uses xterm-256color plus
# the following to tell a console to paste:
bind --preset $argv \e\x20ep fish_clipboard_paste
end
...
25 25 ---> set -g __fish_active_key_bindings "$fish_key_bindings"
16 16 ---> set -g fish_bind_mode default
8 3820 ---> if test "$fish_key_bindings" = fish_default_key_bindings
# Redirect stderr per #1155
fish_default_key_bindings 2>/dev/null
else
$fish_key_bindings 2>/dev/null
...
19 19 ----> test "$fish_key_bindings" = fish_default_key_bindings
110 3793 ----> fish_default_key_bindings 2>/dev/null
3 34 -----> if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
...
17 17 ------> contains -- -h $argv
14 14 ------> contains -- --help $argv
6 96 -----> if not set -q argv[1]
bind --erase --all --preset # clear earlier bindings, if any
if test "$fish_key_bindings" != "fish_default_key_bindings"
# Allow the user to set the variable universally
set -q fish_key_bindings
or set -g fish_key_bindings
# This triggers the handler, which calls us again and ensures the user_key_bindings
# are executed.
set fish_key_bindings fish_default_key_bindings
return
end
...
12 12 ------> not set -q argv[1]
56 56 ------> bind --erase --all --preset
1 22 ------> if test "$fish_key_bindings" != "fish_default_key_bindings"
# Allow the user to set the variable universally
set -q fish_key_bindings
or set -g fish_key_bindings
# This triggers the handler, which calls us again and ensures the user_key_bindings
# are executed.
set fish_key_bindings fish_default_key_bindings
return
...
21 21 -------> test "$fish_key_bindings" != "fish_default_key_bindings"
4 35 -----> if not contains -- -s $argv
set argv "-s" $argv
...
15 15 ------> not contains -- -s $argv
16 16 ------> set argv "-s" $argv
172 2765 -----> __fish_shared_key_bindings $argv
550 584 ------> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_shared_key_bindings.fish
13 13 -------> function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mode"
# These are some bindings that are supposed to be shared between vi mode and default mode.
# They are supposed to be unrelated to text-editing (or movement).
# This takes $argv so the vi-bindings can pass the mode they are valid in.
if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
end
bind --preset $argv \cy yank
or return # protect against invalid $argv
bind --preset $argv \ey yank-pop
# Left/Right arrow
bind --preset $argv -k right forward-char
bind --preset $argv -k left backward-char
bind --preset $argv \e\[C forward-char
bind --preset $argv \e\[D backward-char
# Some terminals output these when they're in in keypad mode.
bind --preset $argv \eOC forward-char
bind --preset $argv \eOD backward-char
bind --preset $argv -k ppage beginning-of-history
bind --preset $argv -k npage end-of-history
# Interaction with the system clipboard.
bind --preset $argv \cx fish_clipboard_copy
bind --preset $argv \cv fish_clipboard_paste
bind --preset $argv \e cancel
bind --preset $argv \t complete
bind --preset $argv \cs pager-toggle-search
# shift-tab does a tab complete followed by a search.
bind --preset $argv --key btab complete-and-search
bind --preset $argv \e\n "commandline -i \n"
bind --preset $argv \e\r "commandline -i \n"
bind --preset $argv -k down down-or-search
bind --preset $argv -k up up-or-search
bind --preset $argv \e\[A up-or-search
bind --preset $argv \e\[B down-or-search
bind --preset $argv \eOA up-or-search
bind --preset $argv \eOB down-or-search
# Alt-left/Alt-right
bind --preset $argv \e\eOC nextd-or-forward-word
bind --preset $argv \e\eOD prevd-or-backward-word
bind --preset $argv \e\e\[C nextd-or-forward-word
bind --preset $argv \e\e\[D prevd-or-backward-word
bind --preset $argv \eO3C nextd-or-forward-word
bind --preset $argv \eO3D prevd-or-backward-word
bind --preset $argv \e\[3C nextd-or-forward-word
bind --preset $argv \e\[3D prevd-or-backward-word
bind --preset $argv \e\[1\;3C nextd-or-forward-word
bind --preset $argv \e\[1\;3D prevd-or-backward-word
bind --preset $argv \e\[1\;9C nextd-or-forward-word #iTerm2
bind --preset $argv \e\[1\;9D prevd-or-backward-word #iTerm2
# Alt-up/Alt-down
bind --preset $argv \e\eOA history-token-search-backward
bind --preset $argv \e\eOB history-token-search-forward
bind --preset $argv \e\e\[A history-token-search-backward
bind --preset $argv \e\e\[B history-token-search-forward
bind --preset $argv \eO3A history-token-search-backward
bind --preset $argv \eO3B history-token-search-forward
bind --preset $argv \e\[3A history-token-search-backward
bind --preset $argv \e\[3B history-token-search-forward
bind --preset $argv \e\[1\;3A history-token-search-backward
bind --preset $argv \e\[1\;3B history-token-search-forward
bind --preset $argv \e\[1\;9A history-token-search-backward # iTerm2
bind --preset $argv \e\[1\;9B history-token-search-forward # iTerm2
# Bash compatibility
# https://github.com/fish-shell/fish-shell/issues/89
bind --preset $argv \e. history-token-search-backward
bind --preset $argv \el __fish_list_current_token
bind --preset $argv \ew 'set tok (commandline -pt); if test $tok[1]; echo; whatis $tok[1]; commandline -f repaint; end'
# ncurses > 6.0 sends a "delete scrollback" sequence along with clear.
# This string replace removes it.
bind --preset $argv \cl 'echo -n (clear | string replace \e\[3J ""); commandline -f repaint'
bind --preset $argv \cc __fish_cancel_commandline
bind --preset $argv \cu backward-kill-line
bind --preset $argv \cw backward-kill-path-component
bind --preset $argv \e\[F end-of-line
bind --preset $argv \e\[H beginning-of-line
bind --preset $argv \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
bind --preset $argv \cd delete-or-exit
# Allow reading manpages by pressing F1 (many GUI applications) or Alt+h (like in zsh).
bind --preset $argv -k f1 __fish_man_page
bind --preset $argv \eh __fish_man_page
# This will make sure the output of the current command is paged using the default pager when
# you press Meta-p.
# If none is set, less will be used.
bind --preset $argv \ep '__fish_paginate'
# Make it easy to turn an unexecuted command into a comment in the shell history. Also,
# remove the commenting chars so the command can be further edited then executed.
bind --preset $argv \e\# __fish_toggle_comment_commandline
# The [meta-e] and [meta-v] keystrokes invoke an external editor on the command buffer.
bind --preset $argv \ee edit_command_buffer
bind --preset $argv \ev edit_command_buffer
# Support for "bracketed paste"
# The way it works is that we acknowledge our support by printing
# \e\[?2004h
# then the terminal will "bracket" every paste in
# \e\[200~ and \e\[201~
# Every character in between those two will be part of the paste and should not cause a binding to execute (like \n executing commands).
#
# We enable it after every command and disable it before (in __fish_config_interactive.fish)
#
# Support for this seems to be ubiquitous - emacs enables it unconditionally (!) since 25.1 (though it only supports it since then,
# it seems to be the last term to gain support).
# TODO: Should we disable this in older emacsen?
#
# NOTE: This is more of a "security" measure than a proper feature.
# The better way to paste remains the `fish_clipboard_paste` function (bound to \cv by default).
# We don't disable highlighting here, so it will be redone after every character (which can be slow),
# and it doesn't handle "paste-stop" sequences in the paste (which the terminal needs to strip, but KDE konsole doesn't).
#
# See http://thejh.net/misc/website-terminal-copy-paste. The second case will not be caught in KDE konsole.
# Bind the starting sequence in every bind mode, even user-defined ones.
# We usually just pass the text through as-is to facilitate pasting code,
# but when the current token contains an unbalanced single-quote (`'`),
# we escape all single-quotes and backslashes, effectively turning the paste
# into one literal token, to facilitate pasting non-code (e.g. markdown or git commitishes)
# Exclude paste mode or there'll be an additional binding after switching between emacs and vi
for mode in (bind --list-modes | string match -v paste)
bind --preset -M $mode -m paste \e\[200~ '__fish_start_bracketed_paste'
end
# This sequence ends paste-mode and returns to the previous mode we have saved before.
bind --preset -M paste \e\[201~ '__fish_stop_bracketed_paste'
# In paste-mode, everything self-inserts except for the sequence to get out of it
bind --preset -M paste "" self-insert
# Without this, a \r will overwrite the other text, rendering it invisible - which makes the exercise kinda pointless.
# TODO: Test this in windows (\r\n line endings)
bind --preset -M paste \r "commandline -i \n"
bind --preset -M paste "'" "__fish_commandline_insert_escaped \' \$__fish_paste_quoted"
bind --preset -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted"
...
12 12 -------> function __fish_commandline_insert_escaped --description 'Insert the first arg escaped if a second arg is given'
if set -q argv[2]
commandline -i \\$argv[1]
else
commandline -i $argv[1]
end
...
5 5 -------> function __fish_start_bracketed_paste
# Save the last bind mode so we can restore it.
set -g __fish_last_bind_mode $fish_bind_mode
# If the token is currently single-quoted,
# we escape single-quotes (and backslashes).
__fish_commandline_is_singlequoted
and set -g __fish_paste_quoted 1
...
4 4 -------> function __fish_stop_bracketed_paste
# Restore the last bind mode.
set fish_bind_mode $__fish_last_bind_mode
set -e __fish_paste_quoted
commandline -f force-repaint
...
2 38 ------> if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
...
20 20 -------> contains -- -h $argv
16 16 -------> contains -- --help $argv
18 18 ------> bind --preset $argv \cy yank
17 17 ------> bind --preset $argv \ey yank-pop
22 22 ------> bind --preset $argv -k right forward-char
18 18 ------> bind --preset $argv -k left backward-char
18 18 ------> bind --preset $argv \e\[C forward-char
16 16 ------> bind --preset $argv \e\[D backward-char
16 16 ------> bind --preset $argv \eOC forward-char
16 16 ------> bind --preset $argv \eOD backward-char
17 17 ------> bind --preset $argv -k ppage beginning-of-history
17 17 ------> bind --preset $argv -k npage end-of-history
17 17 ------> bind --preset $argv \cx fish_clipboard_copy
16 16 ------> bind --preset $argv \cv fish_clipboard_paste
16 16 ------> bind --preset $argv \e cancel
16 16 ------> bind --preset $argv \t complete
15 15 ------> bind --preset $argv \cs pager-toggle-search
17 17 ------> bind --preset $argv --key btab complete-and-search
18 18 ------> bind --preset $argv \e\n "commandline -i \n"
18 18 ------> bind --preset $argv \e\r "commandline -i \n"
20 20 ------> bind --preset $argv -k down down-or-search
17 17 ------> bind --preset $argv -k up up-or-search
17 17 ------> bind --preset $argv \e\[A up-or-search
17 17 ------> bind --preset $argv \e\[B down-or-search
15 15 ------> bind --preset $argv \eOA up-or-search
15 15 ------> bind --preset $argv \eOB down-or-search
17 17 ------> bind --preset $argv \e\eOC nextd-or-forward-word
16 16 ------> bind --preset $argv \e\eOD prevd-or-backward-word
17 17 ------> bind --preset $argv \e\e\[C nextd-or-forward-word
16 16 ------> bind --preset $argv \e\e\[D prevd-or-backward-word
17 17 ------> bind --preset $argv \eO3C nextd-or-forward-word
19 19 ------> bind --preset $argv \eO3D prevd-or-backward-word
17 17 ------> bind --preset $argv \e\[3C nextd-or-forward-word
17 17 ------> bind --preset $argv \e\[3D prevd-or-backward-word
17 17 ------> bind --preset $argv \e\[1\;3C nextd-or-forward-word
17 17 ------> bind --preset $argv \e\[1\;3D prevd-or-backward-word
17 17 ------> bind --preset $argv \e\[1\;9C nextd-or-forward-word
18 18 ------> bind --preset $argv \e\[1\;9D prevd-or-backward-word
17 17 ------> bind --preset $argv \e\eOA history-token-search-backward
17 17 ------> bind --preset $argv \e\eOB history-token-search-forward
18 18 ------> bind --preset $argv \e\e\[A history-token-search-backward
17 17 ------> bind --preset $argv \e\e\[B history-token-search-forward
16 16 ------> bind --preset $argv \eO3A history-token-search-backward
17 17 ------> bind --preset $argv \eO3B history-token-search-forward
17 17 ------> bind --preset $argv \e\[3A history-token-search-backward
17 17 ------> bind --preset $argv \e\[3B history-token-search-forward
17 17 ------> bind --preset $argv \e\[1\;3A history-token-search-backward
17 17 ------> bind --preset $argv \e\[1\;3B history-token-search-forward
19 19 ------> bind --preset $argv \e\[1\;9A history-token-search-backward
18 18 ------> bind --preset $argv \e\[1\;9B history-token-search-forward
17 17 ------> bind --preset $argv \e. history-token-search-backward
16 16 ------> bind --preset $argv \el __fish_list_current_token
20 20 ------> bind --preset $argv \ew 'set tok (commandline -pt); if test $tok[1]; echo; whatis $tok[1]; commandline -f repaint; end'
19 19 ------> bind --preset $argv \cl 'echo -n (clear | string replace \e\[3J ""); commandline -f repaint'
16 16 ------> bind --preset $argv \cc __fish_cancel_commandline
17 17 ------> bind --preset $argv \cu backward-kill-line
16 16 ------> bind --preset $argv \cw backward-kill-path-component
18 18 ------> bind --preset $argv \e\[F end-of-line
17 17 ------> bind --preset $argv \e\[H beginning-of-line
21 21 ------> bind --preset $argv \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
17 17 ------> bind --preset $argv \cd delete-or-exit
18 18 ------> bind --preset $argv -k f1 __fish_man_page
17 17 ------> bind --preset $argv \eh __fish_man_page
17 17 ------> bind --preset $argv \ep '__fish_paginate'
17 17 ------> bind --preset $argv \e\# __fish_toggle_comment_commandline
17 17 ------> bind --preset $argv \ee edit_command_buffer
16 16 ------> bind --preset $argv \ev edit_command_buffer
73 750 ------> for mode in (bind --list-modes | string match -v paste)
bind --preset -M $mode -m paste \e\[200~ '__fish_start_bracketed_paste'
...
636 636 -------> bind --list-modes | string match -v paste
41 41 -------> bind --preset -M $mode -m paste \e\[200~ '__fish_start_bracketed_paste'
24 24 ------> bind --preset -M paste \e\[201~ '__fish_stop_bracketed_paste'
17 17 ------> bind --preset -M paste "" self-insert
25 25 ------> bind --preset -M paste \r "commandline -i \n"
20 20 ------> bind --preset -M paste "'" "__fish_commandline_insert_escaped \' \$__fish_paste_quoted"
18 18 ------> bind --preset -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted"
18 18 -----> bind --preset $argv "" self-insert
17 17 -----> bind --preset $argv \n execute
18 18 -----> bind --preset $argv \r execute
17 17 -----> bind --preset $argv \ck kill-line
17 17 -----> bind --preset $argv \eOC forward-char
16 16 -----> bind --preset $argv \eOD backward-char
17 17 -----> bind --preset $argv \e\[C forward-char
16 16 -----> bind --preset $argv \e\[D backward-char
17 17 -----> bind --preset $argv -k right forward-char
17 17 -----> bind --preset $argv -k left backward-char
19 19 -----> bind --preset $argv -k dc delete-char
18 18 -----> bind --preset $argv -k backspace backward-delete-char
17 17 -----> bind --preset $argv \x7f backward-delete-char
18 18 -----> bind --preset $argv \e\[1~ beginning-of-line
15 15 -----> bind --preset $argv \e\[3~ delete-char
18 18 -----> bind --preset $argv \e\[4~ end-of-line
24 24 -----> bind --preset $argv -k home beginning-of-line 2>/dev/null
20 20 -----> bind --preset $argv -k end end-of-line 2>/dev/null
20 20 -----> bind --preset $argv \e\[3\;2~ backward-delete-char
16 16 -----> bind --preset $argv \ca beginning-of-line
16 16 -----> bind --preset $argv \ce end-of-line
16 16 -----> bind --preset $argv \ch backward-delete-char
16 16 -----> bind --preset $argv \cp up-or-search
17 17 -----> bind --preset $argv \cn down-or-search
16 16 -----> bind --preset $argv \cf forward-char
16 16 -----> bind --preset $argv \cb backward-char
16 16 -----> bind --preset $argv \ct transpose-chars
17 17 -----> bind --preset $argv \et transpose-words
17 17 -----> bind --preset $argv \eu upcase-word
17 17 -----> bind --preset $argv \ec capitalize-word
18 18 -----> bind --preset $argv \e\x7f backward-kill-word
17 17 -----> bind --preset $argv \e\b backward-kill-word
17 17 -----> bind --preset $argv \eb backward-word
17 17 -----> bind --preset $argv \ef forward-word
19 19 -----> bind --preset $argv \e\[1\;5C forward-word
19 19 -----> bind --preset $argv \e\[1\;5D backward-word
17 17 -----> bind --preset $argv \e\< beginning-of-buffer
19 19 -----> bind --preset $argv \e\> end-of-buffer
16 16 -----> bind --preset $argv \ed kill-word
20 20 -----> bind --preset $argv \e\[I 'begin;end'
19 19 -----> bind --preset $argv \e\[O 'begin;end'
17 36 -----> switch "$TERM"
case 'rxvt*'
bind --preset $argv \e\[8~ end-of-line
bind --preset $argv \eOc forward-word
bind --preset $argv \eOd backward-word
case 'xterm-256color'
# Microsoft's conemu uses xterm-256color plus
# the following to tell a console to paste:
bind --preset $argv \e\x20ep fish_clipboard_paste
...
19 19 ------> bind --preset $argv \e\x20ep fish_clipboard_paste
3 60 ---> if functions --query fish_user_key_bindings >/dev/null
fish_user_key_bindings 2>/dev/null
...
57 57 ----> functions --query fish_user_key_bindings >/dev/null
5 113 --> if not set -q FISH_UNIT_TESTS_RUNNING
# Enable bracketed paste before every prompt (see __fish_shared_bindings for the bindings).
# Disable it for unit tests so we don't have to add the sequences to bind.expect
function __fish_enable_bracketed_paste --on-event fish_prompt
printf "\e[?2004h"
end
# Disable BP before every command because that might not support it.
function __fish_disable_bracketed_paste --on-event fish_preexec --on-event fish_exit
printf "\e[?2004l"
end
# Tell the terminal we support BP. Since we are in __f_c_i, the first fish_prompt
# has already fired.
__fish_enable_bracketed_paste
...
16 16 ---> not set -q FISH_UNIT_TESTS_RUNNING
10 10 ---> function __fish_enable_bracketed_paste --on-event fish_prompt
printf "\e[?2004h"
...
12 12 ---> function __fish_disable_bracketed_paste --on-event fish_preexec --on-event fish_exit
printf "\e[?2004l"
...
19 70 ---> __fish_enable_bracketed_paste
51 51 ----> printf "\e[?2004h"
13 13 --> function __fish_winch_handler --on-signal WINCH -d "Repaint screen when window changes size"
commandline -f repaint >/dev/null 2>/dev/null
...
13 13 --> set -q VTE_VERSION
14 14 --> set -l VTE_VERSION 0
12 12 --> set -q TERM_PROGRAM
2 36 --> if test "$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal"
function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes'
if status --is-command-substitution
or set -q INSIDE_EMACS
return
end
printf \e\]7\;file://\%s\%s\a $hostname (string escape --style=url $PWD)
end
__update_cwd_osc # Run once because we might have already inherited a PWD from an old tab
...
34 34 ---> test "$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal"
12 2463 --> if not type -q __fish_command_not_found_handler
# Read the OS/Distro from /etc/os-release.
# This has a "ID=" line that defines the exact distribution,
# and an "ID_LIKE=" line that defines what it is derived from or otherwise like.
# For our purposes, we use both.
set -l os
if test -r /etc/os-release
set os (string match -r '^ID(?:_LIKE)?\s*=.*' < /etc/os-release | \
string replace -r '^ID(?:_LIKE)?\s*=(.*)' '$1' | string trim -c '\'"' | string split " ")
end
# First check if we are on OpenSUSE since SUSE's handler has no options
# but the same name and path as Ubuntu's.
if contains -- suse $os
or contains -- sles $os
and type -q command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/bin/command-not-found $argv[1]
end
# Check for Fedora's handler
else if test -f /usr/libexec/pk-command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/libexec/pk-command-not-found $argv[1]
end
# Check in /usr/lib, this is where modern Ubuntus place this command
else if test -f /usr/lib/command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/lib/command-not-found -- $argv[1]
end
# Check for NixOS handler
else if test -f /run/current-system/sw/bin/command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/run/current-system/sw/bin/command-not-found $argv
end
# Ubuntu Feisty places this command in the regular path instead
else if type -q command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
command-not-found -- $argv[1]
end
# pkgfile is an optional, but official, package on Arch Linux
# it ships with example handlers for bash and zsh, so we'll follow that format
else if type -p -q pkgfile
function __fish_command_not_found_handler --on-event fish_command_not_found
set -l __packages (pkgfile --binaries --verbose -- $argv[1] 2>/dev/null)
if test $status -eq 0
printf "%s may be found in the following packages:\n" "$argv[1]"
printf " %s\n" $__packages
else
__fish_default_command_not_found_handler $argv[1]
end
end
# Use standard fish command not found handler otherwise
else
function __fish_command_not_found_handler --on-event fish_command_not_found
__fish_default_command_not_found_handler $argv[1]
end
end
...
114 1069 ---> not type -q __fish_command_not_found_handler
326 337 ----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/type.fish
11 11 -----> function type --description 'Print the type of a command'
# For legacy reasons, no argument simply causes an unsuccessful return.
set -q argv[1]
or return 1
set -l options 'h/help' 'a/all' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
argparse -n type -x t,p,P $options -- $argv
or return
if set -q _flag_help
__fish_print_help type
return 0
end
set -l res 1
set -l mode normal
set -l multi no
set -l selection all
# Technically all four of these flags are mutually exclusive. However, we allow -q to be used
# with the other three because old versions of this function explicitly allowed it by making
# --quiet have precedence.
if set -q _flag_quiet
set mode quiet
else if set -q _flag_type
set mode type
else if set -q _flag_path
set mode path
else if set -q _flag_force_path
set mode path
set selection files
end
set -q _flag_all
and set multi yes
set -q _flag_no_functions
and set selection files
# Check all possible types for the remaining arguments.
for i in $argv
# Found will be set to 1 if a match is found.
set -l found 0
if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
end
set -l paths
if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
end
for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
end
if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
end
return $res
...
17 17 ----> set -q argv[1]
29 29 ----> set -l options 'h/help' 'a/all' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
48 48 ----> argparse -n type -x t,p,P $options -- $argv
2 15 ----> if set -q _flag_help
__fish_print_help type
return 0
...
13 13 -----> set -q _flag_help
12 12 ----> set -l res 1
12 12 ----> set -l mode normal
12 12 ----> set -l multi no
12 12 ----> set -l selection all
6 28 ----> if set -q _flag_quiet
set mode quiet
else if set -q _flag_type
set mode type
else if set -q _flag_path
set mode path
else if set -q _flag_force_path
set mode path
set selection files
...
10 10 -----> set -q _flag_quiet
12 12 -----> set mode quiet
11 11 ----> set -q _flag_all
10 10 ----> set -q _flag_no_functions
16 398 ----> for i in $argv
# Found will be set to 1 if a match is found.
set -l found 0
if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
end
set -l paths
if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
end
for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
end
if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
13 13 -----> set -l found 0
5 202 -----> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
...
15 15 ------> test $selection != files
1 49 ------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
...
48 48 -------> functions -q -- $i
3 133 ------> if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
...
98 130 -------> contains -- $i (builtin -n)
32 32 --------> builtin -n
14 14 -----> set -l paths
6 112 -----> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
15 15 ------> test $multi != yes
31 91 ------> set paths (command -s -- $i)
60 60 -------> command -s -- $i
8 8 -----> for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
...
3 33 -----> if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
15 15 ------> test $found = 0
15 15 ------> test $mode != quiet
14 14 ----> return $res
12 12 ---> set -l os
1 21 ---> if test -r /etc/os-release
set os (string match -r '^ID(?:_LIKE)?\s*=.*' < /etc/os-release | \
string replace -r '^ID(?:_LIKE)?\s*=(.*)' '$1' | string trim -c '\'"' | string split " ")
...
20 20 ----> test -r /etc/os-release
14 1349 ---> if contains -- suse $os
or contains -- sles $os
and type -q command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/bin/command-not-found $argv[1]
end
# Check for Fedora's handler
else if test -f /usr/libexec/pk-command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/libexec/pk-command-not-found $argv[1]
end
# Check in /usr/lib, this is where modern Ubuntus place this command
else if test -f /usr/lib/command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/lib/command-not-found -- $argv[1]
end
# Check for NixOS handler
else if test -f /run/current-system/sw/bin/command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
/run/current-system/sw/bin/command-not-found $argv
end
# Ubuntu Feisty places this command in the regular path instead
else if type -q command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found
command-not-found -- $argv[1]
end
# pkgfile is an optional, but official, package on Arch Linux
# it ships with example handlers for bash and zsh, so we'll follow that format
else if type -p -q pkgfile
function __fish_command_not_found_handler --on-event fish_command_not_found
set -l __packages (pkgfile --binaries --verbose -- $argv[1] 2>/dev/null)
if test $status -eq 0
printf "%s may be found in the following packages:\n" "$argv[1]"
printf " %s\n" $__packages
else
__fish_default_command_not_found_handler $argv[1]
end
end
# Use standard fish command not found handler otherwise
else
function __fish_command_not_found_handler --on-event fish_command_not_found
__fish_default_command_not_found_handler $argv[1]
end
...
15 15 ----> contains -- suse $os
12 12 ----> contains -- sles $os
14 14 ----> test -f /usr/libexec/pk-command-not-found
13 13 ----> test -f /usr/lib/command-not-found
13 13 ----> test -f /run/current-system/sw/bin/command-not-found
36 632 ----> type -q command-not-found
12 12 -----> set -q argv[1]
27 27 -----> set -l options 'h/help' 'a/all' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
45 45 -----> argparse -n type -x t,p,P $options -- $argv
3 14 -----> if set -q _flag_help
__fish_print_help type
return 0
...
11 11 ------> set -q _flag_help
12 12 -----> set -l res 1
12 12 -----> set -l mode normal
12 12 -----> set -l multi no
12 12 -----> set -l selection all
4 27 -----> if set -q _flag_quiet
set mode quiet
else if set -q _flag_type
set mode type
else if set -q _flag_path
set mode path
else if set -q _flag_force_path
set mode path
set selection files
...
11 11 ------> set -q _flag_quiet
12 12 ------> set mode quiet
11 11 -----> set -q _flag_all
10 10 -----> set -q _flag_no_functions
20 389 -----> for i in $argv
# Found will be set to 1 if a match is found.
set -l found 0
if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
end
set -l paths
if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
end
for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
end
if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
12 12 ------> set -l found 0
5 199 ------> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
...
15 15 -------> test $selection != files
2 50 -------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
...
48 48 --------> functions -q -- $i
1 129 -------> if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
...
97 128 --------> contains -- $i (builtin -n)
31 31 ---------> builtin -n
14 14 ------> set -l paths
4 104 ------> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
15 15 -------> test $multi != yes
32 85 -------> set paths (command -s -- $i)
53 53 --------> command -s -- $i
8 8 ------> for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
...
2 32 ------> if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
15 15 -------> test $found = 0
15 15 -------> test $mode != quiet
13 13 -----> return $res
35 627 ----> type -p -q pkgfile
12 12 -----> set -q argv[1]
27 27 -----> set -l options 'h/help' 'a/all' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
48 48 -----> argparse -n type -x t,p,P $options -- $argv
2 14 -----> if set -q _flag_help
__fish_print_help type
return 0
...
12 12 ------> set -q _flag_help
11 11 -----> set -l res 1
12 12 -----> set -l mode normal
12 12 -----> set -l multi no
12 12 -----> set -l selection all
5 27 -----> if set -q _flag_quiet
set mode quiet
else if set -q _flag_type
set mode type
else if set -q _flag_path
set mode path
else if set -q _flag_force_path
set mode path
set selection files
...
11 11 ------> set -q _flag_quiet
11 11 ------> set mode quiet
11 11 -----> set -q _flag_all
10 10 -----> set -q _flag_no_functions
19 383 -----> for i in $argv
# Found will be set to 1 if a match is found.
set -l found 0
if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
end
set -l paths
if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
end
for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
end
if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
12 12 ------> set -l found 0
5 199 ------> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
...
15 15 -------> test $selection != files
1 46 -------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
...
45 45 --------> functions -q -- $i
1 133 -------> if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
...
101 132 --------> contains -- $i (builtin -n)
31 31 ---------> builtin -n
14 14 ------> set -l paths
4 101 ------> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
15 15 -------> test $multi != yes
32 82 -------> set paths (command -s -- $i)
50 50 --------> command -s -- $i
7 7 ------> for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
...
2 31 ------> if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
15 15 -------> test $found = 0
14 14 -------> test $mode != quiet
13 13 -----> return $res
9 9 ----> function __fish_command_not_found_handler --on-event fish_command_not_found
__fish_default_command_not_found_handler $argv[1]
...
22 22 -> functions -e __fish_on_interactive
306 317 > source /Users/austin/.config/fish/functions/fish_prompt.fish
11 11 -> function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
end
if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
end
if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch magenta --bold
end
if not set -q __fish_git_prompt_showupstream
set -g __fish_git_prompt_showupstream "informative"
end
if not set -q __fish_git_prompt_char_upstream_ahead
set -g __fish_git_prompt_char_upstream_ahead "↑"
end
if not set -q __fish_git_prompt_char_upstream_behind
set -g __fish_git_prompt_char_upstream_behind "↓"
end
if not set -q __fish_git_prompt_char_upstream_prefix
set -g __fish_git_prompt_char_upstream_prefix ""
end
if not set -q __fish_git_prompt_char_stagedstate
set -g __fish_git_prompt_char_stagedstate "●"
end
if not set -q __fish_git_prompt_char_dirtystate
set -g __fish_git_prompt_char_dirtystate "✚"
end
if not set -q __fish_git_prompt_char_untrackedfiles
set -g __fish_git_prompt_char_untrackedfiles "…"
end
if not set -q __fish_git_prompt_char_invalidstate
set -g __fish_git_prompt_char_invalidstate "✖"
end
if not set -q __fish_git_prompt_char_cleanstate
set -g __fish_git_prompt_char_cleanstate "✔"
end
if not set -q __fish_git_prompt_color_dirtystate
set -g __fish_git_prompt_color_dirtystate blue
end
if not set -q __fish_git_prompt_color_stagedstate
set -g __fish_git_prompt_color_stagedstate yellow
end
if not set -q __fish_git_prompt_color_invalidstate
set -g __fish_git_prompt_color_invalidstate red
end
if not set -q __fish_git_prompt_color_untrackedfiles
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
end
if not set -q __fish_git_prompt_color_cleanstate
set -g __fish_git_prompt_color_cleanstate green --bold
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
set -l color_cwd
set -l prefix
set -l suffix
switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
case '*'
set color_cwd $fish_color_cwd
set suffix '$'
end
# PWD
set_color $color_cwd
echo -n (prompt_pwd)
set_color normal
if set -q VIRTUAL_ENV
echo -n " ("(basename "$VIRTUAL_ENV")")"
end
printf '%s ' (__fish_vcs_prompt)
if not test $last_status -eq 0
set_color $fish_color_error
echo -n "[$last_status] "
set_color normal
end
echo
echo -n "$suffix "
...
65 75 > source /usr/local/Cellar/fish/3.0.2/share/fish/functions/fish_mode_prompt.fish
10 10 -> function fish_mode_prompt --description "Displays the current mode"
# To reuse the mode indicator use this function instead
fish_default_mode_prompt
...
14 261 > fish_mode_prompt
76 247 -> fish_default_mode_prompt
114 124 --> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/fish_default_mode_prompt.fish
10 10 ---> function fish_default_mode_prompt --description "Display the default mode for the prompt"
# Do nothing if not in vi mode
if test "$fish_key_bindings" = "fish_vi_key_bindings"
or test "$fish_key_bindings" = "fish_hybrid_key_bindings"
switch $fish_bind_mode
case default
set_color --bold --background red white
echo '[N]'
case insert
set_color --bold --background green white
echo '[I]'
case replace_one
set_color --bold --background green white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
end
...
3 47 --> if test "$fish_key_bindings" = "fish_vi_key_bindings"
or test "$fish_key_bindings" = "fish_hybrid_key_bindings"
switch $fish_bind_mode
case default
set_color --bold --background red white
echo '[N]'
case insert
set_color --bold --background green white
echo '[I]'
case replace_one
set_color --bold --background green white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
...
24 24 ---> test "$fish_key_bindings" = "fish_vi_key_bindings"
20 20 ---> test "$fish_key_bindings" = "fish_hybrid_key_bindings"
59 80150 > fish_prompt
19 19 -> set -l last_status $status
6 35 -> if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
...
13 13 --> not set -q __fish_git_prompt_show_informative_status
16 16 --> set -g __fish_git_prompt_show_informative_status 1
5 32 -> if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
...
13 13 --> not set -q __fish_git_prompt_hide_untrackedfiles
14 14 --> set -g __fish_git_prompt_hide_untrackedfiles 1
4 32 -> if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch magenta --bold
...
13 13 --> not set -q __fish_git_prompt_color_branch
15 15 --> set -g __fish_git_prompt_color_branch magenta --bold
4 32 -> if not set -q __fish_git_prompt_showupstream
set -g __fish_git_prompt_showupstream "informative"
...
12 12 --> not set -q __fish_git_prompt_showupstream
16 16 --> set -g __fish_git_prompt_showupstream "informative"
4 33 -> if not set -q __fish_git_prompt_char_upstream_ahead
set -g __fish_git_prompt_char_upstream_ahead "↑"
...
12 12 --> not set -q __fish_git_prompt_char_upstream_ahead
17 17 --> set -g __fish_git_prompt_char_upstream_ahead "↑"
4 31 -> if not set -q __fish_git_prompt_char_upstream_behind
set -g __fish_git_prompt_char_upstream_behind "↓"
...
12 12 --> not set -q __fish_git_prompt_char_upstream_behind
15 15 --> set -g __fish_git_prompt_char_upstream_behind "↓"
4 30 -> if not set -q __fish_git_prompt_char_upstream_prefix
set -g __fish_git_prompt_char_upstream_prefix ""
...
11 11 --> not set -q __fish_git_prompt_char_upstream_prefix
15 15 --> set -g __fish_git_prompt_char_upstream_prefix ""
4 31 -> if not set -q __fish_git_prompt_char_stagedstate
set -g __fish_git_prompt_char_stagedstate "●"
...
13 13 --> not set -q __fish_git_prompt_char_stagedstate
14 14 --> set -g __fish_git_prompt_char_stagedstate "●"
4 30 -> if not set -q __fish_git_prompt_char_dirtystate
set -g __fish_git_prompt_char_dirtystate "✚"
...
12 12 --> not set -q __fish_git_prompt_char_dirtystate
14 14 --> set -g __fish_git_prompt_char_dirtystate "✚"
4 32 -> if not set -q __fish_git_prompt_char_untrackedfiles
set -g __fish_git_prompt_char_untrackedfiles "…"
...
12 12 --> not set -q __fish_git_prompt_char_untrackedfiles
16 16 --> set -g __fish_git_prompt_char_untrackedfiles "…"
4 30 -> if not set -q __fish_git_prompt_char_invalidstate
set -g __fish_git_prompt_char_invalidstate "✖"
...
12 12 --> not set -q __fish_git_prompt_char_invalidstate
14 14 --> set -g __fish_git_prompt_char_invalidstate "✖"
4 31 -> if not set -q __fish_git_prompt_char_cleanstate
set -g __fish_git_prompt_char_cleanstate "✔"
...
11 11 --> not set -q __fish_git_prompt_char_cleanstate
16 16 --> set -g __fish_git_prompt_char_cleanstate "✔"
4 30 -> if not set -q __fish_git_prompt_color_dirtystate
set -g __fish_git_prompt_color_dirtystate blue
...
13 13 --> not set -q __fish_git_prompt_color_dirtystate
13 13 --> set -g __fish_git_prompt_color_dirtystate blue
4 29 -> if not set -q __fish_git_prompt_color_stagedstate
set -g __fish_git_prompt_color_stagedstate yellow
...
12 12 --> not set -q __fish_git_prompt_color_stagedstate
13 13 --> set -g __fish_git_prompt_color_stagedstate yellow
4 30 -> if not set -q __fish_git_prompt_color_invalidstate
set -g __fish_git_prompt_color_invalidstate red
...
12 12 --> not set -q __fish_git_prompt_color_invalidstate
14 14 --> set -g __fish_git_prompt_color_invalidstate red
4 34 -> if not set -q __fish_git_prompt_color_untrackedfiles
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
...
12 12 --> not set -q __fish_git_prompt_color_untrackedfiles
18 18 --> set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
3 30 -> if not set -q __fish_git_prompt_color_cleanstate
set -g __fish_git_prompt_color_cleanstate green --bold
...
12 12 --> not set -q __fish_git_prompt_color_cleanstate
15 15 --> set -g __fish_git_prompt_color_cleanstate green --bold
4 117 -> if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
...
12 12 --> not set -q __fish_prompt_normal
39 101 --> set -g __fish_prompt_normal (set_color normal)
62 62 ---> set_color normal
14 14 -> set -l color_cwd
13 13 -> set -l prefix
12 12 -> set -l suffix
13 44 -> switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
case '*'
set color_cwd $fish_color_cwd
set suffix '$'
...
17 17 --> set color_cwd $fish_color_cwd
14 14 --> set suffix '$'
22 22 -> set_color $color_cwd
38 517 -> echo -n (prompt_pwd)
90 479 --> prompt_pwd
129 141 ---> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/prompt_pwd.fish
12 12 ----> function prompt_pwd --description "Print the current working directory, shortened to fit the prompt"
set -l options 'h/help'
argparse -n prompt_pwd --max-args=0 $options -- $argv
or return
if set -q _flag_help
__fish_print_help prompt_pwd
return 0
end
# This allows overriding fish_prompt_pwd_dir_length from the outside (global or universal) without leaking it
set -q fish_prompt_pwd_dir_length
or set -l fish_prompt_pwd_dir_length 1
# Replace $HOME with "~"
set realhome ~
set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)
if [ $fish_prompt_pwd_dir_length -eq 0 ]
echo $tmp
else
# Shorten to at most $fish_prompt_pwd_dir_length characters per directory
string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
end
...
19 19 ---> set -l options 'h/help'
24 24 ---> argparse -n prompt_pwd --max-args=0 $options -- $argv
2 15 ---> if set -q _flag_help
__fish_print_help prompt_pwd
return 0
...
13 13 ----> set -q _flag_help
12 12 ---> set -q fish_prompt_pwd_dir_length
14 14 ---> set -l fish_prompt_pwd_dir_length 1
19 19 ---> set realhome ~
39 88 ---> set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)
49 49 ----> string replace -r '^'"$realhome"'($|/)' '~$1' $PWD
6 57 ---> if [ $fish_prompt_pwd_dir_length -eq 0 ]
echo $tmp
else
# Shorten to at most $fish_prompt_pwd_dir_length characters per directory
string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
...
18 18 ----> [ $fish_prompt_pwd_dir_length -eq 0 ]
33 33 ----> string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
21 21 -> set_color normal
4 1115 -> if set -q VIRTUAL_ENV
echo -n " ("(basename "$VIRTUAL_ENV")")"
...
14 14 --> set -q VIRTUAL_ENV
48 1097 --> echo -n " ("(basename "$VIRTUAL_ENV")")"
1049 1049 ---> basename "$VIRTUAL_ENV"
64 77614 -> printf '%s ' (__fish_vcs_prompt)
98 77550 --> __fish_vcs_prompt
69 80 ---> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_vcs_prompt.fish
11 11 ----> function __fish_vcs_prompt --description "Print the prompts for all available vcsen"
__fish_git_prompt
__fish_hg_prompt
__fish_svn_prompt
...
168 64959 ---> __fish_git_prompt
2037 3468 ----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_git_prompt.fish
12 12 -----> function __fish_git_prompt_show_upstream --description "Helper function for __fish_git_prompt"
set -q __fish_git_prompt_showupstream
or set -l __fish_git_prompt_showupstream
set -l show_upstream $__fish_git_prompt_showupstream
set -l svn_prefix # For better SVN upstream information
set -l informative
set -l svn_url_pattern
set -l count
set -l upstream git
set -l verbose
set -l name
# Default to informative if __fish_git_prompt_show_informative_status is set
if set -q __fish_git_prompt_show_informative_status
set informative 1
end
set -l svn_remote
# get some config options from git-config
command git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | while read -lz key value
switch $key
case bash.showupstream
set show_upstream $value
test -n "$show_upstream"
or return
case svn-remote.'*'.url
set svn_remote $svn_remote $value
# Avoid adding \| to the beginning to avoid needing #?? later
if test -n "$svn_url_pattern"
set svn_url_pattern $svn_url_pattern"|$value"
else
set svn_url_pattern $value
end
set upstream svn+git # default upstream is SVN if available, else git
# Save the config key (without .url) for later use
set -l remote_prefix (string replace -r '\.url$' '' -- $key)
set svn_prefix $svn_prefix $remote_prefix
end
end
# parse configuration variables
# and clear informative default when needed
for option in $show_upstream
switch $option
case git svn
set upstream $option
set -e informative
case verbose
set verbose 1
set -e informative
case informative
set informative 1
case name
set name 1
case none
return
end
end
# Find our upstream
switch $upstream
case git
set upstream '@{upstream}'
case svn\*
# get the upstream from the 'git-svn-id: …' in a commit message
# (git-svn uses essentially the same procedure internally)
set -l svn_upstream (git log --first-parent -1 --grep="^git-svn-id: \($svn_url_pattern\)" 2>/dev/null)
if test (count $svn_upstream) -ne 0
echo $svn_upstream[-1] | read -l __ svn_upstream __
set svn_upstream (string replace -r '@.*' '' -- $svn_upstream)
set -l cur_prefix
for i in (seq (count $svn_remote))
set -l remote $svn_remote[$i]
set -l mod_upstream (string replace "$remote" "" -- $svn_upstream)
if test "$svn_upstream" != "$mod_upstream"
# we found a valid remote
set svn_upstream $mod_upstream
set cur_prefix $svn_prefix[$i]
break
end
end
if test -z "$svn_upstream"
# default branch name for checkouts with no layout:
if test -n "$GIT_SVN_ID"
set upstream $GIT_SVN_ID
else
set upstream git-svn
end
else
set upstream (string replace '/branches' '' -- $svn_upstream | string replace -a '/' '')
# Use fetch config to fix upstream
set -l fetch_val (command git config "$cur_prefix".fetch)
if test -n "$fetch_val"
string split -m1 : -- "$fetch_val" | read -l trunk pattern
set upstream (string replace -r -- "/$trunk\$" '' $pattern) /$upstream
end
end
else if test $upstream = svn+git
set upstream '@{upstream}'
end
end
# Find how many commits we are ahead/behind our upstream
set count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
# calculate the result
if test -n "$verbose"
# Verbose has a space by default
set -l prefix "$___fish_git_prompt_char_upstream_prefix"
# Using two underscore version to check if user explicitly set to nothing
if not set -q __fish_git_prompt_char_upstream_prefix
set -l prefix " "
end
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
end
if test -n "$count" -a -n "$name"
echo " "(command git rev-parse --abbrev-ref "$upstream" 2>/dev/null)
end
else if test -n "$informative"
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
end
else
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged"
end
end
...
8 8 -----> function __fish_git_prompt --description "Prompt function for Git"
# If git isn't installed, there's nothing we can do
# Return 1 so the calling prompt can deal with it
if not command -sq git
return 1
end
set -l repo_info (command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null)
test -n "$repo_info"
or return
set -l git_dir $repo_info[1]
set -l inside_gitdir $repo_info[2]
set -l bare_repo $repo_info[3]
set -l inside_worktree $repo_info[4]
set -q repo_info[5]
and set -l sha $repo_info[5]
set -l rbc (__fish_git_prompt_operation_branch_bare $repo_info)
set -l r $rbc[1] # current operation
set -l b $rbc[2] # current branch
set -l detached $rbc[3]
set -l w #dirty working directory
set -l i #staged changes
set -l s #stashes
set -l u #untracked
set -l c $rbc[4] # bare repository
set -l p #upstream
set -l informative_status
if not set -q ___fish_git_prompt_init
# This takes a while, so it only needs to be done once,
# and then whenever the configuration changes.
__fish_git_prompt_validate_chars
__fish_git_prompt_validate_colors
set -g ___fish_git_prompt_init
end
set -l space "$___fish_git_prompt_color$___fish_git_prompt_char_stateseparator$___fish_git_prompt_color_done"
if test "true" = $inside_worktree
if set -q __fish_git_prompt_show_informative_status
set informative_status "$space"(__fish_git_prompt_informative_status)
else
if set -q __fish_git_prompt_showdirtystate
set -l config (command git config --bool bash.showDirtyState)
if test "$config" != "false"
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false
set u (__fish_git_prompt_untracked)
end
end
end
if set -q __fish_git_prompt_showupstream
or set -q __fish_git_prompt_show_informative_status
set p (__fish_git_prompt_show_upstream)
end
end
set -l branch_color $___fish_git_prompt_color_branch
set -l branch_done $___fish_git_prompt_color_branch_done
if set -q __fish_git_prompt_showcolorhints
if test $detached = yes
set branch_color $___fish_git_prompt_color_branch_detached
set branch_done $___fish_git_prompt_color_branch_detached_done
end
end
if test -n "$w"
set w "$___fish_git_prompt_color_dirtystate$w$___fish_git_prompt_color_dirtystate_done"
end
if test -n "$i"
set i "$___fish_git_prompt_color_stagedstate$i$___fish_git_prompt_color_stagedstate_done"
end
if test -n "$s"
set s "$___fish_git_prompt_color_stashstate$s$___fish_git_prompt_color_stashstate_done"
end
if test -n "$u"
set u "$___fish_git_prompt_color_untrackedfiles$u$___fish_git_prompt_color_untrackedfiles_done"
end
set b (string replace refs/heads/ '' -- $b)
set -q __fish_git_prompt_shorten_branch_char_suffix
or set -l __fish_git_prompt_shorten_branch_char_suffix "…"
if string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"; and test (string length "$b") -gt $__fish_git_prompt_shorten_branch_len
set b (string sub -l "$__fish_git_prompt_shorten_branch_len" "$b")"$__fish_git_prompt_shorten_branch_char_suffix"
end
if test -n "$b"
set b "$branch_color$b$branch_done"
end
if test -n "$c"
set c "$___fish_git_prompt_color_bare$c$___fish_git_prompt_color_bare_done"
end
if test -n "$r"
set r "$___fish_git_prompt_color_merging$r$___fish_git_prompt_color_merging_done"
end
if test -n "$p"
set p "$___fish_git_prompt_color_upstream$p$___fish_git_prompt_color_upstream_done"
end
# Formatting
set -l f "$w$i$s$u"
if test -n "$f"
set f "$space$f"
end
set -l format $argv[1]
if test -z "$format"
set format " (%s)"
end
printf "%s$format%s" "$___fish_git_prompt_color_prefix" "$___fish_git_prompt_color_prefix_done$c$b$f$r$p$informative_status$___fish_git_prompt_color_suffix" "$___fish_git_prompt_color_suffix_done"
...
11 11 -----> function __fish_git_prompt_staged --description "__fish_git_prompt helper, tells whether or not the current branch has staged files"
set -l sha $argv[1]
set -l staged
if test -n "$sha"
command git diff-index --cached --quiet HEAD -- 2>/dev/null
or set staged $___fish_git_prompt_char_stagedstate
else
set staged $___fish_git_prompt_char_invalidstate
end
echo $staged
...
9 9 -----> function __fish_git_prompt_untracked --description "__fish_git_prompt helper, tells whether or not the current repository has untracked files"
set -l untracked
if command git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- :/ >/dev/null 2>&1
set untracked $___fish_git_prompt_char_untrackedfiles
end
echo $untracked
...
8 8 -----> function __fish_git_prompt_dirty --description "__fish_git_prompt helper, tells whether or not the current branch has tracked, modified files"
set -l dirty
set -l os
command git diff --no-ext-diff --quiet --exit-code 2>/dev/null
set os $status
if test $os -ne 0
set dirty $___fish_git_prompt_char_dirtystate
end
echo $dirty
...
26 26 -----> set -g ___fish_git_prompt_status_order stagedstate invalidstate dirtystate untrackedfiles
4 4 -----> function __fish_git_prompt_informative_status
set -l changedFiles (command git diff --name-status 2>/dev/null | string match -r \\w)
set -l stagedFiles (command git diff --staged --name-status | string match -r \\w)
set -l x (count $changedFiles)
set -l y (count (string match -r "U" -- $changedFiles))
set -l dirtystate (math $x - $y)
set -l x (count $stagedFiles)
set -l invalidstate (count (string match -r "U" -- $stagedFiles))
set -l stagedstate (math $x - $invalidstate)
set -l untrackedfiles (command git ls-files --others --exclude-standard | wc -l | string trim)
set -l info
# If `math` fails for some reason, assume the state is clean - it's the simpler path
set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles 2>/dev/null)
if test -z "$state"
or test "$state" = 0
set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
else
for i in $___fish_git_prompt_status_order
if [ $$i != "0" ]
set -l color_var ___fish_git_prompt_color_$i
set -l color_done_var ___fish_git_prompt_color_{$i}_done
set -l symbol_var ___fish_git_prompt_char_$i
set -l color $$color_var
set -l color_done $$color_done_var
set -l symbol $$symbol_var
set -l count
if not set -q __fish_git_prompt_hide_$i
set count $$i
end
set info "$info$color$symbol$count$color_done"
end
end
end
echo $info
...
11 11 -----> function __fish_git_prompt_operation_branch_bare --description "__fish_git_prompt helper, returns the current Git operation and branch"
# This function is passed the full repo_info array
set -l git_dir $argv[1]
set -l inside_gitdir $argv[2]
set -l bare_repo $argv[3]
set -q argv[5]
and set -l sha $argv[5]
set -l branch
set -l operation
set -l detached no
set -l bare
set -l step
set -l total
set -l os
if test -d $git_dir/rebase-merge
set branch (cat $git_dir/rebase-merge/head-name 2>/dev/null)
set step (cat $git_dir/rebase-merge/msgnum 2>/dev/null)
set total (cat $git_dir/rebase-merge/end 2>/dev/null)
if test -f $git_dir/rebase-merge/interactive
set operation "|REBASE-i"
else
set operation "|REBASE-m"
end
else
if test -d $git_dir/rebase-apply
set step (cat $git_dir/rebase-apply/next 2>/dev/null)
set total (cat $git_dir/rebase-apply/last 2>/dev/null)
if test -f $git_dir/rebase-apply/rebasing
set branch (cat $git_dir/rebase-apply/head-name 2>/dev/null)
set operation "|REBASE"
else if test -f $git_dir/rebase-apply/applying
set operation "|AM"
else
set operation "|AM/REBASE"
end
else if test -f $git_dir/MERGE_HEAD
set operation "|MERGING"
else if test -f $git_dir/CHERRY_PICK_HEAD
set operation "|CHERRY-PICKING"
else if test -f $git_dir/REVERT_HEAD
set operation "|REVERTING"
else if test -f $git_dir/BISECT_LOG
set operation "|BISECTING"
end
end
if test -n "$step" -a -n "$total"
set operation "$operation $step/$total"
end
if test -z "$branch"
set branch (command git symbolic-ref HEAD 2>/dev/null; set os $status)
if test $os -ne 0
set detached yes
set branch (switch "$__fish_git_prompt_describe_style"
case contains
command git describe --contains HEAD
case branch
command git describe --contains --all HEAD
case describe
command git describe HEAD
case default '*'
command git describe --tags --exact-match HEAD
end 2>/dev/null; set os $status)
if test $os -ne 0
# Shorten the sha ourselves to 8 characters - this should be good for most repositories,
# and even for large ones it should be good for most commits
if set -q sha
set branch (string match -r '^.{8}' -- $sha)…
else
set branch unknown
end
end
set branch "($branch)"
end
end
if test "true" = $inside_gitdir
if test "true" = $bare_repo
set bare "BARE:"
else
# Let user know they're inside the git dir of a non-bare repo
set branch "GIT_DIR!"
end
end
echo $operation
echo $branch
echo $detached
echo $bare
...
4 4 -----> function __fish_git_prompt_set_char
set -l user_variable_name "$argv[1]"
set -l char $argv[2]
set -l user_variable
if set -q $user_variable_name
set user_variable $$user_variable_name
end
if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
end
set -l variable _$user_variable_name
set -l variable_done "$variable"_done
if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
end
...
8 8 -----> function __fish_git_prompt_validate_chars --description "__fish_git_prompt helper, checks char variables"
__fish_git_prompt_set_char __fish_git_prompt_char_cleanstate '✔'
__fish_git_prompt_set_char __fish_git_prompt_char_dirtystate '*' '✚'
__fish_git_prompt_set_char __fish_git_prompt_char_invalidstate '#' '✖'
__fish_git_prompt_set_char __fish_git_prompt_char_stagedstate '+' '●'
__fish_git_prompt_set_char __fish_git_prompt_char_stashstate '$'
__fish_git_prompt_set_char __fish_git_prompt_char_stateseparator ' ' '|'
__fish_git_prompt_set_char __fish_git_prompt_char_untrackedfiles '%' '…'
__fish_git_prompt_set_char __fish_git_prompt_char_upstream_ahead '>' '↑'
__fish_git_prompt_set_char __fish_git_prompt_char_upstream_behind '<' '↓'
__fish_git_prompt_set_char __fish_git_prompt_char_upstream_diverged '<>'
__fish_git_prompt_set_char __fish_git_prompt_char_upstream_equal '='
__fish_git_prompt_set_char __fish_git_prompt_char_upstream_prefix ''
...
3 3 -----> function __fish_git_prompt_set_color
set -l user_variable_name "$argv[1]"
set -l user_variable
if set -q $user_variable_name
set user_variable $$user_variable_name
end
set -l user_variable_bright
set -l default default_done
switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
end
set -l variable _$user_variable_name
set -l variable_done "$variable"_done
if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
end
...
7 7 -----> function __fish_git_prompt_validate_colors --description "__fish_git_prompt helper, checks color variables"
# Base color defaults to nothing (must be done first)
__fish_git_prompt_set_color __fish_git_prompt_color '' ''
# Normal colors
__fish_git_prompt_set_color __fish_git_prompt_color_prefix
__fish_git_prompt_set_color __fish_git_prompt_color_suffix
__fish_git_prompt_set_color __fish_git_prompt_color_bare
__fish_git_prompt_set_color __fish_git_prompt_color_merging
__fish_git_prompt_set_color __fish_git_prompt_color_cleanstate
__fish_git_prompt_set_color __fish_git_prompt_color_invalidstate
__fish_git_prompt_set_color __fish_git_prompt_color_upstream
# Colors with defaults with showcolorhints
if set -q __fish_git_prompt_showcolorhints
__fish_git_prompt_set_color __fish_git_prompt_color_flags (set_color --bold blue)
__fish_git_prompt_set_color __fish_git_prompt_color_branch (set_color green)
__fish_git_prompt_set_color __fish_git_prompt_color_dirtystate (set_color red)
__fish_git_prompt_set_color __fish_git_prompt_color_stagedstate (set_color green)
else
__fish_git_prompt_set_color __fish_git_prompt_color_flags
__fish_git_prompt_set_color __fish_git_prompt_color_branch
__fish_git_prompt_set_color __fish_git_prompt_color_dirtystate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
__fish_git_prompt_set_color __fish_git_prompt_color_stagedstate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
end
# Branch_detached has a default, but is only used with showcolorhints
__fish_git_prompt_set_color __fish_git_prompt_color_branch_detached (set_color red)
# Colors that depend on flags color
__fish_git_prompt_set_color __fish_git_prompt_color_stashstate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
__fish_git_prompt_set_color __fish_git_prompt_color_untrackedfiles $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
...
17 17 -----> set -l varargs
73 238 -----> for var in repaint describe_style show_informative_status showdirtystate showstashstate showuntrackedfiles showupstream
set -a varargs --on-variable __fish_git_prompt_$var
...
22 22 ------> set -a varargs --on-variable __fish_git_prompt_$var
21 21 ------> set -a varargs --on-variable __fish_git_prompt_$var
23 23 ------> set -a varargs --on-variable __fish_git_prompt_$var
23 23 ------> set -a varargs --on-variable __fish_git_prompt_$var
24 24 ------> set -a varargs --on-variable __fish_git_prompt_$var
26 26 ------> set -a varargs --on-variable __fish_git_prompt_$var
26 26 ------> set -a varargs --on-variable __fish_git_prompt_$var
43 43 -----> function __fish_git_prompt_repaint $varargs --description "Event handler, repaints prompt when functionality changes"
if status --is-interactive
if test $argv[3] = __fish_git_prompt_show_informative_status
# Clear characters that have different defaults with/without informative status
for name in cleanstate dirtystate invalidstate stagedstate stateseparator untrackedfiles upstream_ahead upstream_behind
set -e ___fish_git_prompt_char_$name
end
end
commandline -f repaint 2>/dev/null
end
...
19 19 -----> set -l varargs
48 466 -----> for var in '' _prefix _suffix _bare _merging _cleanstate _invalidstate _upstream _flags _branch _dirtystate _stagedstate _branch_detached _stashstate _untrackedfiles
set -a varargs --on-variable __fish_git_prompt_color$var
...
18 18 ------> set -a varargs --on-variable __fish_git_prompt_color$var
20 20 ------> set -a varargs --on-variable __fish_git_prompt_color$var
22 22 ------> set -a varargs --on-variable __fish_git_prompt_color$var
22 22 ------> set -a varargs --on-variable __fish_git_prompt_color$var
24 24 ------> set -a varargs --on-variable __fish_git_prompt_color$var
25 25 ------> set -a varargs --on-variable __fish_git_prompt_color$var
26 26 ------> set -a varargs --on-variable __fish_git_prompt_color$var
27 27 ------> set -a varargs --on-variable __fish_git_prompt_color$var
30 30 ------> set -a varargs --on-variable __fish_git_prompt_color$var
32 32 ------> set -a varargs --on-variable __fish_git_prompt_color$var
31 31 ------> set -a varargs --on-variable __fish_git_prompt_color$var
33 33 ------> set -a varargs --on-variable __fish_git_prompt_color$var
34 34 ------> set -a varargs --on-variable __fish_git_prompt_color$var
37 37 ------> set -a varargs --on-variable __fish_git_prompt_color$var
37 37 ------> set -a varargs --on-variable __fish_git_prompt_color$var
35 35 -----> set -a varargs --on-variable __fish_git_prompt_showcolorhints
72 72 -----> function __fish_git_prompt_repaint_color $varargs --description "Event handler, repaints prompt when any color changes"
if status --is-interactive
set -e ___fish_git_prompt_init
set -l var $argv[3]
set -e _$var
set -e _{$var}_done
if test $var = __fish_git_prompt_color -o $var = __fish_git_prompt_color_flags -o $var = __fish_git_prompt_showcolorhints
# reset all the other colors too
for name in prefix suffix bare merging branch dirtystate stagedstate invalidstate stashstate untrackedfiles upstream flags
set -e ___fish_git_prompt_color_$name
set -e ___fish_git_prompt_color_{$name}_done
end
end
commandline -f repaint 2>/dev/null
end
...
22 22 -----> set -l varargs
41 351 -----> for var in cleanstate dirtystate invalidstate stagedstate stashstate stateseparator untrackedfiles upstream_ahead upstream_behind upstream_diverged upstream_equal upstream_prefix
set -a varargs --on-variable __fish_git_prompt_char_$var
...
18 18 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
21 21 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
21 21 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
23 23 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
23 23 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
25 25 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
27 27 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
28 28 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
29 29 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
30 30 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
32 32 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
33 33 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
57 57 -----> function __fish_git_prompt_repaint_char $varargs --description "Event handler, repaints prompt when any char changes"
if status --is-interactive
set -e ___fish_git_prompt_init
set -e _$argv[3]
commandline -f repaint 2>/dev/null
end
...
3 52 ----> if not command -sq git
return 1
...
49 49 -----> not command -sq git
95 6430 ----> set -l repo_info (command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null)
6335 6335 -----> command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null
24 24 ----> test -n "$repo_info"
20 20 ----> set -l git_dir $repo_info[1]
19 19 ----> set -l inside_gitdir $repo_info[2]
18 18 ----> set -l bare_repo $repo_info[3]
17 17 ----> set -l inside_worktree $repo_info[4]
15 15 ----> set -q repo_info[5]
18 18 ----> set -l sha $repo_info[5]
55 6701 ----> set -l rbc (__fish_git_prompt_operation_branch_bare $repo_info)
123 6646 -----> __fish_git_prompt_operation_branch_bare $repo_info
20 20 ------> set -l git_dir $argv[1]
18 18 ------> set -l inside_gitdir $argv[2]
17 17 ------> set -l bare_repo $argv[3]
14 14 ------> set -q argv[5]
17 17 ------> set -l sha $argv[5]
13 13 ------> set -l branch
14 14 ------> set -l operation
13 13 ------> set -l detached no
13 13 ------> set -l bare
12 12 ------> set -l step
13 13 ------> set -l total
12 12 ------> set -l os
45 157 ------> if test -d $git_dir/rebase-merge
set branch (cat $git_dir/rebase-merge/head-name 2>/dev/null)
set step (cat $git_dir/rebase-merge/msgnum 2>/dev/null)
set total (cat $git_dir/rebase-merge/end 2>/dev/null)
if test -f $git_dir/rebase-merge/interactive
set operation "|REBASE-i"
else
set operation "|REBASE-m"
end
else
if test -d $git_dir/rebase-apply
set step (cat $git_dir/rebase-apply/next 2>/dev/null)
set total (cat $git_dir/rebase-apply/last 2>/dev/null)
if test -f $git_dir/rebase-apply/rebasing
set branch (cat $git_dir/rebase-apply/head-name 2>/dev/null)
set operation "|REBASE"
else if test -f $git_dir/rebase-apply/applying
set operation "|AM"
else
set operation "|AM/REBASE"
end
else if test -f $git_dir/MERGE_HEAD
set operation "|MERGING"
else if test -f $git_dir/CHERRY_PICK_HEAD
set operation "|CHERRY-PICKING"
else if test -f $git_dir/REVERT_HEAD
set operation "|REVERTING"
else if test -f $git_dir/BISECT_LOG
set operation "|BISECTING"
end
...
19 19 -------> test -d $git_dir/rebase-merge
7 93 -------> if test -d $git_dir/rebase-apply
set step (cat $git_dir/rebase-apply/next 2>/dev/null)
set total (cat $git_dir/rebase-apply/last 2>/dev/null)
if test -f $git_dir/rebase-apply/rebasing
set branch (cat $git_dir/rebase-apply/head-name 2>/dev/null)
set operation "|REBASE"
else if test -f $git_dir/rebase-apply/applying
set operation "|AM"
else
set operation "|AM/REBASE"
end
else if test -f $git_dir/MERGE_HEAD
set operation "|MERGING"
else if test -f $git_dir/CHERRY_PICK_HEAD
set operation "|CHERRY-PICKING"
else if test -f $git_dir/REVERT_HEAD
set operation "|REVERTING"
else if test -f $git_dir/BISECT_LOG
set operation "|BISECTING"
...
18 18 --------> test -d $git_dir/rebase-apply
17 17 --------> test -f $git_dir/MERGE_HEAD
18 18 --------> test -f $git_dir/CHERRY_PICK_HEAD
16 16 --------> test -f $git_dir/REVERT_HEAD
17 17 --------> test -f $git_dir/BISECT_LOG
1 21 ------> if test -n "$step" -a -n "$total"
set operation "$operation $step/$total"
...
20 20 -------> test -n "$step" -a -n "$total"
25 6086 ------> if test -z "$branch"
set branch (command git symbolic-ref HEAD 2>/dev/null; set os $status)
if test $os -ne 0
set detached yes
set branch (switch "$__fish_git_prompt_describe_style"
case contains
command git describe --contains HEAD
case branch
command git describe --contains --all HEAD
case describe
command git describe HEAD
case default '*'
command git describe --tags --exact-match HEAD
end 2>/dev/null; set os $status)
if test $os -ne 0
# Shorten the sha ourselves to 8 characters - this should be good for most repositories,
# and even for large ones it should be good for most commits
if set -q sha
set branch (string match -r '^.{8}' -- $sha)…
else
set branch unknown
end
end
set branch "($branch)"
end
...
15 15 -------> test -z "$branch"
63 6025 -------> set branch (command git symbolic-ref HEAD 2>/dev/null; set os $status)
5929 5929 --------> command git symbolic-ref HEAD 2>/dev/null
33 33 --------> set os $status
2 21 -------> if test $os -ne 0
set detached yes
set branch (switch "$__fish_git_prompt_describe_style"
case contains
command git describe --contains HEAD
case branch
command git describe --contains --all HEAD
case describe
command git describe HEAD
case default '*'
command git describe --tags --exact-match HEAD
end 2>/dev/null; set os $status)
if test $os -ne 0
# Shorten the sha ourselves to 8 characters - this should be good for most repositories,
# and even for large ones it should be good for most commits
if set -q sha
set branch (string match -r '^.{8}' -- $sha)…
else
set branch unknown
end
end
set branch "($branch)"
...
19 19 --------> test $os -ne 0
1 22 ------> if test "true" = $inside_gitdir
if test "true" = $bare_repo
set bare "BARE:"
else
# Let user know they're inside the git dir of a non-bare repo
set branch "GIT_DIR!"
end
...
21 21 -------> test "true" = $inside_gitdir
17 17 ------> echo $operation
17 17 ------> echo $branch
14 14 ------> echo $detached
13 13 ------> echo $bare
18 18 ----> set -l r $rbc[1]
17 17 ----> set -l b $rbc[2]
17 17 ----> set -l detached $rbc[3]
12 12 ----> set -l w
12 12 ----> set -l i
11 11 ----> set -l s
12 12 ----> set -l u
15 15 ----> set -l c $rbc[4]
11 11 ----> set -l p
14 14 ----> set -l informative_status
18 11877 ----> if not set -q ___fish_git_prompt_init
# This takes a while, so it only needs to be done once,
# and then whenever the configuration changes.
__fish_git_prompt_validate_chars
__fish_git_prompt_validate_colors
set -g ___fish_git_prompt_init
...
25 25 -----> not set -q ___fish_git_prompt_init
93 4490 -----> __fish_git_prompt_validate_chars
108 421 ------> __fish_git_prompt_set_char __fish_git_prompt_char_cleanstate '✔'
24 24 -------> set -l user_variable_name "$argv[1]"
18 18 -------> set -l char $argv[2]
14 14 -------> set -l user_variable
44 79 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
16 16 --------> set -q $user_variable_name
19 19 --------> set user_variable $$user_variable_name
2 16 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
14 14 --------> set -q argv[3]
18 18 -------> set -l variable _$user_variable_name
20 20 -------> set -l variable_done "$variable"_done
17 124 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
56 92 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
19 19 ---------> set -q $user_variable_name
17 17 ---------> echo $user_variable
51 395 ------> __fish_git_prompt_set_char __fish_git_prompt_char_dirtystate '*' '✚'
20 20 -------> set -l user_variable_name "$argv[1]"
17 17 -------> set -l char $argv[2]
14 14 -------> set -l user_variable
44 78 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
19 19 --------> set user_variable $$user_variable_name
17 60 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
14 14 --------> set -q argv[3]
13 13 --------> set -q __fish_git_prompt_show_informative_status
16 16 --------> set char $argv[3]
18 18 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
16 119 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
56 88 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
16 16 ---------> set -q $user_variable_name
16 16 ---------> echo $user_variable
53 392 ------> __fish_git_prompt_set_char __fish_git_prompt_char_invalidstate '#' '✖'
19 19 -------> set -l user_variable_name "$argv[1]"
16 16 -------> set -l char $argv[2]
14 14 -------> set -l user_variable
44 77 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
18 18 --------> set user_variable $$user_variable_name
17 59 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
14 14 --------> set -q argv[3]
12 12 --------> set -q __fish_git_prompt_show_informative_status
16 16 --------> set char $argv[3]
17 17 -------> set -l variable _$user_variable_name
20 20 -------> set -l variable_done "$variable"_done
17 117 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
53 85 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
17 17 ---------> set -q $user_variable_name
15 15 ---------> echo $user_variable
52 388 ------> __fish_git_prompt_set_char __fish_git_prompt_char_stagedstate '+' '●'
19 19 -------> set -l user_variable_name "$argv[1]"
16 16 -------> set -l char $argv[2]
13 13 -------> set -l user_variable
44 77 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
18 18 --------> set user_variable $$user_variable_name
18 59 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
14 14 --------> set -q argv[3]
12 12 --------> set -q __fish_git_prompt_show_informative_status
15 15 --------> set char $argv[3]
18 18 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
16 116 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
55 85 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
15 15 ---------> set -q $user_variable_name
15 15 ---------> echo $user_variable
51 310 ------> __fish_git_prompt_set_char __fish_git_prompt_char_stashstate '$'
20 20 -------> set -l user_variable_name "$argv[1]"
17 17 -------> set -l char $argv[2]
14 14 -------> set -l user_variable
2 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
1 14 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
17 17 -------> set -l variable _$user_variable_name
17 17 -------> set -l variable_done "$variable"_done
43 143 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
55 85 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
15 15 ---------> set -q $user_variable_name
15 15 ---------> echo $char
53 359 ------> __fish_git_prompt_set_char __fish_git_prompt_char_stateseparator ' ' '|'
19 19 -------> set -l user_variable_name "$argv[1]"
16 16 -------> set -l char $argv[2]
14 14 -------> set -l user_variable
2 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
44 85 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
12 12 --------> set -q __fish_git_prompt_show_informative_status
16 16 --------> set char $argv[3]
20 20 -------> set -l variable _$user_variable_name
17 17 -------> set -l variable_done "$variable"_done
16 118 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
53 87 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
18 18 ---------> set -q $user_variable_name
16 16 ---------> echo $char
50 387 ------> __fish_git_prompt_set_char __fish_git_prompt_char_untrackedfiles '%' '…'
20 20 -------> set -l user_variable_name "$argv[1]"
16 16 -------> set -l char $argv[2]
13 13 -------> set -l user_variable
44 77 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
18 18 --------> set user_variable $$user_variable_name
18 59 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
12 12 --------> set -q __fish_git_prompt_show_informative_status
16 16 --------> set char $argv[3]
18 18 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
17 116 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
14 14 --------> not set -q $variable
55 85 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
15 15 ---------> set -q $user_variable_name
15 15 ---------> echo $user_variable
57 399 ------> __fish_git_prompt_set_char __fish_git_prompt_char_upstream_ahead '>' '↑'
20 20 -------> set -l user_variable_name "$argv[1]"
18 18 -------> set -l char $argv[2]
14 14 -------> set -l user_variable
44 77 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
18 18 --------> set user_variable $$user_variable_name
17 58 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
12 12 --------> set -q __fish_git_prompt_show_informative_status
16 16 --------> set char $argv[3]
18 18 -------> set -l variable _$user_variable_name
20 20 -------> set -l variable_done "$variable"_done
18 117 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
52 84 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
17 17 ---------> set -q $user_variable_name
15 15 ---------> echo $user_variable
52 385 ------> __fish_git_prompt_set_char __fish_git_prompt_char_upstream_behind '<' '↓'
19 19 -------> set -l user_variable_name "$argv[1]"
17 17 -------> set -l char $argv[2]
13 13 -------> set -l user_variable
44 77 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
18 18 --------> set user_variable $$user_variable_name
18 58 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
11 11 --------> set -q __fish_git_prompt_show_informative_status
16 16 --------> set char $argv[3]
17 17 -------> set -l variable _$user_variable_name
17 17 -------> set -l variable_done "$variable"_done
16 115 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
53 84 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
15 15 ---------> set -q $user_variable_name
16 16 ---------> echo $user_variable
51 312 ------> __fish_git_prompt_set_char __fish_git_prompt_char_upstream_diverged '<>'
19 19 -------> set -l user_variable_name "$argv[1]"
16 16 -------> set -l char $argv[2]
14 14 -------> set -l user_variable
3 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
14 14 --------> set -q $user_variable_name
1 14 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
17 17 -------> set -l variable _$user_variable_name
20 20 -------> set -l variable_done "$variable"_done
44 144 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
51 85 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
18 18 ---------> set -q $user_variable_name
16 16 ---------> echo $char
51 307 ------> __fish_git_prompt_set_char __fish_git_prompt_char_upstream_equal '='
19 19 -------> set -l user_variable_name "$argv[1]"
16 16 -------> set -l char $argv[2]
13 13 -------> set -l user_variable
2 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
1 14 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
17 17 -------> set -l variable _$user_variable_name
17 17 -------> set -l variable_done "$variable"_done
44 143 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
53 84 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
16 16 ---------> set -q $user_variable_name
15 15 ---------> echo $char
49 342 ------> __fish_git_prompt_set_char __fish_git_prompt_char_upstream_prefix ''
19 19 -------> set -l user_variable_name "$argv[1]"
16 16 -------> set -l char $argv[2]
13 13 -------> set -l user_variable
43 77 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
19 19 --------> set user_variable $$user_variable_name
2 15 -------> if set -q argv[3]
and set -q __fish_git_prompt_show_informative_status
set char $argv[3]
...
13 13 --------> set -q argv[3]
18 18 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
17 117 -------> if not set -q $variable
set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
...
15 15 --------> not set -q $variable
55 85 --------> set -g $variable (set -q $user_variable_name; and echo $user_variable; or echo $char)
15 15 ---------> set -q $user_variable_name
15 15 ---------> echo $user_variable
85 7329 -----> __fish_git_prompt_validate_colors
115 507 ------> __fish_git_prompt_set_color __fish_git_prompt_color '' ''
21 21 -------> set -l user_variable_name "$argv[1]"
13 13 -------> set -l user_variable
1 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
16 16 --------> set -q $user_variable_name
13 13 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
82 171 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
52 52 --------> count $argv
19 19 --------> set default "$argv[2]"
18 18 --------> set default_done "$argv[3]"
19 19 -------> set -l variable _$user_variable_name
19 19 -------> set -l variable_done "$variable"_done
16 105 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
16 16 --------> not set -q $variable
18 73 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
16 16 ---------> test -n "$user_variable"
20 20 ---------> set -g $variable $default
19 19 ---------> set -g $variable_done $default_done
57 408 ------> __fish_git_prompt_set_color __fish_git_prompt_color_prefix
19 19 -------> set -l user_variable_name "$argv[1]"
13 13 -------> set -l user_variable
2 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
14 14 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
79 133 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
19 19 --------> count $argv
18 18 --------> set default $___fish_git_prompt_color
17 17 --------> set default_done $___fish_git_prompt_color_done
18 18 -------> set -l variable _$user_variable_name
17 17 -------> set -l variable_done "$variable"_done
16 106 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
19 75 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ---------> test -n "$user_variable"
20 20 ---------> set -g $variable $default
21 21 ---------> set -g $variable_done $default_done
55 406 ------> __fish_git_prompt_set_color __fish_git_prompt_color_suffix
19 19 -------> set -l user_variable_name "$argv[1]"
13 13 -------> set -l user_variable
1 16 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
14 14 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
79 132 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
18 18 --------> count $argv
18 18 --------> set default $___fish_git_prompt_color
17 17 --------> set default_done $___fish_git_prompt_color_done
19 19 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
16 106 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
19 75 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ---------> test -n "$user_variable"
22 22 ---------> set -g $variable $default
19 19 ---------> set -g $variable_done $default_done
52 402 ------> __fish_git_prompt_set_color __fish_git_prompt_color_bare
19 19 -------> set -l user_variable_name "$argv[1]"
14 14 -------> set -l user_variable
2 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
13 13 -------> set -l user_variable_bright
13 13 -------> set -l default default_done
80 133 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
19 19 --------> count $argv
17 17 --------> set default $___fish_git_prompt_color
17 17 --------> set default_done $___fish_git_prompt_color_done
18 18 -------> set -l variable _$user_variable_name
20 20 -------> set -l variable_done "$variable"_done
16 103 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
19 72 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ---------> test -n "$user_variable"
19 19 ---------> set -g $variable $default
19 19 ---------> set -g $variable_done $default_done
53 406 ------> __fish_git_prompt_set_color __fish_git_prompt_color_merging
19 19 -------> set -l user_variable_name "$argv[1]"
13 13 -------> set -l user_variable
2 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
13 13 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
79 135 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
20 20 --------> count $argv
18 18 --------> set default $___fish_git_prompt_color
18 18 --------> set default_done $___fish_git_prompt_color_done
18 18 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
20 106 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
14 14 --------> not set -q $variable
18 72 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ---------> test -n "$user_variable"
20 20 ---------> set -g $variable $default
19 19 ---------> set -g $variable_done $default_done
55 555 ------> __fish_git_prompt_set_color __fish_git_prompt_color_cleanstate
19 19 -------> set -l user_variable_name "$argv[1]"
13 13 -------> set -l user_variable
45 82 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
16 16 --------> set -q $user_variable_name
21 21 --------> set user_variable $$user_variable_name
14 14 -------> set -l user_variable_bright
13 13 -------> set -l default default_done
48 102 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
19 19 --------> count $argv
18 18 --------> set default $___fish_git_prompt_color
17 17 --------> set default_done $___fish_git_prompt_color_done
19 19 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
17 220 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
19 188 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
17 17 ---------> test -n "$user_variable"
53 81 ---------> set -g $variable (set_color $user_variable)
28 28 ----------> set_color $user_variable
51 71 ---------> set -g $variable_done (set_color normal)
20 20 ----------> set_color normal
54 547 ------> __fish_git_prompt_set_color __fish_git_prompt_color_invalidstate
19 19 -------> set -l user_variable_name "$argv[1]"
13 13 -------> set -l user_variable
45 80 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
16 16 --------> set -q $user_variable_name
19 19 --------> set user_variable $$user_variable_name
14 14 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
50 106 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
21 21 --------> count $argv
18 18 --------> set default $___fish_git_prompt_color
17 17 --------> set default_done $___fish_git_prompt_color_done
19 19 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
17 210 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
17 178 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
16 16 ---------> test -n "$user_variable"
51 75 ---------> set -g $variable (set_color $user_variable)
24 24 ----------> set_color $user_variable
51 70 ---------> set -g $variable_done (set_color normal)
19 19 ----------> set_color normal
52 408 ------> __fish_git_prompt_set_color __fish_git_prompt_color_upstream
20 20 -------> set -l user_variable_name "$argv[1]"
14 14 -------> set -l user_variable
3 18 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
14 14 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
78 132 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
19 19 --------> count $argv
18 18 --------> set default $___fish_git_prompt_color
17 17 --------> set default_done $___fish_git_prompt_color_done
19 19 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
17 107 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
18 75 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ---------> test -n "$user_variable"
22 22 ---------> set -g $variable $default
20 20 ---------> set -g $variable_done $default_done
20 2108 ------> if set -q __fish_git_prompt_showcolorhints
__fish_git_prompt_set_color __fish_git_prompt_color_flags (set_color --bold blue)
__fish_git_prompt_set_color __fish_git_prompt_color_branch (set_color green)
__fish_git_prompt_set_color __fish_git_prompt_color_dirtystate (set_color red)
__fish_git_prompt_set_color __fish_git_prompt_color_stagedstate (set_color green)
else
__fish_git_prompt_set_color __fish_git_prompt_color_flags
__fish_git_prompt_set_color __fish_git_prompt_color_branch
__fish_git_prompt_set_color __fish_git_prompt_color_dirtystate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
__fish_git_prompt_set_color __fish_git_prompt_color_stagedstate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
...
13 13 -------> set -q __fish_git_prompt_showcolorhints
57 408 -------> __fish_git_prompt_set_color __fish_git_prompt_color_flags
19 19 --------> set -l user_variable_name "$argv[1]"
14 14 --------> set -l user_variable
1 17 --------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
16 16 ---------> set -q $user_variable_name
13 13 --------> set -l user_variable_bright
14 14 --------> set -l default default_done
78 133 --------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
20 20 ---------> count $argv
18 18 ---------> set default $___fish_git_prompt_color
17 17 ---------> set default_done $___fish_git_prompt_color_done
18 18 --------> set -l variable _$user_variable_name
17 17 --------> set -l variable_done "$variable"_done
18 106 --------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 ---------> not set -q $variable
19 73 ---------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ----------> test -n "$user_variable"
20 20 ----------> set -g $variable $default
19 19 ----------> set -g $variable_done $default_done
55 549 -------> __fish_git_prompt_set_color __fish_git_prompt_color_branch
19 19 --------> set -l user_variable_name "$argv[1]"
13 13 --------> set -l user_variable
45 81 --------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 ---------> set -q $user_variable_name
21 21 ---------> set user_variable $$user_variable_name
14 14 --------> set -l user_variable_bright
14 14 --------> set -l default default_done
49 102 --------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
18 18 ---------> count $argv
18 18 ---------> set default $___fish_git_prompt_color
17 17 ---------> set default_done $___fish_git_prompt_color_done
19 19 --------> set -l variable _$user_variable_name
17 17 --------> set -l variable_done "$variable"_done
17 215 --------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 ---------> not set -q $variable
19 183 ---------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
16 16 ----------> test -n "$user_variable"
52 78 ----------> set -g $variable (set_color $user_variable)
26 26 -----------> set_color $user_variable
50 70 ----------> set -g $variable_done (set_color normal)
20 20 -----------> set_color normal
64 562 -------> __fish_git_prompt_set_color __fish_git_prompt_color_dirtystate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
20 20 --------> set -l user_variable_name "$argv[1]"
14 14 --------> set -l user_variable
47 80 --------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 ---------> set -q $user_variable_name
18 18 ---------> set user_variable $$user_variable_name
14 14 --------> set -l user_variable_bright
14 14 --------> set -l default default_done
50 107 --------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
22 22 ---------> count $argv
18 18 ---------> set default "$argv[2]"
17 17 ---------> set default_done "$argv[3]"
18 18 --------> set -l variable _$user_variable_name
18 18 --------> set -l variable_done "$variable"_done
19 213 --------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 ---------> not set -q $variable
18 179 ---------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
16 16 ----------> test -n "$user_variable"
51 75 ----------> set -g $variable (set_color $user_variable)
24 24 -----------> set_color $user_variable
51 70 ----------> set -g $variable_done (set_color normal)
19 19 -----------> set_color normal
60 556 -------> __fish_git_prompt_set_color __fish_git_prompt_color_stagedstate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
19 19 --------> set -l user_variable_name "$argv[1]"
14 14 --------> set -l user_variable
47 81 --------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 ---------> set -q $user_variable_name
19 19 ---------> set user_variable $$user_variable_name
13 13 --------> set -l user_variable_bright
14 14 --------> set -l default default_done
50 106 --------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
21 21 ---------> count $argv
18 18 ---------> set default "$argv[2]"
17 17 ---------> set default_done "$argv[3]"
19 19 --------> set -l variable _$user_variable_name
18 18 --------> set -l variable_done "$variable"_done
17 212 --------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 ---------> not set -q $variable
21 180 ---------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
16 16 ----------> test -n "$user_variable"
51 74 ----------> set -g $variable (set_color $user_variable)
23 23 -----------> set_color $user_variable
49 69 ----------> set -g $variable_done (set_color normal)
20 20 -----------> set_color normal
84 515 ------> __fish_git_prompt_set_color __fish_git_prompt_color_branch_detached (set_color red)
20 20 -------> set_color red
21 21 -------> set -l user_variable_name "$argv[1]"
14 14 -------> set -l user_variable
2 18 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
16 16 --------> set -q $user_variable_name
13 13 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
78 183 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
20 20 --------> count $argv
19 19 --------> set default "$argv[2]"
47 66 --------> set default_done (set_color normal)
19 19 ---------> set_color normal
20 20 -------> set -l variable _$user_variable_name
21 21 -------> set -l variable_done "$variable"_done
18 107 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
19 74 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ---------> test -n "$user_variable"
20 20 ---------> set -g $variable $default
20 20 ---------> set -g $variable_done $default_done
68 424 ------> __fish_git_prompt_set_color __fish_git_prompt_color_stashstate $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
19 19 -------> set -l user_variable_name "$argv[1]"
14 14 -------> set -l user_variable
2 17 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
13 13 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
80 136 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
20 20 --------> count $argv
19 19 --------> set default "$argv[2]"
17 17 --------> set default_done "$argv[3]"
18 18 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
19 107 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
15 15 --------> not set -q $variable
19 73 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
15 15 ---------> test -n "$user_variable"
20 20 ---------> set -g $variable $default
19 19 ---------> set -g $variable_done $default_done
59 558 ------> __fish_git_prompt_set_color __fish_git_prompt_color_untrackedfiles $___fish_git_prompt_color_flags $___fish_git_prompt_color_flags_done
20 20 -------> set -l user_variable_name "$argv[1]"
14 14 -------> set -l user_variable
49 83 -------> if set -q $user_variable_name
set user_variable $$user_variable_name
...
15 15 --------> set -q $user_variable_name
19 19 --------> set user_variable $$user_variable_name
13 13 -------> set -l user_variable_bright
14 14 -------> set -l default default_done
51 107 -------> switch (count $argv)
case 1 # No defaults given, use prompt color
set default $___fish_git_prompt_color
set default_done $___fish_git_prompt_color_done
case 2 # One default given, use normal for done
set default "$argv[2]"
set default_done (set_color normal)
case 3 # Both defaults given
set default "$argv[2]"
set default_done "$argv[3]"
...
20 20 --------> count $argv
19 19 --------> set default "$argv[2]"
17 17 --------> set default_done "$argv[3]"
19 19 -------> set -l variable _$user_variable_name
18 18 -------> set -l variable_done "$variable"_done
16 211 -------> if not set -q $variable
if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
end
...
16 16 --------> not set -q $variable
18 179 --------> if test -n "$user_variable"
set -g $variable (set_color $user_variable)
set -g $variable_done (set_color normal)
else
set -g $variable $default
set -g $variable_done $default_done
...
16 16 ---------> test -n "$user_variable"
53 76 ---------> set -g $variable (set_color $user_variable)
23 23 ----------> set_color $user_variable
50 69 ---------> set -g $variable_done (set_color normal)
19 19 ----------> set_color normal
15 15 -----> set -g ___fish_git_prompt_init
22 22 ----> set -l space "$___fish_git_prompt_color$___fish_git_prompt_char_stateseparator$___fish_git_prompt_color_done"
24 35435 ----> if test "true" = $inside_worktree
if set -q __fish_git_prompt_show_informative_status
set informative_status "$space"(__fish_git_prompt_informative_status)
else
if set -q __fish_git_prompt_showdirtystate
set -l config (command git config --bool bash.showDirtyState)
if test "$config" != "false"
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false
set u (__fish_git_prompt_untracked)
end
end
end
if set -q __fish_git_prompt_showupstream
or set -q __fish_git_prompt_show_informative_status
set p (__fish_git_prompt_show_upstream)
end
...
17 17 -----> test "true" = $inside_worktree
12 21223 -----> if set -q __fish_git_prompt_show_informative_status
set informative_status "$space"(__fish_git_prompt_informative_status)
else
if set -q __fish_git_prompt_showdirtystate
set -l config (command git config --bool bash.showDirtyState)
if test "$config" != "false"
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false
set u (__fish_git_prompt_untracked)
end
end
...
12 12 ------> set -q __fish_git_prompt_show_informative_status
46 21199 ------> set informative_status "$space"(__fish_git_prompt_informative_status)
91 21153 -------> __fish_git_prompt_informative_status
87 6506 --------> set -l changedFiles (command git diff --name-status 2>/dev/null | string match -r \\w)
6419 6419 ---------> command git diff --name-status 2>/dev/null | string match -r \\w
78 6786 --------> set -l stagedFiles (command git diff --staged --name-status | string match -r \\w)
6708 6708 ---------> command git diff --staged --name-status | string match -r \\w
61 85 --------> set -l x (count $changedFiles)
24 24 ---------> count $changedFiles
44 113 --------> set -l y (count (string match -r "U" -- $changedFiles))
43 69 ---------> count (string match -r "U" -- $changedFiles)
26 26 ----------> string match -r "U" -- $changedFiles
45 112 --------> set -l dirtystate (math $x - $y)
67 67 ---------> math $x - $y
41 60 --------> set -l x (count $stagedFiles)
19 19 ---------> count $stagedFiles
42 103 --------> set -l invalidstate (count (string match -r "U" -- $stagedFiles))
39 61 ---------> count (string match -r "U" -- $stagedFiles)
22 22 ----------> string match -r "U" -- $stagedFiles
41 64 --------> set -l stagedstate (math $x - $invalidstate)
23 23 ---------> math $x - $invalidstate
67 7024 --------> set -l untrackedfiles (command git ls-files --others --exclude-standard | wc -l | string trim)
6957 6957 ---------> command git ls-files --others --exclude-standard | wc -l | string trim
18 18 --------> set -l info
58 96 --------> set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles 2>/dev/null)
38 38 ---------> math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles 2>/dev/null
16 76 --------> if test -z "$state"
or test "$state" = 0
set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
else
for i in $___fish_git_prompt_status_order
if [ $$i != "0" ]
set -l color_var ___fish_git_prompt_color_$i
set -l color_done_var ___fish_git_prompt_color_{$i}_done
set -l symbol_var ___fish_git_prompt_char_$i
set -l color $$color_var
set -l color_done $$color_done_var
set -l symbol $$symbol_var
set -l count
if not set -q __fish_git_prompt_hide_$i
set count $$i
end
set info "$info$color$symbol$count$color_done"
end
end
...
18 18 ---------> test -z "$state"
15 15 ---------> test "$state" = 0
27 27 ---------> set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
19 19 --------> echo $info
16 14171 -----> if set -q __fish_git_prompt_showupstream
or set -q __fish_git_prompt_show_informative_status
set p (__fish_git_prompt_show_upstream)
...
14 14 ------> set -q __fish_git_prompt_showupstream
52 14141 ------> set p (__fish_git_prompt_show_upstream)
126 14089 -------> __fish_git_prompt_show_upstream
15 15 --------> set -q __fish_git_prompt_showupstream
19 19 --------> set -l show_upstream $__fish_git_prompt_showupstream
14 14 --------> set -l svn_prefix
14 14 --------> set -l informative
13 13 --------> set -l svn_url_pattern
13 13 --------> set -l count
14 14 --------> set -l upstream git
13 13 --------> set -l verbose
13 13 --------> set -l name
18 44 --------> if set -q __fish_git_prompt_show_informative_status
set informative 1
...
12 12 ---------> set -q __fish_git_prompt_show_informative_status
14 14 ---------> set informative 1
13 13 --------> set -l svn_remote
253 6095 --------> command git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | while read -lz key value
switch $key
case bash.showupstream
set show_upstream $value
test -n "$show_upstream"
or return
case svn-remote.'*'.url
set svn_remote $svn_remote $value
# Avoid adding \| to the beginning to avoid needing #?? later
if test -n "$svn_url_pattern"
set svn_url_pattern $svn_url_pattern"|$value"
else
set svn_url_pattern $value
end
set upstream svn+git # default upstream is SVN if available, else git
# Save the config key (without .url) for later use
set -l remote_prefix (string replace -r '\.url$' '' -- $key)
set svn_prefix $svn_prefix $remote_prefix
end
end
5842 5842 ---------> read -lz key value
21 62 --------> for option in $show_upstream
switch $option
case git svn
set upstream $option
set -e informative
case verbose
set verbose 1
set -e informative
case informative
set informative 1
case name
set name 1
case none
return
end
...
17 41 ---------> switch $option
case git svn
set upstream $option
set -e informative
case verbose
set verbose 1
set -e informative
case informative
set informative 1
case name
set name 1
case none
return
...
24 24 ----------> set informative 1
12 31 --------> switch $upstream
case git
set upstream '@{upstream}'
case svn\*
# get the upstream from the 'git-svn-id: …' in a commit message
# (git-svn uses essentially the same procedure internally)
set -l svn_upstream (git log --first-parent -1 --grep="^git-svn-id: \($svn_url_pattern\)" 2>/dev/null)
if test (count $svn_upstream) -ne 0
echo $svn_upstream[-1] | read -l __ svn_upstream __
set svn_upstream (string replace -r '@.*' '' -- $svn_upstream)
set -l cur_prefix
for i in (seq (count $svn_remote))
set -l remote $svn_remote[$i]
set -l mod_upstream (string replace "$remote" "" -- $svn_upstream)
if test "$svn_upstream" != "$mod_upstream"
# we found a valid remote
set svn_upstream $mod_upstream
set cur_prefix $svn_prefix[$i]
break
end
end
if test -z "$svn_upstream"
# default branch name for checkouts with no layout:
if test -n "$GIT_SVN_ID"
set upstream $GIT_SVN_ID
else
set upstream git-svn
end
else
set upstream (string replace '/branches' '' -- $svn_upstream | string replace -a '/' '')
# Use fetch config to fix upstream
set -l fetch_val (command git config "$cur_prefix".fetch)
if test -n "$fetch_val"
string split -m1 : -- "$fetch_val" | read -l trunk pattern
set upstream (string replace -r -- "/$trunk\$" '' $pattern) /$upstream
end
end
else if test $upstream = svn+git
set upstream '@{upstream}'
end
...
19 19 ---------> set upstream '@{upstream}'
68 6793 --------> set count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
6725 6725 ---------> command git rev-list --count --left-right $upstream...HEAD 2>/dev/null
37 797 --------> if test -n "$verbose"
# Verbose has a space by default
set -l prefix "$___fish_git_prompt_char_upstream_prefix"
# Using two underscore version to check if user explicitly set to nothing
if not set -q __fish_git_prompt_char_upstream_prefix
set -l prefix " "
end
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
end
if test -n "$count" -a -n "$name"
echo " "(command git rev-parse --abbrev-ref "$upstream" 2>/dev/null)
end
else if test -n "$informative"
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
end
else
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged"
end
...
22 22 ---------> test -n "$verbose"
16 16 ---------> test -n "$informative"
695 695 ---------> echo $count | read -l behind ahead
27 27 ---------> switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
...
32 32 ----> set -l branch_color $___fish_git_prompt_color_branch
21 21 ----> set -l branch_done $___fish_git_prompt_color_branch_done
2 31 ----> if set -q __fish_git_prompt_showcolorhints
if test $detached = yes
set branch_color $___fish_git_prompt_color_branch_detached
set branch_done $___fish_git_prompt_color_branch_detached_done
end
...
29 29 -----> set -q __fish_git_prompt_showcolorhints
2 20 ----> if test -n "$w"
set w "$___fish_git_prompt_color_dirtystate$w$___fish_git_prompt_color_dirtystate_done"
...
18 18 -----> test -n "$w"
1 16 ----> if test -n "$i"
set i "$___fish_git_prompt_color_stagedstate$i$___fish_git_prompt_color_stagedstate_done"
...
15 15 -----> test -n "$i"
1 15 ----> if test -n "$s"
set s "$___fish_git_prompt_color_stashstate$s$___fish_git_prompt_color_stashstate_done"
...
14 14 -----> test -n "$s"
2 14 ----> if test -n "$u"
set u "$___fish_git_prompt_color_untrackedfiles$u$___fish_git_prompt_color_untrackedfiles_done"
...
12 12 -----> test -n "$u"
51 78 ----> set b (string replace refs/heads/ '' -- $b)
27 27 -----> string replace refs/heads/ '' -- $b
14 14 ----> set -q __fish_git_prompt_shorten_branch_char_suffix
17 17 ----> set -l __fish_git_prompt_shorten_branch_char_suffix "…"
3 37 ----> if string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"; and test (string length "$b") -gt $__fish_git_prompt_shorten_branch_len
set b (string sub -l "$__fish_git_prompt_shorten_branch_len" "$b")"$__fish_git_prompt_shorten_branch_char_suffix"
...
34 34 -----> string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"
14 55 ----> if test -n "$b"
set b "$branch_color$b$branch_done"
...
17 17 -----> test -n "$b"
24 24 -----> set b "$branch_color$b$branch_done"
2 16 ----> if test -n "$c"
set c "$___fish_git_prompt_color_bare$c$___fish_git_prompt_color_bare_done"
...
14 14 -----> test -n "$c"
1 14 ----> if test -n "$r"
set r "$___fish_git_prompt_color_merging$r$___fish_git_prompt_color_merging_done"
...
13 13 -----> test -n "$r"
1 14 ----> if test -n "$p"
set p "$___fish_git_prompt_color_upstream$p$___fish_git_prompt_color_upstream_done"
...
13 13 -----> test -n "$p"
18 18 ----> set -l f "$w$i$s$u"
2 15 ----> if test -n "$f"
set f "$space$f"
...
13 13 -----> test -n "$f"
17 17 ----> set -l format $argv[1]
12 42 ----> if test -z "$format"
set format " (%s)"
...
14 14 -----> test -z "$format"
16 16 -----> set format " (%s)"
50 50 ----> printf "%s$format%s" "$___fish_git_prompt_color_prefix" "$___fish_git_prompt_color_prefix_done$c$b$f$r$p$informative_status$___fish_git_prompt_color_suffix" "$___fish_git_prompt_color_suffix_done"
91 754 ---> __fish_hg_prompt
324 591 ----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_hg_prompt.fish
25 25 -----> set -g fish_color_hg_clean green
17 17 -----> set -g fish_color_hg_modified yellow
14 14 -----> set -g fish_color_hg_dirty red
15 15 -----> set -g fish_color_hg_added green
15 15 -----> set -g fish_color_hg_renamed magenta
16 16 -----> set -g fish_color_hg_copied magenta
14 14 -----> set -g fish_color_hg_deleted red
14 14 -----> set -g fish_color_hg_untracked yellow
13 13 -----> set -g fish_color_hg_unmerged red
15 15 -----> set -g fish_prompt_hg_status_added '✚'
15 15 -----> set -g fish_prompt_hg_status_modified '*'
14 14 -----> set -g fish_prompt_hg_status_copied '⇒'
15 15 -----> set -g fish_prompt_hg_status_deleted '✖'
14 14 -----> set -g fish_prompt_hg_status_untracked '?'
15 15 -----> set -g fish_prompt_hg_status_unmerged '!'
23 23 -----> set -g fish_prompt_hg_status_order added modified copied deleted untracked unmerged
13 13 -----> function __fish_hg_prompt --description 'Write out the hg prompt'
# If hg isn't installed, there's nothing we can do
# Return 1 so the calling prompt can deal with it
if not command -sq hg
return 1
end
set -l root (fish_print_hg_root)
or return 0
# Read branch and bookmark
set -l branch (cat $root/branch 2>/dev/null; or echo default)
if set -l bookmark (cat $root/bookmarks.current 2>/dev/null)
set branch "$branch|$bookmark"
end
echo -n '|'
# For some reason, "-q" still prints the same output, but ~20% faster.
# Disabling color and pager is always a good idea.
set -l repo_status (hg status -q --color never --pager never | string sub -l 2 | sort -u)
# Show nice color for a clean repo
if test -z "$repo_status"
set_color $fish_color_hg_clean
echo -n "($branch)"'✓'
set_color normal
# Handle modified or dirty (unknown state)
else
set -l hg_statuses
# Take actions for the statuses of the files in the repo
for line in $repo_status
# Add a character for each file status if we have one
# HACK: To allow this to work both with and without '?' globs
set -l q '?'
switch $line
case 'A '
set -a hg_statuses added
case 'M ' ' M'
set -a hg_statuses modified
case 'C '
set -a hg_statuses copied
case 'D ' ' D'
set -a hg_statuses deleted
case "$dq "
set -a hg_statuses untracked
case 'U*' '*U' 'DD' 'AA'
set -a hg_statuses unmerged
end
end
if string match -qr '^[AMCD]' $repo_status
set_color $fish_color_hg_modified
else
set_color $fish_color_hg_dirty
end
echo -n "($branch)"'⚡'
# Sort status symbols
for i in $fish_prompt_hg_status_order
if contains -- $i $hg_statuses
set -l color_name fish_color_hg_$i
set -l status_name fish_prompt_hg_status_$i
set_color $$color_name
echo -n $$status_name
end
end
set_color normal
end
...
6 72 ----> if not command -sq hg
return 1
...
53 53 -----> not command -sq hg
13 13 -----> return 1
85 11659 ---> __fish_svn_prompt
509 1086 ----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_svn_prompt.fish
25 25 -----> set -g __fish_svn_prompt_color_revision yellow
19 19 -----> set -g __fish_svn_prompt_char_separator "|"
17 17 -----> set -g __fish_svn_prompt_char_added_display 'A'
16 16 -----> set -g __fish_svn_prompt_char_added_color green
16 16 -----> set -g __fish_svn_prompt_char_conflicted_display 'C'
16 16 -----> set -g __fish_svn_prompt_char_conflicted_color --underline magenta
15 15 -----> set -g __fish_svn_prompt_char_deleted_display 'D'
14 14 -----> set -g __fish_svn_prompt_char_deleted_color red
14 14 -----> set -g __fish_svn_prompt_char_ignored_display 'I'
15 15 -----> set -g __fish_svn_prompt_char_ignored_color --bold yellow
15 15 -----> set -g __fish_svn_prompt_char_modified_display 'M'
13 13 -----> set -g __fish_svn_prompt_char_modified_color blue
16 16 -----> set -g __fish_svn_prompt_char_replaced_display 'R'
13 13 -----> set -g __fish_svn_prompt_char_replaced_color cyan
15 15 -----> set -g __fish_svn_prompt_char_unversioned_external_display 'X'
16 16 -----> set -g __fish_svn_prompt_char_unversioned_external_color --underline cyan
15 15 -----> set -g __fish_svn_prompt_char_unversioned_display '?'
14 14 -----> set -g __fish_svn_prompt_char_unversioned_color purple
15 15 -----> set -g __fish_svn_prompt_char_missing_display '!'
14 14 -----> set -g __fish_svn_prompt_char_missing_color yellow
14 14 -----> set -g __fish_svn_prompt_char_versioned_obstructed_display '~'
14 14 -----> set -g __fish_svn_prompt_char_versioned_obstructed_color magenta
15 15 -----> set -g __fish_svn_prompt_char_locked_display 'L'
15 15 -----> set -g __fish_svn_prompt_char_locked_color --bold red
15 15 -----> set -g __fish_svn_prompt_char_scheduled_display '+'
17 17 -----> set -g __fish_svn_prompt_char_scheduled_color --bold green
15 15 -----> set -g __fish_svn_prompt_char_switched_display 'S'
15 15 -----> set -g __fish_svn_prompt_char_switched_color --bold blue
15 15 -----> set -g __fish_svn_prompt_char_token_present_display 'K'
15 15 -----> set -g __fish_svn_prompt_char_token_present_color --bold cyan
15 15 -----> set -g __fish_svn_prompt_char_token_other_display 'O'
16 16 -----> set -g __fish_svn_prompt_char_token_other_color --underline purple
15 15 -----> set -g __fish_svn_prompt_char_token_stolen_display 'T'
15 15 -----> set -g __fish_svn_prompt_char_token_stolen_color --bold purple
15 15 -----> set -g __fish_svn_prompt_char_token_broken_display 'B'
15 15 -----> set -g __fish_svn_prompt_char_token_broken_color --bold magenta
15 15 -----> function __fish_svn_prompt_parse_status --argument flag_status_string --description "helper function that does pretty formatting on svn status"
# SVN status symbols
# Do not change these! These are the expected characters that are output from `svn status`, they are taken from `svn help status`
set -l __fish_svn_prompt_chars A C D I M R X \? ! ~ L + S K O T B
# this sets up an array of all the types of status codes that could be returned.
set -l __fish_svn_prompt_flag_names added conflicted deleted ignored modified replaced unversioned_external unversioned missing locked scheduled switched token_present token_other token_stolen token_broken
# iterate over the different status types
for flag_type in $__fish_svn_prompt_flag_names
# resolve the name of the variable for the character representing the current status type
set -l flag_index (contains -i $flag_type $__fish_svn_prompt_flag_names)
# check to see if the status string for this column contains the character representing the current status type
if test (echo $flag_status_string | grep -c $__fish_svn_prompt_chars[$flag_index]) -eq 1
# if it does, then get the names of the variables for the display character and colour to format it with
set -l flag_var_display __fish_svn_prompt_char_{$flag_type}_display
set -l flag_var_color __fish_svn_prompt_char_{$flag_type}_color
# set the colour and print display character, then restore to default display colour
printf '%s%s%s' (set_color $$flag_var_color) $$flag_var_display (set_color normal)
end
end
...
8 8 -----> function __fish_svn_prompt --description "Prompt function for svn"
# if svn isn't installed then don't do anything
if not command -sq svn
return 1
end
# make sure that this is a svn repo
set -l checkout_info (command svn info 2>/dev/null)
if [ $status -ne 0 ]
return
end
# get the current revision number
printf '(%s%s%s' (set_color $__fish_svn_prompt_color_revision) (__fish_print_svn_rev) (set_color normal)
# resolve the status of the checkout
# 1. perform `svn status`
# 2. remove extra lines that aren't necessary
# 3. cut the output down to the first 7 columns, as these contain the information needed
set -l svn_status_lines (command svn status | sed -e 's=^Summary of conflicts.*==' -e 's=^ Text conflicts.*==' -e 's=^ Property conflicts.*==' -e 's=^ Tree conflicts.*==' -e 's=.*incoming .* upon update.*==' | cut -c 1-7)
# track the last column to contain a status flag
set -l last_column 0
# iterate over the 7 columns of output (the 7 columns are defined on `svn help status`)
for col in (seq 7)
# get the output for a particular column
# 1. echo the whole status flag text
# 2. cut out the current column of characters
# 3. remove spaces and newline characters
set -l column_status (printf '%s\n' $svn_status_lines | cut -c $col | tr -d ' \n')
# check that the character count is not zero (this would indicate that there are status flags in this column)
if [ (count $column_status) -ne 0 ]
# we only want to display unique status flags (eg: if there are 5 modified files, the prompt should only show the modified status once)
set -l column_unique_status (echo $column_status | sort -u)
# parse the status flags for this column and create the formatting by calling out to the helper function
set -l svn_status_flags (__fish_svn_prompt_parse_status $column_unique_status)
# the default separator is empty
set -l prompt_separator ""
for index in (seq (math "$col - $last_column"))
# the prompt separator variable has to be updated with the number of separators needed to represent empty status columns (eg: if a file has the status "A +" then it should display as "A|||+" in the prompt)
set prompt_separator $prompt_separator$__fish_svn_prompt_char_separator
end
# record that the current column was the last one printed to the prompt
set last_column $col
# print the separator string then the current column's status flags
printf '%s%s' $prompt_separator $svn_status_flags
end
end
# print the close of the svn status prompt
printf ')'
...
3 53 ----> if not command -sq svn
return 1
...
50 50 -----> not command -sq svn
66 10390 ----> set -l checkout_info (command svn info 2>/dev/null)
10324 10324 -----> command svn info 2>/dev/null
9 45 ----> if [ $status -ne 0 ]
return
...
24 24 -----> [ $status -ne 0 ]
12 12 -----> return
3 21 -> if not test $last_status -eq 0
set_color $fish_color_error
echo -n "[$last_status] "
set_color normal
...
18 18 --> not test $last_status -eq 0
14 14 -> echo
16 16 -> echo -n "$suffix "
15 116 > fish_title
54 101 -> echo (status current-command) (__fish_pwd)
17 17 --> status current-command
15 30 --> __fish_pwd
15 15 ---> pwd
15 83 > fish_mode_prompt
19 68 -> fish_default_mode_prompt
4 49 --> if test "$fish_key_bindings" = "fish_vi_key_bindings"
or test "$fish_key_bindings" = "fish_hybrid_key_bindings"
switch $fish_bind_mode
case default
set_color --bold --background red white
echo '[N]'
case insert
set_color --bold --background green white
echo '[I]'
case replace_one
set_color --bold --background green white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
...
25 25 ---> test "$fish_key_bindings" = "fish_vi_key_bindings"
20 20 ---> test "$fish_key_bindings" = "fish_hybrid_key_bindings"
53 70990 > fish_prompt
19 19 -> set -l last_status $status
2 16 -> if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
...
14 14 --> not set -q __fish_git_prompt_show_informative_status
2 14 -> if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
...
12 12 --> not set -q __fish_git_prompt_hide_untrackedfiles
2 15 -> if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch magenta --bold
...
13 13 --> not set -q __fish_git_prompt_color_branch
2 14 -> if not set -q __fish_git_prompt_showupstream
set -g __fish_git_prompt_showupstream "informative"
...
12 12 --> not set -q __fish_git_prompt_showupstream
2 13 -> if not set -q __fish_git_prompt_char_upstream_ahead
set -g __fish_git_prompt_char_upstream_ahead "↑"
...
11 11 --> not set -q __fish_git_prompt_char_upstream_ahead
2 13 -> if not set -q __fish_git_prompt_char_upstream_behind
set -g __fish_git_prompt_char_upstream_behind "↓"
...
11 11 --> not set -q __fish_git_prompt_char_upstream_behind
3 14 -> if not set -q __fish_git_prompt_char_upstream_prefix
set -g __fish_git_prompt_char_upstream_prefix ""
...
11 11 --> not set -q __fish_git_prompt_char_upstream_prefix
1 13 -> if not set -q __fish_git_prompt_char_stagedstate
set -g __fish_git_prompt_char_stagedstate "●"
...
12 12 --> not set -q __fish_git_prompt_char_stagedstate
1 13 -> if not set -q __fish_git_prompt_char_dirtystate
set -g __fish_git_prompt_char_dirtystate "✚"
...
12 12 --> not set -q __fish_git_prompt_char_dirtystate
1 13 -> if not set -q __fish_git_prompt_char_untrackedfiles
set -g __fish_git_prompt_char_untrackedfiles "…"
...
12 12 --> not set -q __fish_git_prompt_char_untrackedfiles
1 13 -> if not set -q __fish_git_prompt_char_invalidstate
set -g __fish_git_prompt_char_invalidstate "✖"
...
12 12 --> not set -q __fish_git_prompt_char_invalidstate
2 13 -> if not set -q __fish_git_prompt_char_cleanstate
set -g __fish_git_prompt_char_cleanstate "✔"
...
11 11 --> not set -q __fish_git_prompt_char_cleanstate
3 14 -> if not set -q __fish_git_prompt_color_dirtystate
set -g __fish_git_prompt_color_dirtystate blue
...
11 11 --> not set -q __fish_git_prompt_color_dirtystate
2 14 -> if not set -q __fish_git_prompt_color_stagedstate
set -g __fish_git_prompt_color_stagedstate yellow
...
12 12 --> not set -q __fish_git_prompt_color_stagedstate
1 13 -> if not set -q __fish_git_prompt_color_invalidstate
set -g __fish_git_prompt_color_invalidstate red
...
12 12 --> not set -q __fish_git_prompt_color_invalidstate
2 13 -> if not set -q __fish_git_prompt_color_untrackedfiles
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
...
11 11 --> not set -q __fish_git_prompt_color_untrackedfiles
2 13 -> if not set -q __fish_git_prompt_color_cleanstate
set -g __fish_git_prompt_color_cleanstate green --bold
...
11 11 --> not set -q __fish_git_prompt_color_cleanstate
1 13 -> if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
...
12 12 --> not set -q __fish_prompt_normal
14 14 -> set -l color_cwd
13 13 -> set -l prefix
12 12 -> set -l suffix
15 48 -> switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
case '*'
set color_cwd $fish_color_cwd
set suffix '$'
...
18 18 --> set color_cwd $fish_color_cwd
15 15 --> set suffix '$'
27 27 -> set_color $color_cwd
37 299 -> echo -n (prompt_pwd)
23 262 --> prompt_pwd
19 19 ---> set -l options 'h/help'
24 24 ---> argparse -n prompt_pwd --max-args=0 $options -- $argv
3 15 ---> if set -q _flag_help
__fish_print_help prompt_pwd
return 0
...
12 12 ----> set -q _flag_help
12 12 ---> set -q fish_prompt_pwd_dir_length
14 14 ---> set -l fish_prompt_pwd_dir_length 1
19 19 ---> set realhome ~
41 81 ---> set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)
40 40 ----> string replace -r '^'"$realhome"'($|/)' '~$1' $PWD
6 55 ---> if [ $fish_prompt_pwd_dir_length -eq 0 ]
echo $tmp
else
# Shorten to at most $fish_prompt_pwd_dir_length characters per directory
string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
...
17 17 ----> [ $fish_prompt_pwd_dir_length -eq 0 ]
32 32 ----> string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
21 21 -> set_color normal
6 1152 -> if set -q VIRTUAL_ENV
echo -n " ("(basename "$VIRTUAL_ENV")")"
...
13 13 --> set -q VIRTUAL_ENV
48 1133 --> echo -n " ("(basename "$VIRTUAL_ENV")")"
1085 1085 ---> basename "$VIRTUAL_ENV"
65 69030 -> printf '%s ' (__fish_vcs_prompt)
24 68965 --> __fish_vcs_prompt
108 57422 ---> __fish_git_prompt
2 53 ----> if not command -sq git
return 1
...
51 51 -----> not command -sq git
131 6230 ----> set -l repo_info (command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null)
6099 6099 -----> command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null
23 23 ----> test -n "$repo_info"
21 21 ----> set -l git_dir $repo_info[1]
19 19 ----> set -l inside_gitdir $repo_info[2]
18 18 ----> set -l bare_repo $repo_info[3]
18 18 ----> set -l inside_worktree $repo_info[4]
15 15 ----> set -q repo_info[5]
18 18 ----> set -l sha $repo_info[5]
78 8188 ----> set -l rbc (__fish_git_prompt_operation_branch_bare $repo_info)
88 8110 -----> __fish_git_prompt_operation_branch_bare $repo_info
20 20 ------> set -l git_dir $argv[1]
18 18 ------> set -l inside_gitdir $argv[2]
17 17 ------> set -l bare_repo $argv[3]
14 14 ------> set -q argv[5]
17 17 ------> set -l sha $argv[5]
13 13 ------> set -l branch
13 13 ------> set -l operation
13 13 ------> set -l detached no
13 13 ------> set -l bare
12 12 ------> set -l step
12 12 ------> set -l total
14 14 ------> set -l os
42 155 ------> if test -d $git_dir/rebase-merge
set branch (cat $git_dir/rebase-merge/head-name 2>/dev/null)
set step (cat $git_dir/rebase-merge/msgnum 2>/dev/null)
set total (cat $git_dir/rebase-merge/end 2>/dev/null)
if test -f $git_dir/rebase-merge/interactive
set operation "|REBASE-i"
else
set operation "|REBASE-m"
end
else
if test -d $git_dir/rebase-apply
set step (cat $git_dir/rebase-apply/next 2>/dev/null)
set total (cat $git_dir/rebase-apply/last 2>/dev/null)
if test -f $git_dir/rebase-apply/rebasing
set branch (cat $git_dir/rebase-apply/head-name 2>/dev/null)
set operation "|REBASE"
else if test -f $git_dir/rebase-apply/applying
set operation "|AM"
else
set operation "|AM/REBASE"
end
else if test -f $git_dir/MERGE_HEAD
set operation "|MERGING"
else if test -f $git_dir/CHERRY_PICK_HEAD
set operation "|CHERRY-PICKING"
else if test -f $git_dir/REVERT_HEAD
set operation "|REVERTING"
else if test -f $git_dir/BISECT_LOG
set operation "|BISECTING"
end
...
19 19 -------> test -d $git_dir/rebase-merge
9 94 -------> if test -d $git_dir/rebase-apply
set step (cat $git_dir/rebase-apply/next 2>/dev/null)
set total (cat $git_dir/rebase-apply/last 2>/dev/null)
if test -f $git_dir/rebase-apply/rebasing
set branch (cat $git_dir/rebase-apply/head-name 2>/dev/null)
set operation "|REBASE"
else if test -f $git_dir/rebase-apply/applying
set operation "|AM"
else
set operation "|AM/REBASE"
end
else if test -f $git_dir/MERGE_HEAD
set operation "|MERGING"
else if test -f $git_dir/CHERRY_PICK_HEAD
set operation "|CHERRY-PICKING"
else if test -f $git_dir/REVERT_HEAD
set operation "|REVERTING"
else if test -f $git_dir/BISECT_LOG
set operation "|BISECTING"
...
18 18 --------> test -d $git_dir/rebase-apply
18 18 --------> test -f $git_dir/MERGE_HEAD
17 17 --------> test -f $git_dir/CHERRY_PICK_HEAD
16 16 --------> test -f $git_dir/REVERT_HEAD
16 16 --------> test -f $git_dir/BISECT_LOG
1 21 ------> if test -n "$step" -a -n "$total"
set operation "$operation $step/$total"
...
20 20 -------> test -n "$step" -a -n "$total"
28 7575 ------> if test -z "$branch"
set branch (command git symbolic-ref HEAD 2>/dev/null; set os $status)
if test $os -ne 0
set detached yes
set branch (switch "$__fish_git_prompt_describe_style"
case contains
command git describe --contains HEAD
case branch
command git describe --contains --all HEAD
case describe
command git describe HEAD
case default '*'
command git describe --tags --exact-match HEAD
end 2>/dev/null; set os $status)
if test $os -ne 0
# Shorten the sha ourselves to 8 characters - this should be good for most repositories,
# and even for large ones it should be good for most commits
if set -q sha
set branch (string match -r '^.{8}' -- $sha)…
else
set branch unknown
end
end
set branch "($branch)"
end
...
14 14 -------> test -z "$branch"
75 7508 -------> set branch (command git symbolic-ref HEAD 2>/dev/null; set os $status)
7388 7388 --------> command git symbolic-ref HEAD 2>/dev/null
45 45 --------> set os $status
2 25 -------> if test $os -ne 0
set detached yes
set branch (switch "$__fish_git_prompt_describe_style"
case contains
command git describe --contains HEAD
case branch
command git describe --contains --all HEAD
case describe
command git describe HEAD
case default '*'
command git describe --tags --exact-match HEAD
end 2>/dev/null; set os $status)
if test $os -ne 0
# Shorten the sha ourselves to 8 characters - this should be good for most repositories,
# and even for large ones it should be good for most commits
if set -q sha
set branch (string match -r '^.{8}' -- $sha)…
else
set branch unknown
end
end
set branch "($branch)"
...
23 23 --------> test $os -ne 0
2 25 ------> if test "true" = $inside_gitdir
if test "true" = $bare_repo
set bare "BARE:"
else
# Let user know they're inside the git dir of a non-bare repo
set branch "GIT_DIR!"
end
...
23 23 -------> test "true" = $inside_gitdir
19 19 ------> echo $operation
20 20 ------> echo $branch
16 16 ------> echo $detached
15 15 ------> echo $bare
21 21 ----> set -l r $rbc[1]
20 20 ----> set -l b $rbc[2]
23 23 ----> set -l detached $rbc[3]
15 15 ----> set -l w
14 14 ----> set -l i
13 13 ----> set -l s
16 16 ----> set -l u
20 20 ----> set -l c $rbc[4]
13 13 ----> set -l p
16 16 ----> set -l informative_status
1 17 ----> if not set -q ___fish_git_prompt_init
# This takes a while, so it only needs to be done once,
# and then whenever the configuration changes.
__fish_git_prompt_validate_chars
__fish_git_prompt_validate_colors
set -g ___fish_git_prompt_init
...
16 16 -----> not set -q ___fish_git_prompt_init
30 30 ----> set -l space "$___fish_git_prompt_color$___fish_git_prompt_char_stateseparator$___fish_git_prompt_color_done"
28 41873 ----> if test "true" = $inside_worktree
if set -q __fish_git_prompt_show_informative_status
set informative_status "$space"(__fish_git_prompt_informative_status)
else
if set -q __fish_git_prompt_showdirtystate
set -l config (command git config --bool bash.showDirtyState)
if test "$config" != "false"
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false
set u (__fish_git_prompt_untracked)
end
end
end
if set -q __fish_git_prompt_showupstream
or set -q __fish_git_prompt_show_informative_status
set p (__fish_git_prompt_show_upstream)
end
...
20 20 -----> test "true" = $inside_worktree
14 25534 -----> if set -q __fish_git_prompt_show_informative_status
set informative_status "$space"(__fish_git_prompt_informative_status)
else
if set -q __fish_git_prompt_showdirtystate
set -l config (command git config --bool bash.showDirtyState)
if test "$config" != "false"
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false
set u (__fish_git_prompt_untracked)
end
end
...
15 15 ------> set -q __fish_git_prompt_show_informative_status
60 25505 ------> set informative_status "$space"(__fish_git_prompt_informative_status)
72 25445 -------> __fish_git_prompt_informative_status
109 8264 --------> set -l changedFiles (command git diff --name-status 2>/dev/null | string match -r \\w)
8155 8155 ---------> command git diff --name-status 2>/dev/null | string match -r \\w
99 8052 --------> set -l stagedFiles (command git diff --staged --name-status | string match -r \\w)
7953 7953 ---------> command git diff --staged --name-status | string match -r \\w
69 99 --------> set -l x (count $changedFiles)
30 30 ---------> count $changedFiles
54 141 --------> set -l y (count (string match -r "U" -- $changedFiles))
53 87 ---------> count (string match -r "U" -- $changedFiles)
34 34 ----------> string match -r "U" -- $changedFiles
55 86 --------> set -l dirtystate (math $x - $y)
31 31 ---------> math $x - $y
48 70 --------> set -l x (count $stagedFiles)
22 22 ---------> count $stagedFiles
50 125 --------> set -l invalidstate (count (string match -r "U" -- $stagedFiles))
48 75 ---------> count (string match -r "U" -- $stagedFiles)
27 27 ----------> string match -r "U" -- $stagedFiles
51 78 --------> set -l stagedstate (math $x - $invalidstate)
27 27 ---------> math $x - $invalidstate
89 8215 --------> set -l untrackedfiles (command git ls-files --others --exclude-standard | wc -l | string trim)
8126 8126 ---------> command git ls-files --others --exclude-standard | wc -l | string trim
21 21 --------> set -l info
65 110 --------> set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles 2>/dev/null)
45 45 ---------> math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles 2>/dev/null
20 90 --------> if test -z "$state"
or test "$state" = 0
set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
else
for i in $___fish_git_prompt_status_order
if [ $$i != "0" ]
set -l color_var ___fish_git_prompt_color_$i
set -l color_done_var ___fish_git_prompt_color_{$i}_done
set -l symbol_var ___fish_git_prompt_char_$i
set -l color $$color_var
set -l color_done $$color_done_var
set -l symbol $$symbol_var
set -l count
if not set -q __fish_git_prompt_hide_$i
set count $$i
end
set info "$info$color$symbol$count$color_done"
end
end
...
21 21 ---------> test -z "$state"
18 18 ---------> test "$state" = 0
31 31 ---------> set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
22 22 --------> echo $info
16 16291 -----> if set -q __fish_git_prompt_showupstream
or set -q __fish_git_prompt_show_informative_status
set p (__fish_git_prompt_show_upstream)
...
18 18 ------> set -q __fish_git_prompt_showupstream
65 16257 ------> set p (__fish_git_prompt_show_upstream)
109 16192 -------> __fish_git_prompt_show_upstream
15 15 --------> set -q __fish_git_prompt_showupstream
23 23 --------> set -l show_upstream $__fish_git_prompt_showupstream
17 17 --------> set -l svn_prefix
16 16 --------> set -l informative
20 20 --------> set -l svn_url_pattern
16 16 --------> set -l count
16 16 --------> set -l upstream git
15 15 --------> set -l verbose
15 15 --------> set -l name
22 53 --------> if set -q __fish_git_prompt_show_informative_status
set informative 1
...
15 15 ---------> set -q __fish_git_prompt_show_informative_status
16 16 ---------> set informative 1
15 15 --------> set -l svn_remote
313 7127 --------> command git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | while read -lz key value
switch $key
case bash.showupstream
set show_upstream $value
test -n "$show_upstream"
or return
case svn-remote.'*'.url
set svn_remote $svn_remote $value
# Avoid adding \| to the beginning to avoid needing #?? later
if test -n "$svn_url_pattern"
set svn_url_pattern $svn_url_pattern"|$value"
else
set svn_url_pattern $value
end
set upstream svn+git # default upstream is SVN if available, else git
# Save the config key (without .url) for later use
set -l remote_prefix (string replace -r '\.url$' '' -- $key)
set svn_prefix $svn_prefix $remote_prefix
end
end
6814 6814 ---------> read -lz key value
31 78 --------> for option in $show_upstream
switch $option
case git svn
set upstream $option
set -e informative
case verbose
set verbose 1
set -e informative
case informative
set informative 1
case name
set name 1
case none
return
end
...
20 47 ---------> switch $option
case git svn
set upstream $option
set -e informative
case verbose
set verbose 1
set -e informative
case informative
set informative 1
case name
set name 1
case none
return
...
27 27 ----------> set informative 1
15 36 --------> switch $upstream
case git
set upstream '@{upstream}'
case svn\*
# get the upstream from the 'git-svn-id: …' in a commit message
# (git-svn uses essentially the same procedure internally)
set -l svn_upstream (git log --first-parent -1 --grep="^git-svn-id: \($svn_url_pattern\)" 2>/dev/null)
if test (count $svn_upstream) -ne 0
echo $svn_upstream[-1] | read -l __ svn_upstream __
set svn_upstream (string replace -r '@.*' '' -- $svn_upstream)
set -l cur_prefix
for i in (seq (count $svn_remote))
set -l remote $svn_remote[$i]
set -l mod_upstream (string replace "$remote" "" -- $svn_upstream)
if test "$svn_upstream" != "$mod_upstream"
# we found a valid remote
set svn_upstream $mod_upstream
set cur_prefix $svn_prefix[$i]
break
end
end
if test -z "$svn_upstream"
# default branch name for checkouts with no layout:
if test -n "$GIT_SVN_ID"
set upstream $GIT_SVN_ID
else
set upstream git-svn
end
else
set upstream (string replace '/branches' '' -- $svn_upstream | string replace -a '/' '')
# Use fetch config to fix upstream
set -l fetch_val (command git config "$cur_prefix".fetch)
if test -n "$fetch_val"
string split -m1 : -- "$fetch_val" | read -l trunk pattern
set upstream (string replace -r -- "/$trunk\$" '' $pattern) /$upstream
end
end
else if test $upstream = svn+git
set upstream '@{upstream}'
end
...
21 21 ---------> set upstream '@{upstream}'
80 7710 --------> set count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
7630 7630 ---------> command git rev-list --count --left-right $upstream...HEAD 2>/dev/null
52 911 --------> if test -n "$verbose"
# Verbose has a space by default
set -l prefix "$___fish_git_prompt_char_upstream_prefix"
# Using two underscore version to check if user explicitly set to nothing
if not set -q __fish_git_prompt_char_upstream_prefix
set -l prefix " "
end
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
end
if test -n "$count" -a -n "$name"
echo " "(command git rev-parse --abbrev-ref "$upstream" 2>/dev/null)
end
else if test -n "$informative"
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
end
else
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged"
end
...
25 25 ---------> test -n "$verbose"
19 19 ---------> test -n "$informative"
782 782 ---------> echo $count | read -l behind ahead
33 33 ---------> switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
...
35 35 ----> set -l branch_color $___fish_git_prompt_color_branch
26 26 ----> set -l branch_done $___fish_git_prompt_color_branch_done
3 36 ----> if set -q __fish_git_prompt_showcolorhints
if test $detached = yes
set branch_color $___fish_git_prompt_color_branch_detached
set branch_done $___fish_git_prompt_color_branch_detached_done
end
...
33 33 -----> set -q __fish_git_prompt_showcolorhints
2 23 ----> if test -n "$w"
set w "$___fish_git_prompt_color_dirtystate$w$___fish_git_prompt_color_dirtystate_done"
...
21 21 -----> test -n "$w"
1 19 ----> if test -n "$i"
set i "$___fish_git_prompt_color_stagedstate$i$___fish_git_prompt_color_stagedstate_done"
...
18 18 -----> test -n "$i"
2 17 ----> if test -n "$s"
set s "$___fish_git_prompt_color_stashstate$s$___fish_git_prompt_color_stashstate_done"
...
15 15 -----> test -n "$s"
2 17 ----> if test -n "$u"
set u "$___fish_git_prompt_color_untrackedfiles$u$___fish_git_prompt_color_untrackedfiles_done"
...
15 15 -----> test -n "$u"
60 94 ----> set b (string replace refs/heads/ '' -- $b)
34 34 -----> string replace refs/heads/ '' -- $b
16 16 ----> set -q __fish_git_prompt_shorten_branch_char_suffix
19 19 ----> set -l __fish_git_prompt_shorten_branch_char_suffix "…"
3 39 ----> if string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"; and test (string length "$b") -gt $__fish_git_prompt_shorten_branch_len
set b (string sub -l "$__fish_git_prompt_shorten_branch_len" "$b")"$__fish_git_prompt_shorten_branch_char_suffix"
...
36 36 -----> string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"
14 60 ----> if test -n "$b"
set b "$branch_color$b$branch_done"
...
20 20 -----> test -n "$b"
26 26 -----> set b "$branch_color$b$branch_done"
2 18 ----> if test -n "$c"
set c "$___fish_git_prompt_color_bare$c$___fish_git_prompt_color_bare_done"
...
16 16 -----> test -n "$c"
2 17 ----> if test -n "$r"
set r "$___fish_git_prompt_color_merging$r$___fish_git_prompt_color_merging_done"
...
15 15 -----> test -n "$r"
2 17 ----> if test -n "$p"
set p "$___fish_git_prompt_color_upstream$p$___fish_git_prompt_color_upstream_done"
...
15 15 -----> test -n "$p"
21 21 ----> set -l f "$w$i$s$u"
1 16 ----> if test -n "$f"
set f "$space$f"
...
15 15 -----> test -n "$f"
21 21 ----> set -l format $argv[1]
14 49 ----> if test -z "$format"
set format " (%s)"
...
16 16 -----> test -z "$format"
19 19 -----> set format " (%s)"
60 60 ----> printf "%s$format%s" "$___fish_git_prompt_color_prefix" "$___fish_git_prompt_color_prefix_done$c$b$f$r$p$informative_status$___fish_git_prompt_color_suffix" "$___fish_git_prompt_color_suffix_done"
23 111 ---> __fish_hg_prompt
8 88 ----> if not command -sq hg
return 1
...
65 65 -----> not command -sq hg
15 15 -----> return 1
24 11408 ---> __fish_svn_prompt
2 55 ----> if not command -sq svn
return 1
...
53 53 -----> not command -sq svn
78 11274 ----> set -l checkout_info (command svn info 2>/dev/null)
11196 11196 -----> command svn info 2>/dev/null
12 55 ----> if [ $status -ne 0 ]
return
...
29 29 -----> [ $status -ne 0 ]
14 14 -----> return
2 24 -> if not test $last_status -eq 0
set_color $fish_color_error
echo -n "[$last_status] "
set_color normal
...
22 22 --> not test $last_status -eq 0
15 15 -> echo
19 19 -> echo -n "$suffix "
18 137 > fish_title
63 119 -> echo (status current-command) (__fish_pwd)
19 19 --> status current-command
18 37 --> __fish_pwd
19 19 ---> pwd
205 431311 > __fish_describe_command man
191 208 -> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_describe_command.fish
17 17 --> function __fish_describe_command -d "Command used to find descriptions for commands"
# We're going to try to build a regex out of $argv inside awk.
# Make sure $argv has no special characters.
# TODO: stop interpolating argv into regex, and remove this hack.
string match --quiet --regex '^[a-zA-Z0-9_ ]+$' -- "$argv"
or return
type -q apropos; or return
apropos $argv 2>/dev/null | awk -v FS=" +- +" '{
split($1, names, ", ");
for (name in names)
if (names[name] ~ /^'"$argv"'.* *\([18]\)/ ) {
sub( "( |\t)*\\\([18]\\\)", "", names[name] );
sub( " \\\[.*\\\]", "", names[name] );
print names[name] "\t" $2;
}
}'
...
55 55 -> string match --quiet --regex '^[a-zA-Z0-9_ ]+$' -- "$argv"
71 1107 -> type -q apropos
23 23 --> set -q argv[1]
42 42 --> set -l options 'h/help' 'a/all' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
74 74 --> argparse -n type -x t,p,P $options -- $argv
3 24 --> if set -q _flag_help
__fish_print_help type
return 0
...
21 21 ---> set -q _flag_help
20 20 --> set -l res 1
18 18 --> set -l mode normal
20 20 --> set -l multi no
20 20 --> set -l selection all
10 45 --> if set -q _flag_quiet
set mode quiet
else if set -q _flag_type
set mode type
else if set -q _flag_path
set mode path
else if set -q _flag_force_path
set mode path
set selection files
...
17 17 ---> set -q _flag_quiet
18 18 ---> set mode quiet
18 18 --> set -q _flag_all
17 17 --> set -q _flag_no_functions
33 694 --> for i in $argv
# Found will be set to 1 if a match is found.
set -l found 0
if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
end
set -l paths
if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
end
for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
end
if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
21 21 ---> set -l found 0
12 312 ---> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
end
if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
end
...
25 25 ----> test $selection != files
3 71 ----> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function with definition\n') $i
if isatty stdout
functions $i | fish_indent --ansi
else
functions $i | fish_indent
end
case type
echo (_ 'function')
end
if test $multi != yes
continue
end
...
68 68 -----> functions -q -- $i
3 204 ----> if contains -- $i (builtin -n)
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a builtin\n') $i
case type
echo (_ 'builtin')
end
if test $multi != yes
continue
end
...
152 201 -----> contains -- $i (builtin -n)
49 49 ------> builtin -n
23 23 ---> set -l paths
9 160 ---> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
23 23 ----> test $multi != yes
55 128 ----> set paths (command -s -- $i)
73 73 -----> command -s -- $i
26 121 ---> for path in $paths
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
end
if test $multi != yes
continue
end
...
19 19 ----> set res 0
19 19 ----> set found 1
11 11 ----> switch $mode
case normal
printf (_ '%s is %s\n') $i $path
case type
echo (_ 'file')
case path
echo $path
...
10 46 ----> if test $multi != yes
continue
...
21 21 -----> test $multi != yes
15 15 -----> continue
3 24 ---> if test $found = 0
and test $mode != quiet
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
21 21 ----> test $found = 0
21 21 --> return $res
429736 429736 -> apropos $argv 2>/dev/null | awk -v FS=" +- +" '{
split($1, names, ", ");
for (name in names)
if (names[name] ~ /^'"$argv"'.* *\([18]\)/ ) {
sub( "( |\t)*\\\([18]\\\)", "", names[name] );
sub( " \\\[.*\\\]", "", names[name] );
print names[name] "\t" $2;
}
}'
224 7350 > __fish_cancel_commandline
279 293 -> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/__fish_cancel_commandline.fish
14 14 --> function __fish_cancel_commandline
# Close the pager if it's open (#4298)
commandline -f cancel
set -l cmd (commandline)
if test -n "$cmd"
commandline -C 1000000
if set -q fish_color_cancel
echo -ns (set_color $fish_color_cancel) "^C" (set_color normal)
else
echo -ns "^C"
end
if command -sq tput
# Clear to EOL (to erase any autosuggestion).
echo -n (tput el; or tput ce)
end
for i in (seq (commandline -L))
echo ""
end
commandline ""
commandline -f repaint
end
...
91 91 -> commandline -f cancel
72 99 -> set -l cmd (commandline)
27 27 --> commandline
34 6643 -> if test -n "$cmd"
commandline -C 1000000
if set -q fish_color_cancel
echo -ns (set_color $fish_color_cancel) "^C" (set_color normal)
else
echo -ns "^C"
end
if command -sq tput
# Clear to EOL (to erase any autosuggestion).
echo -n (tput el; or tput ce)
end
for i in (seq (commandline -L))
echo ""
end
commandline ""
commandline -f repaint
...
31 31 --> test -n "$cmd"
95 95 --> commandline -C 1000000
11 243 --> if set -q fish_color_cancel
echo -ns (set_color $fish_color_cancel) "^C" (set_color normal)
else
echo -ns "^C"
...
26 26 ---> set -q fish_color_cancel
114 206 ---> echo -ns (set_color $fish_color_cancel) "^C" (set_color normal)
52 52 ----> set_color $fish_color_cancel
40 40 ----> set_color normal
16 3308 --> if command -sq tput
# Clear to EOL (to erase any autosuggestion).
echo -n (tput el; or tput ce)
...
92 92 ---> command -sq tput
97 3200 ---> echo -n (tput el; or tput ce)
3103 3103 ----> tput el
104 2813 --> for i in (seq (commandline -L))
echo ""
...
2274 2667 ---> seq (commandline -L)
280 363 ----> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/seq.fish
4 83 -----> if not command -sq seq
# No seq command
function seq --description "Print sequences of numbers"
__fish_fallback_seq $argv
end
function __fish_fallback_seq --description "Fallback implementation of the seq command"
set -l from 1
set -l step 1
set -l to 1
switch (count $argv)
case 1
set to $argv[1]
case 2
set from $argv[1]
set to $argv[2]
case 3
set from $argv[1]
set step $argv[2]
set to $argv[3]
case '*'
printf (_ "%s: Expected 1, 2 or 3 arguments, got %d\n") seq (count $argv)
return 1
end
for i in $from $step $to
if not string match -rq '^-?[0-9]*([0-9]*|\.[0-9]+)$' $i
printf (_ "%s: '%s' is not a number\n") seq $i
return 1
end
end
if [ $step -ge 0 ]
echo "for( i=$from; i<=$to ; i+=$step ) i;" | bc
else
echo "for( i=$from; i>=$to ; i+=$step ) i;" | bc
end
end
...
79 79 ------> not command -sq seq
30 30 ----> commandline -L
42 42 ---> echo ""
82 82 --> commandline ""
37 37 --> commandline -f repaint
23 124 > fish_mode_prompt
25 101 -> fish_default_mode_prompt
5 76 --> if test "$fish_key_bindings" = "fish_vi_key_bindings"
or test "$fish_key_bindings" = "fish_hybrid_key_bindings"
switch $fish_bind_mode
case default
set_color --bold --background red white
echo '[N]'
case insert
set_color --bold --background green white
echo '[I]'
case replace_one
set_color --bold --background green white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
...
40 40 ---> test "$fish_key_bindings" = "fish_vi_key_bindings"
31 31 ---> test "$fish_key_bindings" = "fish_hybrid_key_bindings"
77 68911 > fish_prompt
31 31 -> set -l last_status $status
2 22 -> if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
...
20 20 --> not set -q __fish_git_prompt_show_informative_status
2 20 -> if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
...
18 18 --> not set -q __fish_git_prompt_hide_untrackedfiles
2 20 -> if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch magenta --bold
...
18 18 --> not set -q __fish_git_prompt_color_branch
3 20 -> if not set -q __fish_git_prompt_showupstream
set -g __fish_git_prompt_showupstream "informative"
...
17 17 --> not set -q __fish_git_prompt_showupstream
2 21 -> if not set -q __fish_git_prompt_char_upstream_ahead
set -g __fish_git_prompt_char_upstream_ahead "↑"
...
19 19 --> not set -q __fish_git_prompt_char_upstream_ahead
2 19 -> if not set -q __fish_git_prompt_char_upstream_behind
set -g __fish_git_prompt_char_upstream_behind "↓"
...
17 17 --> not set -q __fish_git_prompt_char_upstream_behind
3 19 -> if not set -q __fish_git_prompt_char_upstream_prefix
set -g __fish_git_prompt_char_upstream_prefix ""
...
16 16 --> not set -q __fish_git_prompt_char_upstream_prefix
1 19 -> if not set -q __fish_git_prompt_char_stagedstate
set -g __fish_git_prompt_char_stagedstate "●"
...
18 18 --> not set -q __fish_git_prompt_char_stagedstate
2 20 -> if not set -q __fish_git_prompt_char_dirtystate
set -g __fish_git_prompt_char_dirtystate "✚"
...
18 18 --> not set -q __fish_git_prompt_char_dirtystate
2 20 -> if not set -q __fish_git_prompt_char_untrackedfiles
set -g __fish_git_prompt_char_untrackedfiles "…"
...
18 18 --> not set -q __fish_git_prompt_char_untrackedfiles
1 19 -> if not set -q __fish_git_prompt_char_invalidstate
set -g __fish_git_prompt_char_invalidstate "✖"
...
18 18 --> not set -q __fish_git_prompt_char_invalidstate
2 19 -> if not set -q __fish_git_prompt_char_cleanstate
set -g __fish_git_prompt_char_cleanstate "✔"
...
17 17 --> not set -q __fish_git_prompt_char_cleanstate
3 20 -> if not set -q __fish_git_prompt_color_dirtystate
set -g __fish_git_prompt_color_dirtystate blue
...
17 17 --> not set -q __fish_git_prompt_color_dirtystate
2 19 -> if not set -q __fish_git_prompt_color_stagedstate
set -g __fish_git_prompt_color_stagedstate yellow
...
17 17 --> not set -q __fish_git_prompt_color_stagedstate
2 19 -> if not set -q __fish_git_prompt_color_invalidstate
set -g __fish_git_prompt_color_invalidstate red
...
17 17 --> not set -q __fish_git_prompt_color_invalidstate
3 20 -> if not set -q __fish_git_prompt_color_untrackedfiles
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
...
17 17 --> not set -q __fish_git_prompt_color_untrackedfiles
3 21 -> if not set -q __fish_git_prompt_color_cleanstate
set -g __fish_git_prompt_color_cleanstate green --bold
...
18 18 --> not set -q __fish_git_prompt_color_cleanstate
2 19 -> if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
...
17 17 --> not set -q __fish_prompt_normal
20 20 -> set -l color_cwd
19 19 -> set -l prefix
18 18 -> set -l suffix
25 71 -> switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
case '*'
set color_cwd $fish_color_cwd
set suffix '$'
...
25 25 --> set color_cwd $fish_color_cwd
21 21 --> set suffix '$'
41 41 -> set_color $color_cwd
59 418 -> echo -n (prompt_pwd)
51 359 --> prompt_pwd
24 24 ---> set -l options 'h/help'
29 29 ---> argparse -n prompt_pwd --max-args=0 $options -- $argv
2 18 ---> if set -q _flag_help
__fish_print_help prompt_pwd
return 0
...
16 16 ----> set -q _flag_help
15 15 ---> set -q fish_prompt_pwd_dir_length
21 21 ---> set -l fish_prompt_pwd_dir_length 1
26 26 ---> set realhome ~
52 103 ---> set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)
51 51 ----> string replace -r '^'"$realhome"'($|/)' '~$1' $PWD
9 72 ---> if [ $fish_prompt_pwd_dir_length -eq 0 ]
echo $tmp
else
# Shorten to at most $fish_prompt_pwd_dir_length characters per directory
string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
...
22 22 ----> [ $fish_prompt_pwd_dir_length -eq 0 ]
41 41 ----> string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
28 28 -> set_color normal
9 1423 -> if set -q VIRTUAL_ENV
echo -n " ("(basename "$VIRTUAL_ENV")")"
...
18 18 --> set -q VIRTUAL_ENV
73 1396 --> echo -n " ("(basename "$VIRTUAL_ENV")")"
1323 1323 ---> basename "$VIRTUAL_ENV"
79 66356 -> printf '%s ' (__fish_vcs_prompt)
32 66277 --> __fish_vcs_prompt
121 55897 ---> __fish_git_prompt
3 70 ----> if not command -sq git
return 1
...
67 67 -----> not command -sq git
129 7275 ----> set -l repo_info (command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null)
7146 7146 -----> command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null
30 30 ----> test -n "$repo_info"
23 23 ----> set -l git_dir $repo_info[1]
20 20 ----> set -l inside_gitdir $repo_info[2]
20 20 ----> set -l bare_repo $repo_info[3]
20 20 ----> set -l inside_worktree $repo_info[4]
17 17 ----> set -q repo_info[5]
19 19 ----> set -l sha $repo_info[5]
62 9567 ----> set -l rbc (__fish_git_prompt_operation_branch_bare $repo_info)
91 9505 -----> __fish_git_prompt_operation_branch_bare $repo_info
21 21 ------> set -l git_dir $argv[1]
21 21 ------> set -l inside_gitdir $argv[2]
19 19 ------> set -l bare_repo $argv[3]
15 15 ------> set -q argv[5]
19 19 ------> set -l sha $argv[5]
15 15 ------> set -l branch
15 15 ------> set -l operation
15 15 ------> set -l detached no
13 13 ------> set -l bare
13 13 ------> set -l step
15 15 ------> set -l total
15 15 ------> set -l os
50 182 ------> if test -d $git_dir/rebase-merge
set branch (cat $git_dir/rebase-merge/head-name 2>/dev/null)
set step (cat $git_dir/rebase-merge/msgnum 2>/dev/null)
set total (cat $git_dir/rebase-merge/end 2>/dev/null)
if test -f $git_dir/rebase-merge/interactive
set operation "|REBASE-i"
else
set operation "|REBASE-m"
end
else
if test -d $git_dir/rebase-apply
set step (cat $git_dir/rebase-apply/next 2>/dev/null)
set total (cat $git_dir/rebase-apply/last 2>/dev/null)
if test -f $git_dir/rebase-apply/rebasing
set branch (cat $git_dir/rebase-apply/head-name 2>/dev/null)
set operation "|REBASE"
else if test -f $git_dir/rebase-apply/applying
set operation "|AM"
else
set operation "|AM/REBASE"
end
else if test -f $git_dir/MERGE_HEAD
set operation "|MERGING"
else if test -f $git_dir/CHERRY_PICK_HEAD
set operation "|CHERRY-PICKING"
else if test -f $git_dir/REVERT_HEAD
set operation "|REVERTING"
else if test -f $git_dir/BISECT_LOG
set operation "|BISECTING"
end
...
26 26 -------> test -d $git_dir/rebase-merge
8 106 -------> if test -d $git_dir/rebase-apply
set step (cat $git_dir/rebase-apply/next 2>/dev/null)
set total (cat $git_dir/rebase-apply/last 2>/dev/null)
if test -f $git_dir/rebase-apply/rebasing
set branch (cat $git_dir/rebase-apply/head-name 2>/dev/null)
set operation "|REBASE"
else if test -f $git_dir/rebase-apply/applying
set operation "|AM"
else
set operation "|AM/REBASE"
end
else if test -f $git_dir/MERGE_HEAD
set operation "|MERGING"
else if test -f $git_dir/CHERRY_PICK_HEAD
set operation "|CHERRY-PICKING"
else if test -f $git_dir/REVERT_HEAD
set operation "|REVERTING"
else if test -f $git_dir/BISECT_LOG
set operation "|BISECTING"
...
23 23 --------> test -d $git_dir/rebase-apply
20 20 --------> test -f $git_dir/MERGE_HEAD
19 19 --------> test -f $git_dir/CHERRY_PICK_HEAD
18 18 --------> test -f $git_dir/REVERT_HEAD
18 18 --------> test -f $git_dir/BISECT_LOG
3 24 ------> if test -n "$step" -a -n "$total"
set operation "$operation $step/$total"
...
21 21 -------> test -n "$step" -a -n "$total"
26 8856 ------> if test -z "$branch"
set branch (command git symbolic-ref HEAD 2>/dev/null; set os $status)
if test $os -ne 0
set detached yes
set branch (switch "$__fish_git_prompt_describe_style"
case contains
command git describe --contains HEAD
case branch
command git describe --contains --all HEAD
case describe
command git describe HEAD
case default '*'
command git describe --tags --exact-match HEAD
end 2>/dev/null; set os $status)
if test $os -ne 0
# Shorten the sha ourselves to 8 characters - this should be good for most repositories,
# and even for large ones it should be good for most commits
if set -q sha
set branch (string match -r '^.{8}' -- $sha)…
else
set branch unknown
end
end
set branch "($branch)"
end
...
16 16 -------> test -z "$branch"
91 8792 -------> set branch (command git symbolic-ref HEAD 2>/dev/null; set os $status)
8660 8660 --------> command git symbolic-ref HEAD 2>/dev/null
41 41 --------> set os $status
1 22 -------> if test $os -ne 0
set detached yes
set branch (switch "$__fish_git_prompt_describe_style"
case contains
command git describe --contains HEAD
case branch
command git describe --contains --all HEAD
case describe
command git describe HEAD
case default '*'
command git describe --tags --exact-match HEAD
end 2>/dev/null; set os $status)
if test $os -ne 0
# Shorten the sha ourselves to 8 characters - this should be good for most repositories,
# and even for large ones it should be good for most commits
if set -q sha
set branch (string match -r '^.{8}' -- $sha)…
else
set branch unknown
end
end
set branch "($branch)"
...
21 21 --------> test $os -ne 0
2 43 ------> if test "true" = $inside_gitdir
if test "true" = $bare_repo
set bare "BARE:"
else
# Let user know they're inside the git dir of a non-bare repo
set branch "GIT_DIR!"
end
...
41 41 -------> test "true" = $inside_gitdir
33 33 ------> echo $operation
38 38 ------> echo $branch
29 29 ------> echo $detached
13 13 ------> echo $bare
19 19 ----> set -l r $rbc[1]
18 18 ----> set -l b $rbc[2]
18 18 ----> set -l detached $rbc[3]
27 27 ----> set -l w
12 12 ----> set -l i
32 32 ----> set -l s
27 27 ----> set -l u
18 18 ----> set -l c $rbc[4]
12 12 ----> set -l p
14 14 ----> set -l informative_status
19 34 ----> if not set -q ___fish_git_prompt_init
# This takes a while, so it only needs to be done once,
# and then whenever the configuration changes.
__fish_git_prompt_validate_chars
__fish_git_prompt_validate_colors
set -g ___fish_git_prompt_init
...
15 15 -----> not set -q ___fish_git_prompt_init
26 26 ----> set -l space "$___fish_git_prompt_color$___fish_git_prompt_char_stateseparator$___fish_git_prompt_color_done"
44 37916 ----> if test "true" = $inside_worktree
if set -q __fish_git_prompt_show_informative_status
set informative_status "$space"(__fish_git_prompt_informative_status)
else
if set -q __fish_git_prompt_showdirtystate
set -l config (command git config --bool bash.showDirtyState)
if test "$config" != "false"
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false
set u (__fish_git_prompt_untracked)
end
end
end
if set -q __fish_git_prompt_showupstream
or set -q __fish_git_prompt_show_informative_status
set p (__fish_git_prompt_show_upstream)
end
...
18 18 -----> test "true" = $inside_worktree
27 23740 -----> if set -q __fish_git_prompt_show_informative_status
set informative_status "$space"(__fish_git_prompt_informative_status)
else
if set -q __fish_git_prompt_showdirtystate
set -l config (command git config --bool bash.showDirtyState)
if test "$config" != "false"
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if set -q __fish_git_prompt_showuntrackedfiles
set -l config (command git config --bool bash.showUntrackedFiles)
if test "$config" != false
set u (__fish_git_prompt_untracked)
end
end
...
14 14 ------> set -q __fish_git_prompt_show_informative_status
54 23699 ------> set informative_status "$space"(__fish_git_prompt_informative_status)
81 23645 -------> __fish_git_prompt_informative_status
142 7230 --------> set -l changedFiles (command git diff --name-status 2>/dev/null | string match -r \\w)
7088 7088 ---------> command git diff --name-status 2>/dev/null | string match -r \\w
88 7152 --------> set -l stagedFiles (command git diff --staged --name-status | string match -r \\w)
7064 7064 ---------> command git diff --staged --name-status | string match -r \\w
58 84 --------> set -l x (count $changedFiles)
26 26 ---------> count $changedFiles
45 116 --------> set -l y (count (string match -r "U" -- $changedFiles))
43 71 ---------> count (string match -r "U" -- $changedFiles)
28 28 ----------> string match -r "U" -- $changedFiles
46 77 --------> set -l dirtystate (math $x - $y)
31 31 ---------> math $x - $y
42 66 --------> set -l x (count $stagedFiles)
24 24 ---------> count $stagedFiles
44 107 --------> set -l invalidstate (count (string match -r "U" -- $stagedFiles))
41 63 ---------> count (string match -r "U" -- $stagedFiles)
22 22 ----------> string match -r "U" -- $stagedFiles
45 68 --------> set -l stagedstate (math $x - $invalidstate)
23 23 ---------> math $x - $invalidstate
74 8433 --------> set -l untrackedfiles (command git ls-files --others --exclude-standard | wc -l | string trim)
8359 8359 ---------> command git ls-files --others --exclude-standard | wc -l | string trim
18 18 --------> set -l info
57 98 --------> set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles 2>/dev/null)
41 41 ---------> math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles 2>/dev/null
18 95 --------> if test -z "$state"
or test "$state" = 0
set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
else
for i in $___fish_git_prompt_status_order
if [ $$i != "0" ]
set -l color_var ___fish_git_prompt_color_$i
set -l color_done_var ___fish_git_prompt_color_{$i}_done
set -l symbol_var ___fish_git_prompt_char_$i
set -l color $$color_var
set -l color_done $$color_done_var
set -l symbol $$symbol_var
set -l count
if not set -q __fish_git_prompt_hide_$i
set count $$i
end
set info "$info$color$symbol$count$color_done"
end
end
...
23 23 ---------> test -z "$state"
23 23 ---------> test "$state" = 0
31 31 ---------> set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
20 20 --------> echo $info
16 14114 -----> if set -q __fish_git_prompt_showupstream
or set -q __fish_git_prompt_show_informative_status
set p (__fish_git_prompt_show_upstream)
...
15 15 ------> set -q __fish_git_prompt_showupstream
56 14083 ------> set p (__fish_git_prompt_show_upstream)
102 14027 -------> __fish_git_prompt_show_upstream
14 14 --------> set -q __fish_git_prompt_showupstream
21 21 --------> set -l show_upstream $__fish_git_prompt_showupstream
14 14 --------> set -l svn_prefix
13 13 --------> set -l informative
14 14 --------> set -l svn_url_pattern
13 13 --------> set -l count
14 14 --------> set -l upstream git
14 14 --------> set -l verbose
14 14 --------> set -l name
20 47 --------> if set -q __fish_git_prompt_show_informative_status
set informative 1
...
13 13 ---------> set -q __fish_git_prompt_show_informative_status
14 14 ---------> set informative 1
14 14 --------> set -l svn_remote
284 6063 --------> command git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | while read -lz key value
switch $key
case bash.showupstream
set show_upstream $value
test -n "$show_upstream"
or return
case svn-remote.'*'.url
set svn_remote $svn_remote $value
# Avoid adding \| to the beginning to avoid needing #?? later
if test -n "$svn_url_pattern"
set svn_url_pattern $svn_url_pattern"|$value"
else
set svn_url_pattern $value
end
set upstream svn+git # default upstream is SVN if available, else git
# Save the config key (without .url) for later use
set -l remote_prefix (string replace -r '\.url$' '' -- $key)
set svn_prefix $svn_prefix $remote_prefix
end
end
5779 5779 ---------> read -lz key value
25 70 --------> for option in $show_upstream
switch $option
case git svn
set upstream $option
set -e informative
case verbose
set verbose 1
set -e informative
case informative
set informative 1
case name
set name 1
case none
return
end
...
19 45 ---------> switch $option
case git svn
set upstream $option
set -e informative
case verbose
set verbose 1
set -e informative
case informative
set informative 1
case name
set name 1
case none
return
...
26 26 ----------> set informative 1
13 32 --------> switch $upstream
case git
set upstream '@{upstream}'
case svn\*
# get the upstream from the 'git-svn-id: …' in a commit message
# (git-svn uses essentially the same procedure internally)
set -l svn_upstream (git log --first-parent -1 --grep="^git-svn-id: \($svn_url_pattern\)" 2>/dev/null)
if test (count $svn_upstream) -ne 0
echo $svn_upstream[-1] | read -l __ svn_upstream __
set svn_upstream (string replace -r '@.*' '' -- $svn_upstream)
set -l cur_prefix
for i in (seq (count $svn_remote))
set -l remote $svn_remote[$i]
set -l mod_upstream (string replace "$remote" "" -- $svn_upstream)
if test "$svn_upstream" != "$mod_upstream"
# we found a valid remote
set svn_upstream $mod_upstream
set cur_prefix $svn_prefix[$i]
break
end
end
if test -z "$svn_upstream"
# default branch name for checkouts with no layout:
if test -n "$GIT_SVN_ID"
set upstream $GIT_SVN_ID
else
set upstream git-svn
end
else
set upstream (string replace '/branches' '' -- $svn_upstream | string replace -a '/' '')
# Use fetch config to fix upstream
set -l fetch_val (command git config "$cur_prefix".fetch)
if test -n "$fetch_val"
string split -m1 : -- "$fetch_val" | read -l trunk pattern
set upstream (string replace -r -- "/$trunk\$" '' $pattern) /$upstream
end
end
else if test $upstream = svn+git
set upstream '@{upstream}'
end
...
19 19 ---------> set upstream '@{upstream}'
71 6782 --------> set count (command git rev-list --count --left-right $upstream...HEAD 2>/dev/null)
6711 6711 ---------> command git rev-list --count --left-right $upstream...HEAD 2>/dev/null
32 786 --------> if test -n "$verbose"
# Verbose has a space by default
set -l prefix "$___fish_git_prompt_char_upstream_prefix"
# Using two underscore version to check if user explicitly set to nothing
if not set -q __fish_git_prompt_char_upstream_prefix
set -l prefix " "
end
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$prefix$___fish_git_prompt_char_upstream_diverged$ahead-$behind"
end
if test -n "$count" -a -n "$name"
echo " "(command git rev-parse --abbrev-ref "$upstream" 2>/dev/null)
end
else if test -n "$informative"
echo $count | read -l behind ahead
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
end
else
switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_equal"
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_diverged"
end
...
21 21 ---------> test -n "$verbose"
17 17 ---------> test -n "$informative"
691 691 ---------> echo $count | read -l behind ahead
25 25 ---------> switch "$count"
case '' # no upstream
case "0 0" # equal to upstream
case "0 *" # ahead of upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead"
case "* 0" # behind upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_behind$behind"
case '*' # diverged from upstream
echo "$___fish_git_prompt_char_upstream_prefix$___fish_git_prompt_char_upstream_ahead$ahead$___fish_git_prompt_char_upstream_behind$behind"
...
29 29 ----> set -l branch_color $___fish_git_prompt_color_branch
22 22 ----> set -l branch_done $___fish_git_prompt_color_branch_done
1 31 ----> if set -q __fish_git_prompt_showcolorhints
if test $detached = yes
set branch_color $___fish_git_prompt_color_branch_detached
set branch_done $___fish_git_prompt_color_branch_detached_done
end
...
30 30 -----> set -q __fish_git_prompt_showcolorhints
3 21 ----> if test -n "$w"
set w "$___fish_git_prompt_color_dirtystate$w$___fish_git_prompt_color_dirtystate_done"
...
18 18 -----> test -n "$w"
2 16 ----> if test -n "$i"
set i "$___fish_git_prompt_color_stagedstate$i$___fish_git_prompt_color_stagedstate_done"
...
14 14 -----> test -n "$i"
2 15 ----> if test -n "$s"
set s "$___fish_git_prompt_color_stashstate$s$___fish_git_prompt_color_stashstate_done"
...
13 13 -----> test -n "$s"
2 15 ----> if test -n "$u"
set u "$___fish_git_prompt_color_untrackedfiles$u$___fish_git_prompt_color_untrackedfiles_done"
...
13 13 -----> test -n "$u"
54 84 ----> set b (string replace refs/heads/ '' -- $b)
30 30 -----> string replace refs/heads/ '' -- $b
14 14 ----> set -q __fish_git_prompt_shorten_branch_char_suffix
16 16 ----> set -l __fish_git_prompt_shorten_branch_char_suffix "…"
2 32 ----> if string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"; and test (string length "$b") -gt $__fish_git_prompt_shorten_branch_len
set b (string sub -l "$__fish_git_prompt_shorten_branch_len" "$b")"$__fish_git_prompt_shorten_branch_char_suffix"
...
30 30 -----> string match -qr '^\d+$' "$__fish_git_prompt_shorten_branch_len"
13 54 ----> if test -n "$b"
set b "$branch_color$b$branch_done"
...
18 18 -----> test -n "$b"
23 23 -----> set b "$branch_color$b$branch_done"
1 16 ----> if test -n "$c"
set c "$___fish_git_prompt_color_bare$c$___fish_git_prompt_color_bare_done"
...
15 15 -----> test -n "$c"
1 14 ----> if test -n "$r"
set r "$___fish_git_prompt_color_merging$r$___fish_git_prompt_color_merging_done"
...
13 13 -----> test -n "$r"
2 15 ----> if test -n "$p"
set p "$___fish_git_prompt_color_upstream$p$___fish_git_prompt_color_upstream_done"
...
13 13 -----> test -n "$p"
19 19 ----> set -l f "$w$i$s$u"
1 14 ----> if test -n "$f"
set f "$space$f"
...
13 13 -----> test -n "$f"
18 18 ----> set -l format $argv[1]
14 43 ----> if test -z "$format"
set format " (%s)"
...
14 14 -----> test -z "$format"
15 15 -----> set format " (%s)"
54 54 ----> printf "%s$format%s" "$___fish_git_prompt_color_prefix" "$___fish_git_prompt_color_prefix_done$c$b$f$r$p$informative_status$___fish_git_prompt_color_suffix" "$___fish_git_prompt_color_suffix_done"
23 100 ---> __fish_hg_prompt
6 77 ----> if not command -sq hg
return 1
...
57 57 -----> not command -sq hg
14 14 -----> return 1
23 10248 ---> __fish_svn_prompt
2 49 ----> if not command -sq svn
return 1
...
47 47 -----> not command -sq svn
68 10130 ----> set -l checkout_info (command svn info 2>/dev/null)
10062 10062 -----> command svn info 2>/dev/null
10 46 ----> if [ $status -ne 0 ]
return
...
24 24 -----> [ $status -ne 0 ]
12 12 -----> return
1 23 -> if not test $last_status -eq 0
set_color $fish_color_error
echo -n "[$last_status] "
set_color normal
...
22 22 --> not test $last_status -eq 0
13 13 -> echo
17 17 -> echo -n "$suffix "
17 120 > fish_title
55 103 -> echo (status current-command) (__fish_pwd)
16 16 --> status current-command
17 32 --> __fish_pwd
15 15 ---> pwd
259 686 > delete-or-exit
223 238 -> source /usr/local/Cellar/fish/3.0.2/share/fish/functions/delete-or-exit.fish
15 15 --> function delete-or-exit
set -l cmd (commandline)
switch "$cmd"
case ''
exit 0
case '*'
commandline -f delete-char
end
...
64 94 -> set -l cmd (commandline)
30 30 --> commandline
19 95 -> switch "$cmd"
case ''
exit 0
case '*'
commandline -f delete-char
...
76 76 --> exit 0
32 80 > __vfsupport_remove_env_on_deactivate_or_exit PROCESS_EXIT 25947 0
5 48 -> if set -q VF_TEMPORARY_ENV
echo "Removing temporary virtualenv" (basename $VIRTUAL_ENV)
rm -rf $VIRTUAL_ENV
set -e VF_TEMPORARY_ENV
...
43 43 --> set -q VF_TEMPORARY_ENV
27 67 > __fish_disable_bracketed_paste
40 40 -> printf "\e[?2004l"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment