Skip to content

Instantly share code, notes, and snippets.

@duganchen
Created February 18, 2020 22:05
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 duganchen/7467164add3bcfa6cae0e2f2741ca8bc to your computer and use it in GitHub Desktop.
Save duganchen/7467164add3bcfa6cae0e2f2741ca8bc to your computer and use it in GitHub Desktop.
FISH startup times on OS X
Time Sum Command
3640 14814 > builtin source /usr/local/Cellar/fish/3.1.0/share/fish/config.fish
129 129 -> set -g IFS \n\ \t
47 47 -> set -qg __fish_added_user_paths
48 48 -> set -g __fish_added_user_paths
11 54 -> if not set -q __fish_initialized
set -U __fish_initialized 0
if set -q __fish_init_2_39_8
set __fish_initialized 2398
else if set -q __fish_init_2_3_0
set __fish_initialized 2300
end
...
43 43 --> not set -q __fish_initialized
25 25 -> function __fish_default_command_not_found_handler
printf "fish: Unknown command: %s\n" (string escape -- $argv[1]) >&2
...
14 784 -> if status --is-interactive
# 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
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
...
53 53 --> status --is-interactive
100 717 --> 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
...
40 40 ---> not set -q STY
284 284 ---> not string match -q -- 'eterm*' $TERM
28 148 ---> 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
...
54 54 ----> set -q KONSOLE_PROFILE_NAME
66 66 ----> string match -q -- "*:*" $ITERM_SESSION_ID
79 79 ---> set -q fish_term24bit
66 66 ---> set -g fish_term24bit 1
95 95 -> set -l __extra_completionsdir
54 54 -> set -l __extra_functionsdir
49 49 -> set -l __extra_confdir
18 799 -> if test -f $__fish_data_dir/__fish_build_paths.fish
source $__fish_data_dir/__fish_build_paths.fish
...
326 326 --> test -f $__fish_data_dir/__fish_build_paths.fish
311 455 --> source $__fish_data_dir/__fish_build_paths.fish
87 87 ---> set __extra_completionsdir /usr/local/share/fish/vendor_completions.d
30 30 ---> set __extra_functionsdir /usr/local/share/fish/vendor_functions.d
27 27 ---> set __extra_confdir /usr/local/share/fish/vendor_conf.d
27 27 -> set -l xdg_data_dirs
11 65 -> if set -q XDG_DATA_DIRS
set --path xdg_data_dirs $XDG_DATA_DIRS
set xdg_data_dirs (string replace -r '([^/])/$' '$1' -- $xdg_data_dirs)/fish
else
set xdg_data_dirs $__fish_data_dir
...
23 23 --> set -q XDG_DATA_DIRS
31 31 --> set xdg_data_dirs $__fish_data_dir
32 32 -> set -l vendor_completionsdirs $xdg_data_dirs/vendor_completions.d
33 33 -> set -l vendor_functionsdirs $xdg_data_dirs/vendor_functions.d
31 31 -> set -l vendor_confdirs $xdg_data_dirs/vendor_conf.d
10 87 -> if not contains -- $__extra_completionsdir $vendor_completionsdirs
set -a vendor_completionsdirs $__extra_completionsdir
...
42 42 --> not contains -- $__extra_completionsdir $vendor_completionsdirs
35 35 --> set -a vendor_completionsdirs $__extra_completionsdir
10 74 -> if not contains -- $__extra_functionsdir $vendor_functionsdirs
set -a vendor_functionsdirs $__extra_functionsdir
...
32 32 --> not contains -- $__extra_functionsdir $vendor_functionsdirs
32 32 --> set -a vendor_functionsdirs $__extra_functionsdir
11 76 -> if not contains -- $__extra_confdir $vendor_confdirs
set -a vendor_confdirs $__extra_confdir
...
33 33 --> not contains -- $__extra_confdir $vendor_confdirs
32 32 --> set -a vendor_confdirs $__extra_confdir
10 87 -> if not set -q fish_function_path
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $vendor_functionsdirs $__fish_data_dir/functions
else if not contains -- $__fish_data_dir/functions $fish_function_path
set -a fish_function_path $__fish_data_dir/functions
...
22 22 --> not set -q fish_function_path
55 55 --> set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $vendor_functionsdirs $__fish_data_dir/functions
14 116 -> if not set -q fish_complete_path
set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $vendor_completionsdirs $__fish_data_dir/completions $__fish_user_data_dir/generated_completions
else if not contains -- $__fish_data_dir/completions $fish_complete_path
set -a fish_complete_path $__fish_data_dir/completions
...
23 23 --> not set -q fish_complete_path
79 79 --> set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $vendor_completionsdirs $__fish_data_dir/completions $__fish_user_data_dir/generated_completions
11 11 -> function : -d "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.
# This command always succeeds
true
...
3 78 -> if begin; not set -q FISH_UNIT_TESTS_RUNNING; and test -d /usr/xpg4/bin; end
not contains -- /usr/xpg4/bin $PATH
and set PATH /usr/xpg4/bin $PATH
...
11 75 --> begin; not set -q FISH_UNIT_TESTS_RUNNING; and test -d /usr/xpg4/bin; ...
26 26 ---> not set -q FISH_UNIT_TESTS_RUNNING
38 38 ---> test -d /usr/xpg4/bin
16 16 -> 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
# Explicitly split on ":" because $fish_user_paths might not be a path variable,
# but $PATH definitely is.
for x in (string split ":" -- $fish_user_paths[-1..1])
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
end
set -p local_path $x
end
end
set -xg PATH $local_path
...
34 34 -> function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description "Signal handler for the TRAP signal. Launches a debug prompt."
breakpoint
...
9 9 -> function __fish_on_interactive --on-event fish_prompt
__fish_config_interactive
functions -e __fish_on_interactive
...
1904 3200 -> __fish_set_locale
917 935 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_set_locale.fish
18 18 ---> 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
...
50 50 --> set -l LOCALE_VARS
53 53 --> set -a LOCALE_VARS LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE
57 57 --> set -a LOCALE_VARS LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS
57 57 --> set -a LOCALE_VARS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
49 144 --> for locale_var in $LOCALE_VARS LC_ALL
if set -q $locale_var
return 0
end
...
16 95 ---> if set -q $locale_var
return 0
...
43 43 ----> set -q $locale_var
36 36 ----> return 0
24 24 -> function . -d 'Evaluate a file (deprecated, use "source")' --no-scope-shadowing --wraps source
if [ (count $argv) -eq 0 ] && isatty 0
echo "source: using source via '.' is deprecated, and stdin doesn't work."\n"Did you mean 'source' or './'?" >&2
return 1
else
source $argv
end
...
9 69 -> if test $__fish_initialized -lt 2300
if set -q fish_user_abbreviations
set -l fab
for abbr in $fish_user_abbreviations
set -a fab (string replace -r '^([^ =]+)=(.*)$' '$1 $2' -- $abbr)
end
set fish_user_abbreviations $fab
end
...
60 60 --> test $__fish_initialized -lt 2300
8 46 -> if status --is-login
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
# Populate path according to config files
for path_file in $argv[2] $argv[3]/*
if [ -f $path_file ]
while read -l entry
if not contains -- $entry $result
test -n "$entry"
and set -a result $entry
end
end <$path_file
end
end
# Merge in any existing path elements
for existing_entry in $$argv[1]
if not contains -- $existing_entry $result
set -a result $existing_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
end
#
# Put linux consoles in unicode mode.
#
if test "$TERM" = linux
and string match -qir '\.UTF' -- $LANG
and command -sq unicode_start
unicode_start
end
...
38 38 --> status --is-login
66 1725 -> __fish_reconstruct_path
75 75 --> set -l local_path $PATH
24 24 --> for x in $__fish_added_user_paths
set -l idx (contains --index -- $x $local_path)
and set -e local_path[$idx]
...
44 44 --> set -g __fish_added_user_paths
19 1397 --> if set -q fish_user_paths
# Explicitly split on ":" because $fish_user_paths might not be a path variable,
# but $PATH definitely is.
for x in (string split ":" -- $fish_user_paths[-1..1])
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
end
set -p local_path $x
end
...
36 36 ---> set -q fish_user_paths
152 1342 ---> for x in (string split ":" -- $fish_user_paths[-1..1])
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
end
set -p local_path $x
...
506 506 ----> string split ":" -- $fish_user_paths[-1..1]
23 554 ----> if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
...
239 460 -----> set -l idx (contains --index -- $x $local_path)
221 221 ------> contains --index -- $x $local_path
71 71 -----> set -ga __fish_added_user_paths $x
130 130 ----> set -p local_path $x
119 119 --> set -xg PATH $local_path
85 85 -> 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
...
53 127 -> for jobbltn in bg fg wait disown
function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
end
...
21 21 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
15 15 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
19 19 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
19 19 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
7 7 -> function kill
command kill (__fish_expand_pid_args $argv)
...
55 55 -> set -l sourcelist
1650 2976 -> for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish $vendor_confdirs/*.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
...
225 503 --> set -l basename (string replace -r '^.*/' '' -- $file)
278 278 ---> string replace -r '^.*/' '' -- $file
64 64 --> contains -- $basename $sourcelist
42 42 --> set sourcelist $sourcelist $basename
107 107 --> [ -f $file -a -r $file ]
589 610 --> source $file
21 21 ---> function _nvm_uninstall -e nvm_uninstall
if test -s "$nvm_config/version"
read -l ver <$nvm_config/version
if set -l i (contains -i -- "$nvm_config/$ver/bin" $fish_user_paths)
set -e fish_user_paths[$i]
end
command rm -f $nvm_config/version
end
for name in (set -n | command awk '/^nvm_/')
set -e "$name"
end
functions -e (functions -a | command awk '/^_nvm_/')
...
316 316 > builtin source /usr/local/Cellar/fish/3.1.0/etc/fish/config.fish
435 3505 > builtin source /Users/dugan/.config/fish/config.fish
1013 2691 -> export EDITOR=vim
605 633 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/export.fish
28 28 ---> function export --description 'Set env variable. Alias for `set -gx` for bash compatibility.'
if not set -q argv[1]
set -x
return 0
end
for arg in $argv
set -l v (string split -m 1 "=" -- $arg)
switch (count $v)
case 1
set -gx $v $$v
case 2
if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
end
end
end
...
12 66 --> if not set -q argv[1]
set -x
return 0
...
54 54 ---> not set -q argv[1]
33 979 --> for arg in $argv
set -l v (string split -m 1 "=" -- $arg)
switch (count $v)
case 1
set -gx $v $$v
case 2
if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
end
end
...
148 230 ---> set -l v (string split -m 1 "=" -- $arg)
82 82 ----> string split -m 1 "=" -- $arg
112 716 ---> switch (count $v)
case 1
set -gx $v $$v
case 2
if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
end
...
234 234 ----> count $v
27 370 ----> if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
...
101 101 -----> contains -- $v[1] PATH CDPATH MANPATH
170 170 -----> true
72 72 -----> set -gx $v[1] $v[2]
76 76 -> set -x fish_color_cwd blue
82 82 -> set -x fish_color_user blue
48 48 -> set -e VIRTUAL_ENV_DISABLE_PROMPT
58 58 -> set -x HOMEBREW_GITHUB_API_TOKEN 62c2a550603493ff423a90004ffd9059a166e17a
54 54 -> set -x MANPAGER most
61 61 -> set -x FZF_DEFAULT_COMMAND 'git ls-files 2> /dev/null || fd --type f'
440 456 > source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_title.fish
16 16 -> function fish_title
# emacs is basically the only term that can't handle it.
if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
end
...
85 12344 > fish_title
24 12259 -> if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
...
53 53 --> not set -q INSIDE_EMACS
532 12182 --> echo (status current-command) (__fish_pwd)
71 71 ---> status current-command
568 11579 ---> __fish_pwd
465 10798 ----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_pwd.fish
181 10333 -----> 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
...
10129 10129 ------> uname
23 23 ------> function __fish_pwd --description "Show current path"
pwd
...
213 213 ----> pwd
500 529 > source /Users/dugan/.config/fish/functions/fish_prompt.fish
29 29 -> function fish_prompt --description 'Write out the prompt'
echo -n -s "$USER" @ (prompt_hostname) ' ' (set_color $fish_color_cwd) (prompt_pwd) (fish_vcs_prompt) (set_color normal) '> '
...
72 35431 > __fish_on_interactive
951 35304 -> __fish_config_interactive
2900 2929 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_config_interactive.fish
29 29 ---> function __fish_config_interactive -d "Initializations that should be performed when entering interactive mode"
if test $__fish_initialized -lt 3000
# Perform transitions relevant to going from fish 2.x to 3.x.
# Migrate old universal abbreviations to the new scheme.
__fish_abbr_old | source
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
if not set -q fish_greeting
set -l line1 (_ 'Welcome to fish, the friendly interactive shell')
set -l line2 ''
if test $__fish_initialized -lt 2300
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; and string length -q -- $fish_greeting
set -l line (_ "fish is running in private mode, history will not be persisted.")
set -g fish_greeting $fish_greeting.\n$line
end
# usage: __init_uvar VARIABLE VALUES...
function __init_uvar -d "Sets a universal variable if it's not already set"
if not set --query $argv[1]
set --universal $argv
end
end
#
# If we are starting up for the first time, set various defaults.
if test $__fish_initialized -lt 3100
# Regular syntax highlighting colors
__init_uvar fish_color_normal normal
__init_uvar fish_color_command 005fd7
__init_uvar fish_color_param 00afff
__init_uvar fish_color_redirection 00afff
__init_uvar fish_color_comment 990000
__init_uvar fish_color_error ff0000
__init_uvar fish_color_escape 00a6b2
__init_uvar fish_color_operator 00a6b2
__init_uvar fish_color_end 009900
__init_uvar fish_color_quote 999900
__init_uvar fish_color_autosuggestion 555 brblack
__init_uvar fish_color_user brgreen
__init_uvar fish_color_host normal
__init_uvar fish_color_host_remote yellow
__init_uvar fish_color_valid_path --underline
__init_uvar fish_color_status red
__init_uvar fish_color_cwd green
__init_uvar fish_color_cwd_root red
# Background color for matching quotes and parenthesis
__init_uvar fish_color_match --background=brblue
# Background color for search matches
__init_uvar fish_color_search_match bryellow --background=brblack
# Background color for selections
__init_uvar fish_color_selection white --bold --background=brblack
# XXX fish_color_cancel was added in 2.6, but this was added to post-2.3 initialization
# when 2.4 and 2.5 were already released
__init_uvar fish_color_cancel -r
# Pager colors
__init_uvar fish_pager_color_prefix white --bold --underline
__init_uvar fish_pager_color_completion
__init_uvar fish_pager_color_description B3A06D yellow
__init_uvar fish_pager_color_progress brwhite --background=cyan
#
# Directory history colors
#
__init_uvar fish_color_history_current --bold
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 $__fish_user_data_dir/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
set -l c $py $update_args
# Run python directly in the background and swallow all output
$c (: fish_update_completions: generating completions from man pages) >/dev/null 2>&1 &
# Then disown the job so that it continues to run in case of an early exit (#6269)
disown 2>&1 >/dev/null
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{,_root} changes value. Like all event handlers, it can't be
# autoloaded.
#
set -l varargs --on-variable fish_key_bindings
for var in user host cwd{,_root} status
set -a varargs --on-variable fish_color_$var
end
function __fish_repaint $varargs -d "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
#
# 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
complete -c ! --wraps not
#
# Only a few builtins take filenames; initialize the rest with no file completions
#
complete -c(builtin -n | string match -rv '(source|cd|exec|realpath|set|\\[|test|for)') --no-files
# 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
__init_uvar fish_key_bindings fish_default_key_bindings
# 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
# Similarly, enable TMUX's focus reporting when in tmux.
# This will be handled by
# - The keybindings (reading the sequence and triggering an event)
# - Any listeners (like the vi-cursor)
if set -q TMUX
and not set -q FISH_UNIT_TESTS_RUNNING
function __fish_enable_focus --on-event fish_postexec
echo -n \e\[\?1004h
end
function __fish_disable_focus --on-event fish_preexec
echo -n \e\[\?1004l
end
# Note: Don't call this initially because, even though we're in a fish_prompt event,
# tmux reacts sooo quickly that we'll still get a sequence before we're prepared for it.
# So this means that we won't get focus events until you've run at least one command, but that's preferable
# to always seeing `^[[I` when starting fish.
# __fish_enable_focus
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 (TODO) support this.
if test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309
function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes'
if status --is-command-substitution || 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 || contains -- sles $os && 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
# Bump this whenever some code below needs to run once when upgrading to a new version.
# The universal variable __fish_initialized is initialized in share/config.fish.
set __fish_initialized 3100
...
7 77 --> if test $__fish_initialized -lt 3000
# Perform transitions relevant to going from fish 2.x to 3.x.
# Migrate old universal abbreviations to the new scheme.
__fish_abbr_old | source
...
70 70 ---> test $__fish_initialized -lt 3000
25 73 --> if set -q __fish_config_interactive_done
return
...
48 48 ---> set -q __fish_config_interactive_done
135 135 --> set -g __fish_config_interactive_done
70 70 --> set -g __fish_active_key_bindings
5 50 --> if not set -q fish_greeting
set -l line1 (_ 'Welcome to fish, the friendly interactive shell')
set -l line2 ''
if test $__fish_initialized -lt 2300
set line2 \n(_ 'Type `help` for instructions on how to use fish')
end
set -U fish_greeting "$line1$line2"
...
45 45 ---> not set -q fish_greeting
6 45 --> if set -q fish_private_mode; and string length -q -- $fish_greeting
set -l line (_ "fish is running in private mode, history will not be persisted.")
set -g fish_greeting $fish_greeting.\n$line
...
39 39 ---> set -q fish_private_mode
21 21 --> function __init_uvar -d "Sets a universal variable if it's not already set"
if not set --query $argv[1]
set --universal $argv
end
...
5 56 --> if test $__fish_initialized -lt 3100
# Regular syntax highlighting colors
__init_uvar fish_color_normal normal
__init_uvar fish_color_command 005fd7
__init_uvar fish_color_param 00afff
__init_uvar fish_color_redirection 00afff
__init_uvar fish_color_comment 990000
__init_uvar fish_color_error ff0000
__init_uvar fish_color_escape 00a6b2
__init_uvar fish_color_operator 00a6b2
__init_uvar fish_color_end 009900
__init_uvar fish_color_quote 999900
__init_uvar fish_color_autosuggestion 555 brblack
__init_uvar fish_color_user brgreen
__init_uvar fish_color_host normal
__init_uvar fish_color_host_remote yellow
__init_uvar fish_color_valid_path --underline
__init_uvar fish_color_status red
__init_uvar fish_color_cwd green
__init_uvar fish_color_cwd_root red
# Background color for matching quotes and parenthesis
__init_uvar fish_color_match --background=brblue
# Background color for search matches
__init_uvar fish_color_search_match bryellow --background=brblack
# Background color for selections
__init_uvar fish_color_selection white --bold --background=brblack
# XXX fish_color_cancel was added in 2.6, but this was added to post-2.3 initialization
# when 2.4 and 2.5 were already released
__init_uvar fish_color_cancel -r
# Pager colors
__init_uvar fish_pager_color_prefix white --bold --underline
__init_uvar fish_pager_color_completion
__init_uvar fish_pager_color_description B3A06D yellow
__init_uvar fish_pager_color_progress brwhite --background=cyan
#
# Directory history colors
#
__init_uvar fish_color_history_current --bold
...
51 51 ---> test $__fish_initialized -lt 3100
26 200 --> if not set -q FISH_UNIT_TESTS_RUNNING
if not test -d $__fish_user_data_dir/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
set -l c $py $update_args
# Run python directly in the background and swallow all output
$c (: fish_update_completions: generating completions from man pages) >/dev/null 2>&1 &
# Then disown the job so that it continues to run in case of an early exit (#6269)
disown 2>&1 >/dev/null
break
end
end
end
...
40 40 ---> not set -q FISH_UNIT_TESTS_RUNNING
7 134 ---> if not test -d $__fish_user_data_dir/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
set -l c $py $update_args
# Run python directly in the background and swallow all output
$c (: fish_update_completions: generating completions from man pages) >/dev/null 2>&1 &
# Then disown the job so that it continues to run in case of an early exit (#6269)
disown 2>&1 >/dev/null
break
end
end
...
127 127 ----> not test -d $__fish_user_data_dir/generated_completions
11 479 --> 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
...
45 45 ---> status --is-interactive
16 423 ---> 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
...
278 278 ----> functions -q fish_greeting
54 54 ----> test -n "$fish_greeting"
75 75 ----> echo $fish_greeting
52 52 --> set -l varargs --on-variable fish_key_bindings
54 360 --> for var in user host cwd{,_root} status
set -a varargs --on-variable fish_color_$var
...
62 62 ---> set -a varargs --on-variable fish_color_$var
59 59 ---> set -a varargs --on-variable fish_color_$var
60 60 ---> set -a varargs --on-variable fish_color_$var
62 62 ---> set -a varargs --on-variable fish_color_$var
63 63 ---> set -a varargs --on-variable fish_color_$var
69 69 --> function __fish_repaint $varargs -d "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
...
7 82 --> 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'
...
75 75 ---> test -d /etc/init.d
175 175 --> complete -c [ --wraps test
56 56 --> complete -c ! --wraps not
504 799 --> complete -c(builtin -n | string match -rv '(source|cd|exec|realpath|set|\\[|test|for)') --no-files
295 295 ---> builtin -n | string match -rv '(source|cd|exec|realpath|set|\\[|test|for)'
32 32 --> 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
__init_uvar fish_key_bindings fish_default_key_bindings
# 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
...
131 15157 --> __fish_reload_key_bindings
164 234 ---> __init_uvar fish_key_bindings fish_default_key_bindings
6 70 ----> if not set --query $argv[1]
set --universal $argv
...
64 64 -----> not set --query $argv[1]
8 1039 ---> if test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
return
...
1031 1031 ----> test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
6 1667 ---> 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
...
669 1661 ----> not functions -q "$fish_key_bindings"
965 992 -----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_default_key_bindings.fish
27 27 ------> 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
# Space expands abbrs _and_ inserts itself.
bind --preset $argv " " self-insert expand-abbr
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
# 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
...
183 183 ---> set -g __fish_active_key_bindings "$fish_key_bindings"
59 59 ---> set -g fish_bind_mode default
15 11673 ---> 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
...
61 61 ----> test "$fish_key_bindings" = fish_default_key_bindings
199 11597 ----> fish_default_key_bindings 2>/dev/null
12 125 -----> if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
...
61 61 ------> contains -- -h $argv
52 52 ------> contains -- --help $argv
20 537 -----> 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
...
41 41 ------> not set -q argv[1]
397 397 ------> bind --erase --all --preset
7 79 ------> 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
...
72 72 -------> test "$fish_key_bindings" != "fish_default_key_bindings"
18 180 -----> if not contains -- -s $argv
set argv "-s" $argv
...
98 98 ------> not contains -- -s $argv
64 64 ------> set argv "-s" $argv
750 9086 -----> __fish_shared_key_bindings $argv
2162 2227 ------> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_shared_key_bindings.fish
31 31 -------> 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
bind --preset $argv -k sright forward-bigword
bind --preset $argv -k sleft backward-bigword
# 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 __fish_whatis_current_token
# 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
# Prepend 'sudo ' to the current commandline
bind --preset $argv \es __fish_prepend_sudo
# 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
# Tmux' focus events.
# Exclude paste mode because that should get _everything_ literally.
for mode in (bind --list-modes | string match -v paste)
# We only need the in-focus event currently (to redraw the vi-cursor).
bind --preset -M $mode \e\[I 'emit fish_focus_in'
bind --preset -M $mode \e\[O false
bind --preset -M $mode \e\[\?1004h false
end
# 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).
#
# 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).
#
# See http://thejh.net/misc/website-terminal-copy-paste.
# Bind the starting sequence in every bind mode, even user-defined ones.
# 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.
bind --preset -M paste \r "commandline -i \n"
# 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)
bind --preset -M paste "'" "__fish_commandline_insert_escaped \' \$__fish_paste_quoted"
bind --preset -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted"
# Only insert spaces if we're either quoted or not at the beginning of the commandline
# - this strips leading spaces if they would trigger histignore.
bind --preset -M paste \ 'if set -q __fish_paste_quoted[1]; or string length -q -- (commandline -c); commandline -i " "; end'
...
19 19 -------> 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
...
8 8 -------> 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
...
7 7 -------> 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
...
11 123 ------> if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
...
62 62 -------> contains -- -h $argv
50 50 -------> contains -- --help $argv
75 75 ------> bind --preset $argv \cy yank
53 53 ------> bind --preset $argv \ey yank-pop
61 61 ------> bind --preset $argv -k right forward-char
233 233 ------> bind --preset $argv -k left backward-char
72 72 ------> bind --preset $argv \e\[C forward-char
60 60 ------> bind --preset $argv \e\[D backward-char
57 57 ------> bind --preset $argv \eOC forward-char
53 53 ------> bind --preset $argv \eOD backward-char
57 57 ------> bind --preset $argv -k ppage beginning-of-history
57 57 ------> bind --preset $argv -k npage end-of-history
54 54 ------> bind --preset $argv \cx fish_clipboard_copy
54 54 ------> bind --preset $argv \cv fish_clipboard_paste
55 55 ------> bind --preset $argv \e cancel
54 54 ------> bind --preset $argv \t complete
55 55 ------> bind --preset $argv \cs pager-toggle-search
56 56 ------> bind --preset $argv --key btab complete-and-search
57 57 ------> bind --preset $argv \e\n "commandline -i \n"
58 58 ------> bind --preset $argv \e\r "commandline -i \n"
60 60 ------> bind --preset $argv -k down down-or-search
61 61 ------> bind --preset $argv -k up up-or-search
57 57 ------> bind --preset $argv \e\[A up-or-search
55 55 ------> bind --preset $argv \e\[B down-or-search
52 52 ------> bind --preset $argv \eOA up-or-search
51 51 ------> bind --preset $argv \eOB down-or-search
56 56 ------> bind --preset $argv -k sright forward-bigword
55 55 ------> bind --preset $argv -k sleft backward-bigword
47 47 ------> bind --preset $argv \e\eOC nextd-or-forward-word
33 33 ------> bind --preset $argv \e\eOD prevd-or-backward-word
32 32 ------> bind --preset $argv \e\e\[C nextd-or-forward-word
79 79 ------> bind --preset $argv \e\e\[D prevd-or-backward-word
55 55 ------> bind --preset $argv \eO3C nextd-or-forward-word
53 53 ------> bind --preset $argv \eO3D prevd-or-backward-word
53 53 ------> bind --preset $argv \e\[3C nextd-or-forward-word
53 53 ------> bind --preset $argv \e\[3D prevd-or-backward-word
53 53 ------> bind --preset $argv \e\[1\;3C nextd-or-forward-word
53 53 ------> bind --preset $argv \e\[1\;3D prevd-or-backward-word
62 62 ------> bind --preset $argv \e\[1\;9C nextd-or-forward-word
54 54 ------> bind --preset $argv \e\[1\;9D prevd-or-backward-word
53 53 ------> bind --preset $argv \e\eOA history-token-search-backward
53 53 ------> bind --preset $argv \e\eOB history-token-search-forward
54 54 ------> bind --preset $argv \e\e\[A history-token-search-backward
52 52 ------> bind --preset $argv \e\e\[B history-token-search-forward
183 183 ------> bind --preset $argv \eO3A history-token-search-backward
83 83 ------> bind --preset $argv \eO3B history-token-search-forward
63 63 ------> bind --preset $argv \e\[3A history-token-search-backward
53 53 ------> bind --preset $argv \e\[3B history-token-search-forward
73 73 ------> bind --preset $argv \e\[1\;3A history-token-search-backward
55 55 ------> bind --preset $argv \e\[1\;3B history-token-search-forward
56 56 ------> bind --preset $argv \e\[1\;9A history-token-search-backward
59 59 ------> bind --preset $argv \e\[1\;9B history-token-search-forward
56 56 ------> bind --preset $argv \e. history-token-search-backward
55 55 ------> bind --preset $argv \el __fish_list_current_token
53 53 ------> bind --preset $argv \ew __fish_whatis_current_token
74 74 ------> bind --preset $argv \cl 'echo -n (clear | string replace \e\[3J ""); commandline -f repaint'
56 56 ------> bind --preset $argv \cc __fish_cancel_commandline
55 55 ------> bind --preset $argv \cu backward-kill-line
57 57 ------> bind --preset $argv \cw backward-kill-path-component
61 61 ------> bind --preset $argv \e\[F end-of-line
60 60 ------> bind --preset $argv \e\[H beginning-of-line
64 64 ------> bind --preset $argv \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
134 134 ------> bind --preset $argv \cd delete-or-exit
64 64 ------> bind --preset $argv \es __fish_prepend_sudo
57 57 ------> bind --preset $argv -k f1 __fish_man_page
55 55 ------> bind --preset $argv \eh __fish_man_page
56 56 ------> bind --preset $argv \ep '__fish_paginate'
54 54 ------> bind --preset $argv \e\# __fish_toggle_comment_commandline
53 53 ------> bind --preset $argv \ee edit_command_buffer
51 51 ------> bind --preset $argv \ev edit_command_buffer
153 664 ------> for mode in (bind --list-modes | string match -v paste)
# We only need the in-focus event currently (to redraw the vi-cursor).
bind --preset -M $mode \e\[I 'emit fish_focus_in'
bind --preset -M $mode \e\[O false
bind --preset -M $mode \e\[\?1004h false
...
295 295 -------> bind --list-modes | string match -v paste
100 100 -------> bind --preset -M $mode \e\[I 'emit fish_focus_in'
57 57 -------> bind --preset -M $mode \e\[O false
59 59 -------> bind --preset -M $mode \e\[\?1004h false
146 854 ------> for mode in (bind --list-modes | string match -v paste)
bind --preset -M $mode -m paste \e\[200~ '__fish_start_bracketed_paste'
...
482 482 -------> bind --list-modes | string match -v paste
226 226 -------> bind --preset -M $mode -m paste \e\[200~ '__fish_start_bracketed_paste'
53 53 ------> bind --preset -M paste \e\[201~ '__fish_stop_bracketed_paste'
32 32 ------> bind --preset -M paste "" self-insert
32 32 ------> bind --preset -M paste \r "commandline -i \n"
33 33 ------> bind --preset -M paste "'" "__fish_commandline_insert_escaped \' \$__fish_paste_quoted"
33 33 ------> bind --preset -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted"
38 38 ------> bind --preset -M paste \ 'if set -q __fish_paste_quoted[1]; or string length -q -- (commandline -c); commandline -i " "; end'
38 38 -----> bind --preset $argv "" self-insert
38 38 -----> bind --preset $argv " " self-insert expand-abbr
36 36 -----> bind --preset $argv \n execute
36 36 -----> bind --preset $argv \r execute
35 35 -----> bind --preset $argv \ck kill-line
35 35 -----> bind --preset $argv \eOC forward-char
35 35 -----> bind --preset $argv \eOD backward-char
35 35 -----> bind --preset $argv \e\[C forward-char
34 34 -----> bind --preset $argv \e\[D backward-char
37 37 -----> bind --preset $argv -k right forward-char
35 35 -----> bind --preset $argv -k left backward-char
36 36 -----> bind --preset $argv -k dc delete-char
35 35 -----> bind --preset $argv -k backspace backward-delete-char
35 35 -----> bind --preset $argv \x7f backward-delete-char
35 35 -----> bind --preset $argv \e\[1~ beginning-of-line
38 38 -----> bind --preset $argv \e\[3~ delete-char
34 34 -----> bind --preset $argv \e\[4~ end-of-line
74 74 -----> bind --preset $argv -k home beginning-of-line 2>/dev/null
59 59 -----> bind --preset $argv -k end end-of-line 2>/dev/null
37 37 -----> bind --preset $argv \e\[3\;2~ backward-delete-char
34 34 -----> bind --preset $argv \ca beginning-of-line
33 33 -----> bind --preset $argv \ce end-of-line
32 32 -----> bind --preset $argv \ch backward-delete-char
31 31 -----> bind --preset $argv \cp up-or-search
32 32 -----> bind --preset $argv \cn down-or-search
31 31 -----> bind --preset $argv \cf forward-char
39 39 -----> bind --preset $argv \cb backward-char
33 33 -----> bind --preset $argv \ct transpose-chars
32 32 -----> bind --preset $argv \et transpose-words
32 32 -----> bind --preset $argv \eu upcase-word
33 33 -----> bind --preset $argv \ec capitalize-word
34 34 -----> bind --preset $argv \e\x7f backward-kill-word
33 33 -----> bind --preset $argv \e\b backward-kill-word
33 33 -----> bind --preset $argv \eb backward-word
31 31 -----> bind --preset $argv \ef forward-word
36 36 -----> bind --preset $argv \e\[1\;5C forward-word
35 35 -----> bind --preset $argv \e\[1\;5D backward-word
32 32 -----> bind --preset $argv \e\< beginning-of-buffer
40 40 -----> bind --preset $argv \e\> end-of-buffer
32 32 -----> bind --preset $argv \ed kill-word
25 25 -----> 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
...
5 171 ---> if functions --query fish_user_key_bindings >/dev/null
fish_user_key_bindings 2>/dev/null
...
166 166 ----> functions --query fish_user_key_bindings >/dev/null
13 471 --> 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
...
35 35 ---> not set -q FISH_UNIT_TESTS_RUNNING
12 12 ---> function __fish_enable_bracketed_paste --on-event fish_prompt
printf "\e[?2004h"
...
18 18 ---> function __fish_disable_bracketed_paste --on-event fish_preexec --on-event fish_exit
printf "\e[?2004l"
...
47 393 ---> __fish_enable_bracketed_paste
346 346 ----> printf "\e[?2004h"
8 72 --> if set -q TMUX
and not set -q FISH_UNIT_TESTS_RUNNING
function __fish_enable_focus --on-event fish_postexec
echo -n \e\[\?1004h
end
function __fish_disable_focus --on-event fish_preexec
echo -n \e\[\?1004l
end
# Note: Don't call this initially because, even though we're in a fish_prompt event,
# tmux reacts sooo quickly that we'll still get a sequence before we're prepared for it.
# So this means that we won't get focus events until you've run at least one command, but that's preferable
# to always seeing `^[[I` when starting fish.
# __fish_enable_focus
...
64 64 ---> set -q TMUX
32 32 --> function __fish_winch_handler --on-signal WINCH -d "Repaint screen when window changes size"
commandline -f repaint >/dev/null 2>/dev/null
...
13 749 --> if test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309
function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes'
if status --is-command-substitution || 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
...
608 736 ---> test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309
128 128 ----> string match -r '\d+' 0"$TERM_PROGRAM_VERSION"
43 12031 --> 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 || contains -- sles $os && 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
...
491 6244 ---> not type -q __fish_command_not_found_handler
1710 1743 ----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/type.fish
33 33 -----> 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' 's/short' '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
set -l short no
# 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_short
and set short 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
end
return $res
...
67 67 ----> set -q argv[1]
96 96 ----> set -l options 'h/help' 'a/all' 's/short' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
149 149 ----> argparse -n type -x t,p,P $options -- $argv
7 51 ----> if set -q _flag_help
__fish_print_help type
return 0
...
44 44 -----> set -q _flag_help
49 49 ----> set -l res 1
45 45 ----> set -l mode normal
46 46 ----> set -l multi no
43 43 ----> set -l selection all
44 44 ----> set -l short no
15 94 ----> 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
...
38 38 -----> set -q _flag_quiet
41 41 -----> set mode quiet
38 38 ----> set -q _flag_all
36 36 ----> set -q _flag_short
36 36 ----> set -q _flag_no_functions
65 3163 ----> 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
45 45 -----> set -l found 0
16 786 -----> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
...
48 48 ------> test $selection != files
8 250 ------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
end
if test $multi != yes
continue
end
...
242 242 -------> functions -q -- $i
7 472 ------> 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
...
356 465 -------> contains -- $i (builtin -n)
109 109 --------> builtin -n
61 61 -----> set -l paths
17 2046 -----> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
50 50 ------> test $multi != yes
394 1979 ------> set paths (command -s -- $i)
1585 1585 -------> command -s -- $i
29 29 -----> 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
...
11 131 -----> if test $found = 0
and test $mode != quiet
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
67 67 ------> test $found = 0
53 53 ------> test $mode != quiet
53 53 ----> return $res
47 47 ---> set -l os
5 102 ---> 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 " ")
...
97 97 ----> test -r /etc/os-release
37 5595 ---> if contains -- suse $os || contains -- sles $os && 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
...
59 59 ----> contains -- suse $os
49 49 ----> contains -- sles $os
68 68 ----> test -f /usr/libexec/pk-command-not-found
58 58 ----> test -f /usr/lib/command-not-found
48 48 ----> test -f /run/current-system/sw/bin/command-not-found
137 2790 ----> type -q command-not-found
41 41 -----> set -q argv[1]
76 76 -----> set -l options 'h/help' 'a/all' 's/short' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
105 105 -----> argparse -n type -x t,p,P $options -- $argv
5 43 -----> if set -q _flag_help
__fish_print_help type
return 0
...
38 38 ------> set -q _flag_help
42 42 -----> set -l res 1
41 41 -----> set -l mode normal
42 42 -----> set -l multi no
40 40 -----> set -l selection all
40 40 -----> set -l short no
11 86 -----> 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
...
35 35 ------> set -q _flag_quiet
40 40 ------> set mode quiet
36 36 -----> set -q _flag_all
35 35 -----> set -q _flag_short
35 35 -----> set -q _flag_no_functions
48 1940 -----> 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
41 41 ------> set -l found 0
25 889 ------> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
...
44 44 -------> test $selection != files
6 394 -------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
end
if test $multi != yes
continue
end
...
388 388 --------> functions -q -- $i
7 426 -------> 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
...
327 419 --------> contains -- $i (builtin -n)
92 92 ---------> builtin -n
57 57 ------> set -l paths
14 766 ------> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
51 51 -------> test $multi != yes
401 701 -------> set paths (command -s -- $i)
300 300 --------> command -s -- $i
21 21 ------> 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
...
11 118 ------> if test $found = 0
and test $mode != quiet
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
54 54 -------> test $found = 0
53 53 -------> test $mode != quiet
51 51 -----> return $res
147 2470 ----> type -p -q pkgfile
44 44 -----> set -q argv[1]
84 84 -----> set -l options 'h/help' 'a/all' 's/short' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
125 125 -----> argparse -n type -x t,p,P $options -- $argv
6 52 -----> if set -q _flag_help
__fish_print_help type
return 0
...
46 46 ------> set -q _flag_help
48 48 -----> set -l res 1
48 48 -----> set -l mode normal
47 47 -----> set -l multi no
46 46 -----> set -l selection all
45 45 -----> set -l short no
12 96 -----> 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
...
39 39 ------> set -q _flag_quiet
45 45 ------> set mode quiet
42 42 -----> set -q _flag_all
38 38 -----> set -q _flag_short
37 37 -----> set -q _flag_no_functions
54 1526 -----> 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
45 45 ------> set -l found 0
31 704 ------> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
...
48 48 -------> test $selection != files
5 230 -------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
end
if test $multi != yes
continue
end
...
225 225 --------> functions -q -- $i
6 395 -------> 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
...
298 389 --------> contains -- $i (builtin -n)
91 91 ---------> builtin -n
59 59 ------> set -l paths
13 536 ------> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
51 51 -------> test $multi != yes
166 472 -------> set paths (command -s -- $i)
306 306 --------> command -s -- $i
23 23 ------> 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
...
9 105 ------> if test $found = 0
and test $mode != quiet
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
49 49 -------> test $found = 0
47 47 -------> test $mode != quiet
45 45 -----> return $res
16 16 ----> function __fish_command_not_found_handler --on-event fish_command_not_found
__fish_default_command_not_found_handler $argv[1]
...
81 81 --> set __fish_initialized 3100
55 55 -> functions -e __fish_on_interactive
453 472 > source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_mode_prompt.fish
19 19 -> function fish_mode_prompt --description "Displays the current mode"
# To reuse the mode indicator use this function instead
fish_default_mode_prompt
...
89 2218 > fish_mode_prompt
1259 2129 -> fish_default_mode_prompt
657 686 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_default_mode_prompt.fish
29 29 ---> 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 replace
set_color --bold --background cyan white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
end
...
22 184 --> 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 replace
set_color --bold --background cyan white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
...
90 90 ---> test "$fish_key_bindings" = "fish_vi_key_bindings"
72 72 ---> test "$fish_key_bindings" = "fish_hybrid_key_bindings"
94 7372987 > fish_prompt
620 7372893 -> echo -n -s "$USER" @ (prompt_hostname) ' ' (set_color $fish_color_cwd) (prompt_pwd) (fish_vcs_prompt) (set_color normal) '> '
355 879 --> prompt_hostname
424 435 ---> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/prompt_hostname.fish
11 11 ----> function prompt_hostname
# return the short hostname only by default (#4804)
string replace -r "\..*" "" $hostname
...
89 89 ---> string replace -r "\..*" "" $hostname
154 154 --> set_color $fish_color_cwd
445 1408 --> prompt_pwd
362 382 ---> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/prompt_pwd.fish
20 20 ----> 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
...
40 40 ---> set -l options 'h/help'
42 42 ---> argparse -n prompt_pwd --max-args=0 $options -- $argv
5 29 ---> if set -q _flag_help
__fish_print_help prompt_pwd
return 0
...
24 24 ----> set -q _flag_help
24 24 ---> set -q fish_prompt_pwd_dir_length
26 26 ---> set -l fish_prompt_pwd_dir_length 1
41 41 ---> set realhome ~
146 216 ---> set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)
70 70 ----> string replace -r '^'"$realhome"'($|/)' '~$1' $PWD
19 163 ---> 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
...
56 56 ----> [ $fish_prompt_pwd_dir_length -eq 0 ]
88 88 ----> string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
356 7369742 --> fish_vcs_prompt
360 379 ---> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_vcs_prompt.fish
19 19 ----> function fish_vcs_prompt --description "Print the prompts for all available vcsen"
# If a prompt succeeded, we assume that it's printed the correct info.
# This is so we don't try svn if git already worked.
fish_git_prompt
or fish_hg_prompt
or fish_svn_prompt
...
394 5204357 ---> fish_git_prompt
5211 9198 ----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_git_prompt.fish
28 28 -----> 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 | string replace \t " ")
# 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 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
# For the return status
test "$count" = "0 0"
...
15 15 -----> 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"
# Use our variables as defaults, but allow overrides via the local git config.
# That means if neither is set, this stays empty.
#
# So "!= true" or "!= false" are useful tests if you want to do something by default.
set -l informative (command git config --bool bash.showInformativeStatus)
set -l dirty (command git config --bool bash.showDirtyState)
if not set -q dirty[1]
set -q __fish_git_prompt_showdirtystate
and set dirty true
end
set -l untracked (command git config --bool bash.showUntrackedFiles)
if not set -q untracked[1]
set -q __fish_git_prompt_showuntrackedfiles
and set untracked true
end
if test "true" = $inside_worktree
# Use informative status if it has been enabled locally, or it has been
# enabled globally (via the fish variable) and dirty or untracked are not false.
#
# This is to allow overrides for the repository.
if test "$informative" = true
or begin
set -q __fish_git_prompt_show_informative_status
and test "$dirty" != false
and test "$untracked" != false
end
set informative_status "$space"(__fish_git_prompt_informative_status $git_dir)
else
# This has to be set explicitly.
if test "$dirty" = true
set w (__fish_git_prompt_dirty)
set i (__fish_git_prompt_staged $sha)
end
if set -q __fish_git_prompt_showstashstate
and test -r $git_dir/refs/stash
set s $___fish_git_prompt_char_stashstate
end
if test "$untracked" = true
set u (__fish_git_prompt_untracked)
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"
...
18 18 -----> 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
set -l ret 0
if test -n "$sha"
# The "diff" functions all return > 0 if there _is_ a diff,
# but we want to return 0 if there are staged changes.
# So we invert the status.
not command git diff-index --cached --quiet HEAD -- 2>/dev/null
and set staged $___fish_git_prompt_char_stagedstate
set ret $status
else
set staged $___fish_git_prompt_char_invalidstate
set ret 2
end
echo $staged
return $ret
...
16 16 -----> function __fish_git_prompt_untracked --description "fish_git_prompt helper, tells whether or not the current repository has untracked files"
set -l ret 1
if command git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- :/ >/dev/null 2>&1
set ret $status
set untracked $___fish_git_prompt_char_untrackedfiles
end
echo $untracked
return $ret
...
16 16 -----> function __fish_git_prompt_dirty --description "fish_git_prompt helper, tells whether or not the current branch has tracked, modified files"
set -l dirty
# Like staged, invert the status because we want 0 to mean there are dirty files.
not command git diff --no-ext-diff --quiet --exit-code 2>/dev/null
set -l os $status
if test $os -eq 0
set dirty $___fish_git_prompt_char_dirtystate
end
echo $dirty
return $os
...
110 110 -----> set -g ___fish_git_prompt_status_order stagedstate invalidstate dirtystate untrackedfiles
8 53 -----> if set -q __fish_git_prompt_showstashstate
set -a ___fish_git_prompt_status_order stashstate
...
45 45 ------> set -q __fish_git_prompt_showstashstate
10 10 -----> 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 | count)
set -l stashstate 0
set -l stashfile "$argv[1]/logs/refs/stash"
if set -q __fish_git_prompt_showstashstate; and test -e "$stashfile"
set stashstate (count < $stashfile)
end
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 + $stashstate 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
...
23 23 -----> 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
...
7 7 -----> 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 begin set -q __fish_git_prompt_show_informative_status
or set -q __fish_git_prompt_use_informative_chars
end
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
...
15 15 -----> 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 ''
...
7 7 -----> 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
...
15 15 -----> 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
...
54 54 -----> set -l varargs
150 707 -----> for var in repaint describe_style show_informative_status use_informative_chars showdirtystate showstashstate showuntrackedfiles showupstream
set -a varargs --on-variable __fish_git_prompt_$var
...
135 135 ------> set -a varargs --on-variable __fish_git_prompt_$var
52 52 ------> set -a varargs --on-variable __fish_git_prompt_$var
50 50 ------> set -a varargs --on-variable __fish_git_prompt_$var
42 42 ------> set -a varargs --on-variable __fish_git_prompt_$var
79 79 ------> set -a varargs --on-variable __fish_git_prompt_$var
71 71 ------> set -a varargs --on-variable __fish_git_prompt_$var
63 63 ------> set -a varargs --on-variable __fish_git_prompt_$var
65 65 ------> set -a varargs --on-variable __fish_git_prompt_$var
119 119 -----> 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 stashstate stateseparator untrackedfiles upstream_ahead upstream_behind
set -e ___fish_git_prompt_char_$name
end
# Clear init so we reset the chars next time.
set -e ___fish_git_prompt_init
end
commandline -f repaint 2>/dev/null
end
...
65 65 -----> set -l varargs
159 1259 -----> 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
...
59 59 ------> set -a varargs --on-variable __fish_git_prompt_color$var
61 61 ------> set -a varargs --on-variable __fish_git_prompt_color$var
60 60 ------> set -a varargs --on-variable __fish_git_prompt_color$var
64 64 ------> set -a varargs --on-variable __fish_git_prompt_color$var
68 68 ------> set -a varargs --on-variable __fish_git_prompt_color$var
68 68 ------> set -a varargs --on-variable __fish_git_prompt_color$var
73 73 ------> set -a varargs --on-variable __fish_git_prompt_color$var
79 79 ------> set -a varargs --on-variable __fish_git_prompt_color$var
77 77 ------> set -a varargs --on-variable __fish_git_prompt_color$var
78 78 ------> set -a varargs --on-variable __fish_git_prompt_color$var
87 87 ------> set -a varargs --on-variable __fish_git_prompt_color$var
84 84 ------> set -a varargs --on-variable __fish_git_prompt_color$var
82 82 ------> set -a varargs --on-variable __fish_git_prompt_color$var
81 81 ------> set -a varargs --on-variable __fish_git_prompt_color$var
79 79 ------> set -a varargs --on-variable __fish_git_prompt_color$var
64 64 -----> set -a varargs --on-variable __fish_git_prompt_showcolorhints
128 128 -----> 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
...
76 76 -----> set -l varargs
135 1072 -----> 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
...
60 60 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
64 64 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
62 62 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
71 71 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
85 85 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
128 128 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
73 73 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
69 69 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
72 72 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
80 80 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
76 76 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
97 97 ------> set -a varargs --on-variable __fish_git_prompt_char_$var
110 110 -----> 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
...
19 636 ----> if not command -sq git
return 1
...
617 617 -----> not command -sq git
277 5194027 ----> 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)
5193750 5193750 -----> command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null
63 63 ----> test -n "$repo_info"
39 39 ----> return
390 2579 ---> fish_hg_prompt
1058 1849 ----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_hg_prompt.fish
100 100 -----> set -g fish_color_hg_clean green
47 47 -----> set -g fish_color_hg_modified yellow
43 43 -----> set -g fish_color_hg_dirty red
43 43 -----> set -g fish_color_hg_added green
43 43 -----> set -g fish_color_hg_renamed magenta
44 44 -----> set -g fish_color_hg_copied magenta
43 43 -----> set -g fish_color_hg_deleted red
44 44 -----> set -g fish_color_hg_untracked yellow
41 41 -----> set -g fish_color_hg_unmerged red
49 49 -----> set -g fish_prompt_hg_status_added '✚'
46 46 -----> set -g fish_prompt_hg_status_modified '*'
44 44 -----> set -g fish_prompt_hg_status_copied '⇒'
44 44 -----> set -g fish_prompt_hg_status_deleted '✖'
43 43 -----> set -g fish_prompt_hg_status_untracked '?'
42 42 -----> set -g fish_prompt_hg_status_unmerged !
53 53 -----> set -g fish_prompt_hg_status_order added modified copied deleted untracked unmerged
22 22 -----> 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 '|'
# Disabling color and pager is always a good idea.
set -l repo_status (hg status | 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
...
24 340 ----> if not command -sq hg
return 1
...
263 263 -----> not command -sq hg
53 53 -----> return 1
378 2162071 ---> fish_svn_prompt
1700 3788 ----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_svn_prompt.fish
87 87 -----> set -g __fish_svn_prompt_color_revision yellow
58 58 -----> set -g __fish_svn_prompt_char_separator "|"
50 50 -----> set -g __fish_svn_prompt_char_added_display 'A'
47 47 -----> set -g __fish_svn_prompt_char_added_color green
49 49 -----> set -g __fish_svn_prompt_char_conflicted_display 'C'
256 256 -----> set -g __fish_svn_prompt_char_conflicted_color --underline magenta
56 56 -----> set -g __fish_svn_prompt_char_deleted_display 'D'
49 49 -----> set -g __fish_svn_prompt_char_deleted_color red
48 48 -----> set -g __fish_svn_prompt_char_ignored_display 'I'
51 51 -----> set -g __fish_svn_prompt_char_ignored_color --bold yellow
47 47 -----> set -g __fish_svn_prompt_char_modified_display 'M'
46 46 -----> set -g __fish_svn_prompt_char_modified_color blue
46 46 -----> set -g __fish_svn_prompt_char_replaced_display 'R'
43 43 -----> set -g __fish_svn_prompt_char_replaced_color cyan
45 45 -----> set -g __fish_svn_prompt_char_unversioned_external_display 'X'
45 45 -----> set -g __fish_svn_prompt_char_unversioned_external_color --underline cyan
46 46 -----> set -g __fish_svn_prompt_char_unversioned_display '?'
47 47 -----> set -g __fish_svn_prompt_char_unversioned_color purple
73 73 -----> set -g __fish_svn_prompt_char_missing_display !
48 48 -----> set -g __fish_svn_prompt_char_missing_color yellow
56 56 -----> set -g __fish_svn_prompt_char_versioned_obstructed_display '~'
47 47 -----> set -g __fish_svn_prompt_char_versioned_obstructed_color magenta
49 49 -----> set -g __fish_svn_prompt_char_locked_display 'L'
47 47 -----> set -g __fish_svn_prompt_char_locked_color --bold red
49 49 -----> set -g __fish_svn_prompt_char_scheduled_display '+'
48 48 -----> set -g __fish_svn_prompt_char_scheduled_color --bold green
55 55 -----> set -g __fish_svn_prompt_char_switched_display 'S'
50 50 -----> set -g __fish_svn_prompt_char_switched_color --bold blue
49 49 -----> set -g __fish_svn_prompt_char_token_present_display 'K'
48 48 -----> set -g __fish_svn_prompt_char_token_present_color --bold cyan
47 47 -----> set -g __fish_svn_prompt_char_token_other_display 'O'
50 50 -----> set -g __fish_svn_prompt_char_token_other_color --underline purple
61 61 -----> set -g __fish_svn_prompt_char_token_stolen_display 'T'
50 50 -----> set -g __fish_svn_prompt_char_token_stolen_color --bold purple
49 49 -----> set -g __fish_svn_prompt_char_token_broken_display 'B'
49 49 -----> set -g __fish_svn_prompt_char_token_broken_color --bold magenta
29 29 -----> 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 (count (string match $__fish_svn_prompt_chars[$flag_index] -- $flag_status_string)) -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
...
18 18 -----> function fish_svn_prompt --description "Prompt function for svn"
# if svn isn't installed or doesn't offer svnversion then don't do anything
if not command -sq svn svnversion
return 1
end
# make sure that this is a svn repo
set -l checkout_info (command svn info 2>/dev/null)
or return
# 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 ')'
...
18 1067 ----> if not command -sq svn svnversion
return 1
...
1049 1049 -----> not command -sq svn svnversion
477 2156790 ----> set -l checkout_info (command svn info 2>/dev/null)
2156313 2156313 -----> command svn info 2>/dev/null
48 48 ----> return
90 90 --> set_color normal
59 560 > fish_title
19 501 -> if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
...
48 48 --> not set -q INSIDE_EMACS
258 434 --> echo (status current-command) (__fish_pwd)
56 56 ---> status current-command
65 120 ---> __fish_pwd
55 55 ----> pwd
88 304 > fish_mode_prompt
60 216 -> fish_default_mode_prompt
19 156 --> 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 replace
set_color --bold --background cyan white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
...
72 72 ---> test "$fish_key_bindings" = "fish_vi_key_bindings"
65 65 ---> test "$fish_key_bindings" = "fish_hybrid_key_bindings"
123 59136 > fish_prompt
3096 59013 -> echo -n -s "$USER" @ (prompt_hostname) ' ' (set_color $fish_color_cwd) (prompt_pwd) (fish_vcs_prompt) (set_color normal) '> '
348 694 --> prompt_hostname
346 346 ---> string replace -r "\..*" "" $hostname
1978 1978 --> set_color $fish_color_cwd
516 2114 --> prompt_pwd
84 84 ---> set -l options 'h/help'
73 73 ---> argparse -n prompt_pwd --max-args=0 $options -- $argv
9 52 ---> if set -q _flag_help
__fish_print_help prompt_pwd
return 0
...
43 43 ----> set -q _flag_help
43 43 ---> set -q fish_prompt_pwd_dir_length
50 50 ---> set -l fish_prompt_pwd_dir_length 1
61 61 ---> set realhome ~
482 602 ---> set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)
120 120 ----> string replace -r '^'"$realhome"'($|/)' '~$1' $PWD
84 633 ---> 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
...
184 184 ----> [ $fish_prompt_pwd_dir_length -eq 0 ]
365 365 ----> string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' $tmp
203 51037 --> fish_vcs_prompt
170 14733 ---> fish_git_prompt
41 303 ----> if not command -sq git
return 1
...
262 262 -----> not command -sq git
535 14168 ----> 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)
13633 13633 -----> command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null
58 58 ----> test -n "$repo_info"
34 34 ----> return
57 262 ---> fish_hg_prompt
19 205 ----> if not command -sq hg
return 1
...
144 144 -----> not command -sq hg
42 42 -----> return 1
74 35839 ---> fish_svn_prompt
10 181 ----> if not command -sq svn svnversion
return 1
...
171 171 -----> not command -sq svn svnversion
921 35541 ----> set -l checkout_info (command svn info 2>/dev/null)
34620 34620 -----> command svn info 2>/dev/null
43 43 ----> return
94 94 --> set_color normal
224 847 > fish_title
26 623 -> if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
...
71 71 --> not set -q INSIDE_EMACS
330 526 --> echo (status current-command) (__fish_pwd)
57 57 ---> status current-command
79 139 ---> __fish_pwd
60 60 ----> pwd
270 573 > __fish_disable_bracketed_paste exit
303 303 -> printf "\e[?2004l"
150 1284 > fish_title exit
40 1134 -> if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
...
50 50 --> not set -q INSIDE_EMACS
534 1044 --> echo (status current-command) (__fish_pwd)
54 54 ---> status current-command
276 456 ---> __fish_pwd
180 180 ----> pwd
498 498 > exit
160 246 > __fish_disable_bracketed_paste 0
86 86 -> printf "\e[?2004l"
Time Sum Command
2852 16782 > builtin source /usr/local/Cellar/fish/3.1.0/share/fish/config.fish
160 160 -> set -g IFS \n\ \t
45 45 -> set -qg __fish_added_user_paths
53 53 -> set -g __fish_added_user_paths
11 54 -> if not set -q __fish_initialized
set -U __fish_initialized 0
if set -q __fish_init_2_39_8
set __fish_initialized 2398
else if set -q __fish_init_2_3_0
set __fish_initialized 2300
end
...
43 43 --> not set -q __fish_initialized
30 30 -> function __fish_default_command_not_found_handler
printf "fish: Unknown command: %s\n" (string escape -- $argv[1]) >&2
...
22 770 -> if status --is-interactive
# 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
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
...
51 51 --> status --is-interactive
41 697 --> 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
...
41 41 ---> not set -q STY
336 336 ---> not string match -q -- 'eterm*' $TERM
25 177 ---> 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
...
80 80 ----> set -q KONSOLE_PROFILE_NAME
72 72 ----> string match -q -- "*:*" $ITERM_SESSION_ID
45 45 ---> set -q fish_term24bit
57 57 ---> set -g fish_term24bit 1
52 52 -> set -l __extra_completionsdir
46 46 -> set -l __extra_functionsdir
46 46 -> set -l __extra_confdir
31 1177 -> if test -f $__fish_data_dir/__fish_build_paths.fish
source $__fish_data_dir/__fish_build_paths.fish
...
461 461 --> test -f $__fish_data_dir/__fish_build_paths.fish
491 685 --> source $__fish_data_dir/__fish_build_paths.fish
88 88 ---> set __extra_completionsdir /usr/local/share/fish/vendor_completions.d
55 55 ---> set __extra_functionsdir /usr/local/share/fish/vendor_functions.d
51 51 ---> set __extra_confdir /usr/local/share/fish/vendor_conf.d
50 50 -> set -l xdg_data_dirs
21 129 -> if set -q XDG_DATA_DIRS
set --path xdg_data_dirs $XDG_DATA_DIRS
set xdg_data_dirs (string replace -r '([^/])/$' '$1' -- $xdg_data_dirs)/fish
else
set xdg_data_dirs $__fish_data_dir
...
42 42 --> set -q XDG_DATA_DIRS
66 66 --> set xdg_data_dirs $__fish_data_dir
64 64 -> set -l vendor_completionsdirs $xdg_data_dirs/vendor_completions.d
59 59 -> set -l vendor_functionsdirs $xdg_data_dirs/vendor_functions.d
59 59 -> set -l vendor_confdirs $xdg_data_dirs/vendor_conf.d
20 170 -> if not contains -- $__extra_completionsdir $vendor_completionsdirs
set -a vendor_completionsdirs $__extra_completionsdir
...
79 79 --> not contains -- $__extra_completionsdir $vendor_completionsdirs
71 71 --> set -a vendor_completionsdirs $__extra_completionsdir
19 180 -> if not contains -- $__extra_functionsdir $vendor_functionsdirs
set -a vendor_functionsdirs $__extra_functionsdir
...
95 95 --> not contains -- $__extra_functionsdir $vendor_functionsdirs
66 66 --> set -a vendor_functionsdirs $__extra_functionsdir
17 141 -> if not contains -- $__extra_confdir $vendor_confdirs
set -a vendor_confdirs $__extra_confdir
...
63 63 --> not contains -- $__extra_confdir $vendor_confdirs
61 61 --> set -a vendor_confdirs $__extra_confdir
18 166 -> if not set -q fish_function_path
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $vendor_functionsdirs $__fish_data_dir/functions
else if not contains -- $__fish_data_dir/functions $fish_function_path
set -a fish_function_path $__fish_data_dir/functions
...
44 44 --> not set -q fish_function_path
104 104 --> set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $vendor_functionsdirs $__fish_data_dir/functions
20 183 -> if not set -q fish_complete_path
set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $vendor_completionsdirs $__fish_data_dir/completions $__fish_user_data_dir/generated_completions
else if not contains -- $__fish_data_dir/completions $fish_complete_path
set -a fish_complete_path $__fish_data_dir/completions
...
44 44 --> not set -q fish_complete_path
119 119 --> set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $vendor_completionsdirs $__fish_data_dir/completions $__fish_user_data_dir/generated_completions
19 19 -> function : -d "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.
# This command always succeeds
true
...
6 140 -> if begin; not set -q FISH_UNIT_TESTS_RUNNING; and test -d /usr/xpg4/bin; end
not contains -- /usr/xpg4/bin $PATH
and set PATH /usr/xpg4/bin $PATH
...
21 134 --> begin; not set -q FISH_UNIT_TESTS_RUNNING; and test -d /usr/xpg4/bin; ...
48 48 ---> not set -q FISH_UNIT_TESTS_RUNNING
65 65 ---> test -d /usr/xpg4/bin
30 30 -> 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
# Explicitly split on ":" because $fish_user_paths might not be a path variable,
# but $PATH definitely is.
for x in (string split ":" -- $fish_user_paths[-1..1])
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
end
set -p local_path $x
end
end
set -xg PATH $local_path
...
54 54 -> function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description "Signal handler for the TRAP signal. Launches a debug prompt."
breakpoint
...
16 16 -> function __fish_on_interactive --on-event fish_prompt
__fish_config_interactive
functions -e __fish_on_interactive
...
2584 4448 -> __fish_set_locale
1097 1122 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_set_locale.fish
25 25 ---> 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
...
73 73 --> set -l LOCALE_VARS
68 68 --> set -a LOCALE_VARS LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE
57 57 --> set -a LOCALE_VARS LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS
118 118 --> set -a LOCALE_VARS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
101 426 --> for locale_var in $LOCALE_VARS LC_ALL
if set -q $locale_var
return 0
end
...
49 325 ---> if set -q $locale_var
return 0
...
154 154 ----> set -q $locale_var
122 122 ----> return 0
72 72 -> function . -d 'Evaluate a file (deprecated, use "source")' --no-scope-shadowing --wraps source
if [ (count $argv) -eq 0 ] && isatty 0
echo "source: using source via '.' is deprecated, and stdin doesn't work."\n"Did you mean 'source' or './'?" >&2
return 1
else
source $argv
end
...
21 205 -> if test $__fish_initialized -lt 2300
if set -q fish_user_abbreviations
set -l fab
for abbr in $fish_user_abbreviations
set -a fab (string replace -r '^([^ =]+)=(.*)$' '$1 $2' -- $abbr)
end
set fish_user_abbreviations $fab
end
...
184 184 --> test $__fish_initialized -lt 2300
14 155 -> if status --is-login
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
# Populate path according to config files
for path_file in $argv[2] $argv[3]/*
if [ -f $path_file ]
while read -l entry
if not contains -- $entry $result
test -n "$entry"
and set -a result $entry
end
end <$path_file
end
end
# Merge in any existing path elements
for existing_entry in $$argv[1]
if not contains -- $existing_entry $result
set -a result $existing_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
end
#
# Put linux consoles in unicode mode.
#
if test "$TERM" = linux
and string match -qir '\.UTF' -- $LANG
and command -sq unicode_start
unicode_start
end
...
141 141 --> status --is-login
248 2079 -> __fish_reconstruct_path
269 269 --> set -l local_path $PATH
35 35 --> for x in $__fish_added_user_paths
set -l idx (contains --index -- $x $local_path)
and set -e local_path[$idx]
...
70 70 --> set -g __fish_added_user_paths
19 1355 --> if set -q fish_user_paths
# Explicitly split on ":" because $fish_user_paths might not be a path variable,
# but $PATH definitely is.
for x in (string split ":" -- $fish_user_paths[-1..1])
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
end
set -p local_path $x
end
...
45 45 ---> set -q fish_user_paths
173 1291 ---> for x in (string split ":" -- $fish_user_paths[-1..1])
if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
end
set -p local_path $x
...
530 530 ----> string split ":" -- $fish_user_paths[-1..1]
25 521 ----> if set -l idx (contains --index -- $x $local_path)
set -e local_path[$idx]
else
set -ga __fish_added_user_paths $x
...
185 430 -----> set -l idx (contains --index -- $x $local_path)
245 245 ------> contains --index -- $x $local_path
66 66 -----> set -ga __fish_added_user_paths $x
67 67 ----> set -p local_path $x
102 102 --> set -xg PATH $local_path
15 15 -> 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
...
33 106 -> for jobbltn in bg fg wait disown
function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
end
...
20 20 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
17 17 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
17 17 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
19 19 --> function $jobbltn -V jobbltn
builtin $jobbltn (__fish_expand_pid_args $argv)
...
7 7 -> function kill
command kill (__fish_expand_pid_args $argv)
...
58 58 -> set -l sourcelist
1331 2892 -> for file in $__fish_config_dir/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish $vendor_confdirs/*.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
...
309 617 --> set -l basename (string replace -r '^.*/' '' -- $file)
308 308 ---> string replace -r '^.*/' '' -- $file
89 89 --> contains -- $basename $sourcelist
72 72 --> set sourcelist $sourcelist $basename
198 198 --> [ -f $file -a -r $file ]
558 585 --> source $file
27 27 ---> function _nvm_uninstall -e nvm_uninstall
if test -s "$nvm_config/version"
read -l ver <$nvm_config/version
if set -l i (contains -i -- "$nvm_config/$ver/bin" $fish_user_paths)
set -e fish_user_paths[$i]
end
command rm -f $nvm_config/version
end
for name in (set -n | command awk '/^nvm_/')
set -e "$name"
end
functions -e (functions -a | command awk '/^_nvm_/')
...
560 560 > builtin source /usr/local/Cellar/fish/3.1.0/etc/fish/config.fish
546 3685 > builtin source /Users/dugan/.config/fish/config.fish
857 2757 -> export EDITOR=vim
651 690 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/export.fish
39 39 ---> function export --description 'Set env variable. Alias for `set -gx` for bash compatibility.'
if not set -q argv[1]
set -x
return 0
end
for arg in $argv
set -l v (string split -m 1 "=" -- $arg)
switch (count $v)
case 1
set -gx $v $$v
case 2
if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
end
end
end
...
13 77 --> if not set -q argv[1]
set -x
return 0
...
64 64 ---> not set -q argv[1]
40 1133 --> for arg in $argv
set -l v (string split -m 1 "=" -- $arg)
switch (count $v)
case 1
set -gx $v $$v
case 2
if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
end
end
...
193 280 ---> set -l v (string split -m 1 "=" -- $arg)
87 87 ----> string split -m 1 "=" -- $arg
108 813 ---> switch (count $v)
case 1
set -gx $v $$v
case 2
if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
end
...
325 325 ----> count $v
33 380 ----> if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
...
78 78 -----> contains -- $v[1] PATH CDPATH MANPATH
194 194 -----> true
75 75 -----> set -gx $v[1] $v[2]
106 106 -> set -x fish_color_cwd blue
73 73 -> set -x fish_color_user blue
44 44 -> set -e VIRTUAL_ENV_DISABLE_PROMPT
52 52 -> set -x HOMEBREW_GITHUB_API_TOKEN 62c2a550603493ff423a90004ffd9059a166e17a
51 51 -> set -x MANPAGER most
56 56 -> set -x FZF_DEFAULT_COMMAND 'git ls-files 2> /dev/null || fd --type f'
644 663 > source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_title.fish
19 19 -> function fish_title
# emacs is basically the only term that can't handle it.
if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
end
...
204 8323 > fish_title
34 8119 -> if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
...
533 533 --> not set -q INSIDE_EMACS
521 7552 --> echo (status current-command) (__fish_pwd)
76 76 ---> status current-command
577 6955 ---> __fish_pwd
442 6135 ----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_pwd.fish
201 5693 -----> 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
...
5466 5466 ------> uname
26 26 ------> function __fish_pwd --description "Show current path"
pwd
...
243 243 ----> pwd
447 468 > source /Users/dugan/.config/fish/functions/fish_prompt.fish
21 21 -> function fish_prompt
set_color $fish_color_cwd
echo -n (basename $PWD)
set_color normal
echo -n ' ) '
...
81 42527 > __fish_on_interactive
1104 42356 -> __fish_config_interactive
2949 2977 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_config_interactive.fish
28 28 ---> function __fish_config_interactive -d "Initializations that should be performed when entering interactive mode"
if test $__fish_initialized -lt 3000
# Perform transitions relevant to going from fish 2.x to 3.x.
# Migrate old universal abbreviations to the new scheme.
__fish_abbr_old | source
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
if not set -q fish_greeting
set -l line1 (_ 'Welcome to fish, the friendly interactive shell')
set -l line2 ''
if test $__fish_initialized -lt 2300
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; and string length -q -- $fish_greeting
set -l line (_ "fish is running in private mode, history will not be persisted.")
set -g fish_greeting $fish_greeting.\n$line
end
# usage: __init_uvar VARIABLE VALUES...
function __init_uvar -d "Sets a universal variable if it's not already set"
if not set --query $argv[1]
set --universal $argv
end
end
#
# If we are starting up for the first time, set various defaults.
if test $__fish_initialized -lt 3100
# Regular syntax highlighting colors
__init_uvar fish_color_normal normal
__init_uvar fish_color_command 005fd7
__init_uvar fish_color_param 00afff
__init_uvar fish_color_redirection 00afff
__init_uvar fish_color_comment 990000
__init_uvar fish_color_error ff0000
__init_uvar fish_color_escape 00a6b2
__init_uvar fish_color_operator 00a6b2
__init_uvar fish_color_end 009900
__init_uvar fish_color_quote 999900
__init_uvar fish_color_autosuggestion 555 brblack
__init_uvar fish_color_user brgreen
__init_uvar fish_color_host normal
__init_uvar fish_color_host_remote yellow
__init_uvar fish_color_valid_path --underline
__init_uvar fish_color_status red
__init_uvar fish_color_cwd green
__init_uvar fish_color_cwd_root red
# Background color for matching quotes and parenthesis
__init_uvar fish_color_match --background=brblue
# Background color for search matches
__init_uvar fish_color_search_match bryellow --background=brblack
# Background color for selections
__init_uvar fish_color_selection white --bold --background=brblack
# XXX fish_color_cancel was added in 2.6, but this was added to post-2.3 initialization
# when 2.4 and 2.5 were already released
__init_uvar fish_color_cancel -r
# Pager colors
__init_uvar fish_pager_color_prefix white --bold --underline
__init_uvar fish_pager_color_completion
__init_uvar fish_pager_color_description B3A06D yellow
__init_uvar fish_pager_color_progress brwhite --background=cyan
#
# Directory history colors
#
__init_uvar fish_color_history_current --bold
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 $__fish_user_data_dir/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
set -l c $py $update_args
# Run python directly in the background and swallow all output
$c (: fish_update_completions: generating completions from man pages) >/dev/null 2>&1 &
# Then disown the job so that it continues to run in case of an early exit (#6269)
disown 2>&1 >/dev/null
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{,_root} changes value. Like all event handlers, it can't be
# autoloaded.
#
set -l varargs --on-variable fish_key_bindings
for var in user host cwd{,_root} status
set -a varargs --on-variable fish_color_$var
end
function __fish_repaint $varargs -d "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
#
# 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
complete -c ! --wraps not
#
# Only a few builtins take filenames; initialize the rest with no file completions
#
complete -c(builtin -n | string match -rv '(source|cd|exec|realpath|set|\\[|test|for)') --no-files
# 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
__init_uvar fish_key_bindings fish_default_key_bindings
# 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
# Similarly, enable TMUX's focus reporting when in tmux.
# This will be handled by
# - The keybindings (reading the sequence and triggering an event)
# - Any listeners (like the vi-cursor)
if set -q TMUX
and not set -q FISH_UNIT_TESTS_RUNNING
function __fish_enable_focus --on-event fish_postexec
echo -n \e\[\?1004h
end
function __fish_disable_focus --on-event fish_preexec
echo -n \e\[\?1004l
end
# Note: Don't call this initially because, even though we're in a fish_prompt event,
# tmux reacts sooo quickly that we'll still get a sequence before we're prepared for it.
# So this means that we won't get focus events until you've run at least one command, but that's preferable
# to always seeing `^[[I` when starting fish.
# __fish_enable_focus
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 (TODO) support this.
if test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309
function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes'
if status --is-command-substitution || 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 || contains -- sles $os && 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
# Bump this whenever some code below needs to run once when upgrading to a new version.
# The universal variable __fish_initialized is initialized in share/config.fish.
set __fish_initialized 3100
...
8 79 --> if test $__fish_initialized -lt 3000
# Perform transitions relevant to going from fish 2.x to 3.x.
# Migrate old universal abbreviations to the new scheme.
__fish_abbr_old | source
...
71 71 ---> test $__fish_initialized -lt 3000
7 55 --> if set -q __fish_config_interactive_done
return
...
48 48 ---> set -q __fish_config_interactive_done
52 52 --> set -g __fish_config_interactive_done
48 48 --> set -g __fish_active_key_bindings
6 49 --> if not set -q fish_greeting
set -l line1 (_ 'Welcome to fish, the friendly interactive shell')
set -l line2 ''
if test $__fish_initialized -lt 2300
set line2 \n(_ 'Type `help` for instructions on how to use fish')
end
set -U fish_greeting "$line1$line2"
...
43 43 ---> not set -q fish_greeting
6 47 --> if set -q fish_private_mode; and string length -q -- $fish_greeting
set -l line (_ "fish is running in private mode, history will not be persisted.")
set -g fish_greeting $fish_greeting.\n$line
...
41 41 ---> set -q fish_private_mode
20 20 --> function __init_uvar -d "Sets a universal variable if it's not already set"
if not set --query $argv[1]
set --universal $argv
end
...
5 59 --> if test $__fish_initialized -lt 3100
# Regular syntax highlighting colors
__init_uvar fish_color_normal normal
__init_uvar fish_color_command 005fd7
__init_uvar fish_color_param 00afff
__init_uvar fish_color_redirection 00afff
__init_uvar fish_color_comment 990000
__init_uvar fish_color_error ff0000
__init_uvar fish_color_escape 00a6b2
__init_uvar fish_color_operator 00a6b2
__init_uvar fish_color_end 009900
__init_uvar fish_color_quote 999900
__init_uvar fish_color_autosuggestion 555 brblack
__init_uvar fish_color_user brgreen
__init_uvar fish_color_host normal
__init_uvar fish_color_host_remote yellow
__init_uvar fish_color_valid_path --underline
__init_uvar fish_color_status red
__init_uvar fish_color_cwd green
__init_uvar fish_color_cwd_root red
# Background color for matching quotes and parenthesis
__init_uvar fish_color_match --background=brblue
# Background color for search matches
__init_uvar fish_color_search_match bryellow --background=brblack
# Background color for selections
__init_uvar fish_color_selection white --bold --background=brblack
# XXX fish_color_cancel was added in 2.6, but this was added to post-2.3 initialization
# when 2.4 and 2.5 were already released
__init_uvar fish_color_cancel -r
# Pager colors
__init_uvar fish_pager_color_prefix white --bold --underline
__init_uvar fish_pager_color_completion
__init_uvar fish_pager_color_description B3A06D yellow
__init_uvar fish_pager_color_progress brwhite --background=cyan
#
# Directory history colors
#
__init_uvar fish_color_history_current --bold
...
54 54 ---> test $__fish_initialized -lt 3100
17 188 --> if not set -q FISH_UNIT_TESTS_RUNNING
if not test -d $__fish_user_data_dir/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
set -l c $py $update_args
# Run python directly in the background and swallow all output
$c (: fish_update_completions: generating completions from man pages) >/dev/null 2>&1 &
# Then disown the job so that it continues to run in case of an early exit (#6269)
disown 2>&1 >/dev/null
break
end
end
end
...
42 42 ---> not set -q FISH_UNIT_TESTS_RUNNING
7 129 ---> if not test -d $__fish_user_data_dir/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
set -l c $py $update_args
# Run python directly in the background and swallow all output
$c (: fish_update_completions: generating completions from man pages) >/dev/null 2>&1 &
# Then disown the job so that it continues to run in case of an early exit (#6269)
disown 2>&1 >/dev/null
break
end
end
...
122 122 ----> not test -d $__fish_user_data_dir/generated_completions
12 516 --> 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
...
46 46 ---> status --is-interactive
18 458 ---> 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
...
302 302 ----> functions -q fish_greeting
59 59 ----> test -n "$fish_greeting"
79 79 ----> echo $fish_greeting
55 55 --> set -l varargs --on-variable fish_key_bindings
58 383 --> for var in user host cwd{,_root} status
set -a varargs --on-variable fish_color_$var
...
65 65 ---> set -a varargs --on-variable fish_color_$var
62 62 ---> set -a varargs --on-variable fish_color_$var
68 68 ---> set -a varargs --on-variable fish_color_$var
64 64 ---> set -a varargs --on-variable fish_color_$var
66 66 ---> set -a varargs --on-variable fish_color_$var
70 70 --> function __fish_repaint $varargs -d "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
...
7 89 --> 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'
...
82 82 ---> test -d /etc/init.d
198 198 --> complete -c [ --wraps test
56 56 --> complete -c ! --wraps not
1121 1435 --> complete -c(builtin -n | string match -rv '(source|cd|exec|realpath|set|\\[|test|for)') --no-files
314 314 ---> builtin -n | string match -rv '(source|cd|exec|realpath|set|\\[|test|for)'
30 30 --> 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
__init_uvar fish_key_bindings fish_default_key_bindings
# 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
...
103 18759 --> __fish_reload_key_bindings
65 139 ---> __init_uvar fish_key_bindings fish_default_key_bindings
8 74 ----> if not set --query $argv[1]
set --universal $argv
...
66 66 -----> not set --query $argv[1]
5 81 ---> if test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
return
...
76 76 ----> test "$fish_key_bindings" = "$__fish_active_key_bindings" -a -n "$fish_key_bindings"
7 1776 ---> 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
...
645 1769 ----> not functions -q "$fish_key_bindings"
1095 1124 -----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_default_key_bindings.fish
29 29 ------> 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
# Space expands abbrs _and_ inserts itself.
bind --preset $argv " " self-insert expand-abbr
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
# 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
...
112 112 ---> set -g __fish_active_key_bindings "$fish_key_bindings"
57 57 ---> set -g fish_bind_mode default
18 16128 ---> 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
...
61 61 ----> test "$fish_key_bindings" = fish_default_key_bindings
469 16049 ----> fish_default_key_bindings 2>/dev/null
11 132 -----> if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
...
65 65 ------> contains -- -h $argv
56 56 ------> contains -- --help $argv
18 365 -----> 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
...
46 46 ------> not set -q argv[1]
227 227 ------> bind --erase --all --preset
6 74 ------> 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
...
68 68 -------> test "$fish_key_bindings" != "fish_default_key_bindings"
14 133 -----> if not contains -- -s $argv
set argv "-s" $argv
...
62 62 ------> not contains -- -s $argv
57 57 ------> set argv "-s" $argv
922 10467 -----> __fish_shared_key_bindings $argv
1871 1945 ------> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/__fish_shared_key_bindings.fish
35 35 -------> 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
bind --preset $argv -k sright forward-bigword
bind --preset $argv -k sleft backward-bigword
# 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 __fish_whatis_current_token
# 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
# Prepend 'sudo ' to the current commandline
bind --preset $argv \es __fish_prepend_sudo
# 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
# Tmux' focus events.
# Exclude paste mode because that should get _everything_ literally.
for mode in (bind --list-modes | string match -v paste)
# We only need the in-focus event currently (to redraw the vi-cursor).
bind --preset -M $mode \e\[I 'emit fish_focus_in'
bind --preset -M $mode \e\[O false
bind --preset -M $mode \e\[\?1004h false
end
# 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).
#
# 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).
#
# See http://thejh.net/misc/website-terminal-copy-paste.
# Bind the starting sequence in every bind mode, even user-defined ones.
# 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.
bind --preset -M paste \r "commandline -i \n"
# 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)
bind --preset -M paste "'" "__fish_commandline_insert_escaped \' \$__fish_paste_quoted"
bind --preset -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted"
# Only insert spaces if we're either quoted or not at the beginning of the commandline
# - this strips leading spaces if they would trigger histignore.
bind --preset -M paste \ 'if set -q __fish_paste_quoted[1]; or string length -q -- (commandline -c); commandline -i " "; end'
...
22 22 -------> 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
...
9 9 -------> 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
...
8 8 -------> 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
...
13 154 ------> if contains -- -h $argv
or contains -- --help $argv
echo "Sorry but this function doesn't support -h or --help"
return 1
...
81 81 -------> contains -- -h $argv
60 60 -------> contains -- --help $argv
95 95 ------> bind --preset $argv \cy yank
62 62 ------> bind --preset $argv \ey yank-pop
68 68 ------> bind --preset $argv -k right forward-char
60 60 ------> bind --preset $argv -k left backward-char
57 57 ------> bind --preset $argv \e\[C forward-char
56 56 ------> bind --preset $argv \e\[D backward-char
53 53 ------> bind --preset $argv \eOC forward-char
54 54 ------> bind --preset $argv \eOD backward-char
62 62 ------> bind --preset $argv -k ppage beginning-of-history
56 56 ------> bind --preset $argv -k npage end-of-history
55 55 ------> bind --preset $argv \cx fish_clipboard_copy
54 54 ------> bind --preset $argv \cv fish_clipboard_paste
53 53 ------> bind --preset $argv \e cancel
53 53 ------> bind --preset $argv \t complete
53 53 ------> bind --preset $argv \cs pager-toggle-search
54 54 ------> bind --preset $argv --key btab complete-and-search
57 57 ------> bind --preset $argv \e\n "commandline -i \n"
57 57 ------> bind --preset $argv \e\r "commandline -i \n"
57 57 ------> bind --preset $argv -k down down-or-search
58 58 ------> bind --preset $argv -k up up-or-search
61 61 ------> bind --preset $argv \e\[A up-or-search
56 56 ------> bind --preset $argv \e\[B down-or-search
54 54 ------> bind --preset $argv \eOA up-or-search
54 54 ------> bind --preset $argv \eOB down-or-search
58 58 ------> bind --preset $argv -k sright forward-bigword
58 58 ------> bind --preset $argv -k sleft backward-bigword
56 56 ------> bind --preset $argv \e\eOC nextd-or-forward-word
56 56 ------> bind --preset $argv \e\eOD prevd-or-backward-word
56 56 ------> bind --preset $argv \e\e\[C nextd-or-forward-word
58 58 ------> bind --preset $argv \e\e\[D prevd-or-backward-word
52 52 ------> bind --preset $argv \eO3C nextd-or-forward-word
68 68 ------> bind --preset $argv \eO3D prevd-or-backward-word
109 109 ------> bind --preset $argv \e\[3C nextd-or-forward-word
97 97 ------> bind --preset $argv \e\[3D prevd-or-backward-word
67 67 ------> bind --preset $argv \e\[1\;3C nextd-or-forward-word
61 61 ------> bind --preset $argv \e\[1\;3D prevd-or-backward-word
63 63 ------> bind --preset $argv \e\[1\;9C nextd-or-forward-word
59 59 ------> bind --preset $argv \e\[1\;9D prevd-or-backward-word
60 60 ------> bind --preset $argv \e\eOA history-token-search-backward
58 58 ------> bind --preset $argv \e\eOB history-token-search-forward
58 58 ------> bind --preset $argv \e\e\[A history-token-search-backward
58 58 ------> bind --preset $argv \e\e\[B history-token-search-forward
58 58 ------> bind --preset $argv \eO3A history-token-search-backward
57 57 ------> bind --preset $argv \eO3B history-token-search-forward
67 67 ------> bind --preset $argv \e\[3A history-token-search-backward
57 57 ------> bind --preset $argv \e\[3B history-token-search-forward
61 61 ------> bind --preset $argv \e\[1\;3A history-token-search-backward
61 61 ------> bind --preset $argv \e\[1\;3B history-token-search-forward
59 59 ------> bind --preset $argv \e\[1\;9A history-token-search-backward
60 60 ------> bind --preset $argv \e\[1\;9B history-token-search-forward
59 59 ------> bind --preset $argv \e. history-token-search-backward
58 58 ------> bind --preset $argv \el __fish_list_current_token
59 59 ------> bind --preset $argv \ew __fish_whatis_current_token
70 70 ------> bind --preset $argv \cl 'echo -n (clear | string replace \e\[3J ""); commandline -f repaint'
58 58 ------> bind --preset $argv \cc __fish_cancel_commandline
55 55 ------> bind --preset $argv \cu backward-kill-line
55 55 ------> bind --preset $argv \cw backward-kill-path-component
58 58 ------> bind --preset $argv \e\[F end-of-line
60 60 ------> bind --preset $argv \e\[H beginning-of-line
68 68 ------> bind --preset $argv \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
57 57 ------> bind --preset $argv \cd delete-or-exit
56 56 ------> bind --preset $argv \es __fish_prepend_sudo
59 59 ------> bind --preset $argv -k f1 __fish_man_page
73 73 ------> bind --preset $argv \eh __fish_man_page
59 59 ------> bind --preset $argv \ep '__fish_paginate'
56 56 ------> bind --preset $argv \e\# __fish_toggle_comment_commandline
59 59 ------> bind --preset $argv \ee edit_command_buffer
57 57 ------> bind --preset $argv \ev edit_command_buffer
299 987 ------> for mode in (bind --list-modes | string match -v paste)
# We only need the in-focus event currently (to redraw the vi-cursor).
bind --preset -M $mode \e\[I 'emit fish_focus_in'
bind --preset -M $mode \e\[O false
bind --preset -M $mode \e\[\?1004h false
...
346 346 -------> bind --list-modes | string match -v paste
130 130 -------> bind --preset -M $mode \e\[I 'emit fish_focus_in'
138 138 -------> bind --preset -M $mode \e\[O false
74 74 -------> bind --preset -M $mode \e\[\?1004h false
283 1205 ------> for mode in (bind --list-modes | string match -v paste)
bind --preset -M $mode -m paste \e\[200~ '__fish_start_bracketed_paste'
...
498 498 -------> bind --list-modes | string match -v paste
424 424 -------> bind --preset -M $mode -m paste \e\[200~ '__fish_start_bracketed_paste'
259 259 ------> bind --preset -M paste \e\[201~ '__fish_stop_bracketed_paste'
175 175 ------> bind --preset -M paste "" self-insert
159 159 ------> bind --preset -M paste \r "commandline -i \n"
194 194 ------> bind --preset -M paste "'" "__fish_commandline_insert_escaped \' \$__fish_paste_quoted"
222 222 ------> bind --preset -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted"
138 138 ------> bind --preset -M paste \ 'if set -q __fish_paste_quoted[1]; or string length -q -- (commandline -c); commandline -i " "; end'
198 198 -----> bind --preset $argv "" self-insert
230 230 -----> bind --preset $argv " " self-insert expand-abbr
234 234 -----> bind --preset $argv \n execute
207 207 -----> bind --preset $argv \r execute
201 201 -----> bind --preset $argv \ck kill-line
189 189 -----> bind --preset $argv \eOC forward-char
195 195 -----> bind --preset $argv \eOD backward-char
190 190 -----> bind --preset $argv \e\[C forward-char
217 217 -----> bind --preset $argv \e\[D backward-char
406 406 -----> bind --preset $argv -k right forward-char
83 83 -----> bind --preset $argv -k left backward-char
65 65 -----> bind --preset $argv -k dc delete-char
60 60 -----> bind --preset $argv -k backspace backward-delete-char
61 61 -----> bind --preset $argv \x7f backward-delete-char
60 60 -----> bind --preset $argv \e\[1~ beginning-of-line
56 56 -----> bind --preset $argv \e\[3~ delete-char
66 66 -----> bind --preset $argv \e\[4~ end-of-line
116 116 -----> bind --preset $argv -k home beginning-of-line 2>/dev/null
93 93 -----> bind --preset $argv -k end end-of-line 2>/dev/null
68 68 -----> bind --preset $argv \e\[3\;2~ backward-delete-char
63 63 -----> bind --preset $argv \ca beginning-of-line
59 59 -----> bind --preset $argv \ce end-of-line
53 53 -----> bind --preset $argv \ch backward-delete-char
58 58 -----> bind --preset $argv \cp up-or-search
62 62 -----> bind --preset $argv \cn down-or-search
59 59 -----> bind --preset $argv \cf forward-char
57 57 -----> bind --preset $argv \cb backward-char
57 57 -----> bind --preset $argv \ct transpose-chars
59 59 -----> bind --preset $argv \et transpose-words
56 56 -----> bind --preset $argv \eu upcase-word
56 56 -----> bind --preset $argv \ec capitalize-word
56 56 -----> bind --preset $argv \e\x7f backward-kill-word
57 57 -----> bind --preset $argv \e\b backward-kill-word
56 56 -----> bind --preset $argv \eb backward-word
104 104 -----> bind --preset $argv \ef forward-word
79 79 -----> bind --preset $argv \e\[1\;5C forward-word
66 66 -----> bind --preset $argv \e\[1\;5D backward-word
88 88 -----> bind --preset $argv \e\< beginning-of-buffer
153 153 -----> bind --preset $argv \e\> end-of-buffer
135 135 -----> bind --preset $argv \ed kill-word
55 55 -----> 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
...
10 363 ---> if functions --query fish_user_key_bindings >/dev/null
fish_user_key_bindings 2>/dev/null
...
353 353 ----> functions --query fish_user_key_bindings >/dev/null
30 1454 --> 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
...
93 93 ---> not set -q FISH_UNIT_TESTS_RUNNING
19 19 ---> function __fish_enable_bracketed_paste --on-event fish_prompt
printf "\e[?2004h"
...
23 23 ---> function __fish_disable_bracketed_paste --on-event fish_preexec --on-event fish_exit
printf "\e[?2004l"
...
75 1289 ---> __fish_enable_bracketed_paste
1214 1214 ----> printf "\e[?2004h"
8 100 --> if set -q TMUX
and not set -q FISH_UNIT_TESTS_RUNNING
function __fish_enable_focus --on-event fish_postexec
echo -n \e\[\?1004h
end
function __fish_disable_focus --on-event fish_preexec
echo -n \e\[\?1004l
end
# Note: Don't call this initially because, even though we're in a fish_prompt event,
# tmux reacts sooo quickly that we'll still get a sequence before we're prepared for it.
# So this means that we won't get focus events until you've run at least one command, but that's preferable
# to always seeing `^[[I` when starting fish.
# __fish_enable_focus
...
92 92 ---> set -q TMUX
36 36 --> function __fish_winch_handler --on-signal WINCH -d "Repaint screen when window changes size"
commandline -f repaint >/dev/null 2>/dev/null
...
8 365 --> if test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309
function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes'
if status --is-command-substitution || 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
...
221 357 ---> test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309
136 136 ----> string match -r '\d+' 0"$TERM_PROGRAM_VERSION"
35 13965 --> 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 || contains -- sles $os && 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
...
470 8086 ---> not type -q __fish_command_not_found_handler
2001 2031 ----> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/type.fish
30 30 -----> 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' 's/short' '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
set -l short no
# 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_short
and set short 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
end
return $res
...
64 64 ----> set -q argv[1]
94 94 ----> set -l options 'h/help' 'a/all' 's/short' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
145 145 ----> argparse -n type -x t,p,P $options -- $argv
6 51 ----> if set -q _flag_help
__fish_print_help type
return 0
...
45 45 -----> set -q _flag_help
44 44 ----> set -l res 1
44 44 ----> set -l mode normal
46 46 ----> set -l multi no
44 44 ----> set -l selection all
42 42 ----> set -l short no
14 91 ----> 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
...
36 36 -----> set -q _flag_quiet
41 41 -----> set mode quiet
39 39 ----> set -q _flag_all
36 36 ----> set -q _flag_short
36 36 ----> set -q _flag_no_functions
58 4759 ----> 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
44 44 -----> set -l found 0
15 1127 -----> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
...
58 58 ------> test $selection != files
9 595 ------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
end
if test $multi != yes
continue
end
...
586 586 -------> functions -q -- $i
8 459 ------> 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
...
342 451 -------> contains -- $i (builtin -n)
109 109 --------> builtin -n
59 59 -----> set -l paths
19 3299 -----> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
53 53 ------> test $multi != yes
241 3227 ------> set paths (command -s -- $i)
2986 2986 -------> command -s -- $i
33 33 -----> 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
...
13 139 -----> if test $found = 0
and test $mode != quiet
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
68 68 ------> test $found = 0
58 58 ------> test $mode != quiet
50 50 ----> return $res
45 45 ---> set -l os
5 88 ---> 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 " ")
...
83 83 ----> test -r /etc/os-release
37 5711 ---> if contains -- suse $os || contains -- sles $os && 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
...
58 58 ----> contains -- suse $os
49 49 ----> contains -- sles $os
61 61 ----> test -f /usr/libexec/pk-command-not-found
54 54 ----> test -f /usr/lib/command-not-found
47 47 ----> test -f /run/current-system/sw/bin/command-not-found
162 2800 ----> type -q command-not-found
44 44 -----> set -q argv[1]
95 95 -----> set -l options 'h/help' 'a/all' 's/short' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
111 111 -----> argparse -n type -x t,p,P $options -- $argv
5 47 -----> if set -q _flag_help
__fish_print_help type
return 0
...
42 42 ------> set -q _flag_help
43 43 -----> set -l res 1
43 43 -----> set -l mode normal
45 45 -----> set -l multi no
44 44 -----> set -l selection all
41 41 -----> set -l short no
14 94 -----> 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
...
38 38 ------> set -q _flag_quiet
42 42 ------> set mode quiet
43 43 -----> set -q _flag_all
40 40 -----> set -q _flag_short
38 38 -----> set -q _flag_no_functions
59 1856 -----> 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
44 44 ------> set -l found 0
30 868 ------> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
...
48 48 -------> test $selection != files
5 248 -------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
end
if test $multi != yes
continue
end
...
243 243 --------> functions -q -- $i
12 542 -------> 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
...
425 530 --------> contains -- $i (builtin -n)
105 105 ---------> builtin -n
82 82 ------> set -l paths
20 641 ------> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
70 70 -------> test $multi != yes
217 551 -------> set paths (command -s -- $i)
334 334 --------> command -s -- $i
27 27 ------> 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
...
12 135 ------> if test $found = 0
and test $mode != quiet
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
67 67 -------> test $found = 0
56 56 -------> test $mode != quiet
54 54 -----> return $res
149 2585 ----> type -p -q pkgfile
46 46 -----> set -q argv[1]
87 87 -----> set -l options 'h/help' 'a/all' 's/short' 'f/no-functions' 't/type' 'p/path' 'P/force-path' 'q/quiet'
133 133 -----> argparse -n type -x t,p,P $options -- $argv
6 54 -----> if set -q _flag_help
__fish_print_help type
return 0
...
48 48 ------> set -q _flag_help
48 48 -----> set -l res 1
46 46 -----> set -l mode normal
48 48 -----> set -l multi no
46 46 -----> set -l selection all
46 46 -----> set -l short no
14 99 -----> 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
...
40 40 ------> set -q _flag_quiet
45 45 ------> set mode quiet
43 43 -----> set -q _flag_all
40 40 -----> set -q _flag_short
40 40 -----> set -q _flag_no_functions
49 1611 -----> 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') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
end
...
48 48 ------> set -l found 0
24 760 ------> if test $selection != files
if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
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
...
61 61 -------> test $selection != files
7 236 -------> if functions -q -- $i
set res 0
set found 1
switch $mode
case normal
printf (_ '%s is a function') $i
if test $short != yes
echo (_ ' with definition')
functions $i
else
set -l func_path (functions --details $i)
if not contains -- $func_path - stdin
printf (_ ' (defined in %s)') $func_path
end
echo
end
case type
echo (_ 'function')
case path
set -l func_path (functions --details $i)
switch $func_path
case "-"
case "n/a"
case "stdin"
break
case "*"
echo $func_path
end
end
if test $multi != yes
continue
end
...
229 229 --------> functions -q -- $i
7 439 -------> 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
...
334 432 --------> contains -- $i (builtin -n)
98 98 ---------> builtin -n
57 57 ------> set -l paths
14 559 ------> if test $multi != yes
set paths (command -s -- $i)
else
set paths (command -sa -- $i)
...
53 53 -------> test $multi != yes
164 492 -------> set paths (command -s -- $i)
328 328 --------> command -s -- $i
22 22 ------> 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
...
11 116 ------> if test $found = 0
and test $mode != quiet
and test $mode != path
printf (_ "%s: Could not find '%s'\n") type $i >&2
...
53 53 -------> test $found = 0
52 52 -------> test $mode != quiet
49 49 -----> return $res
20 20 ----> function __fish_command_not_found_handler --on-event fish_command_not_found
__fish_default_command_not_found_handler $argv[1]
...
167 167 --> set __fish_initialized 3100
90 90 -> functions -e __fish_on_interactive
476 519 > source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_mode_prompt.fish
43 43 -> function fish_mode_prompt --description "Displays the current mode"
# To reuse the mode indicator use this function instead
fish_default_mode_prompt
...
111 4408 > fish_mode_prompt
1624 4297 -> fish_default_mode_prompt
2416 2448 --> source /usr/local/Cellar/fish/3.1.0/share/fish/functions/fish_default_mode_prompt.fish
32 32 ---> 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 replace
set_color --bold --background cyan white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
end
...
22 225 --> 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 replace
set_color --bold --background cyan white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'
end
set_color normal
echo -n ' '
...
83 83 ---> test "$fish_key_bindings" = "fish_vi_key_bindings"
120 120 ---> test "$fish_key_bindings" = "fish_hybrid_key_bindings"
118 12107 > fish_prompt
253 253 -> set_color $fish_color_cwd
462 11552 -> echo -n (basename $PWD)
11090 11090 --> basename $PWD
103 103 -> set_color normal
81 81 -> echo -n ' ) '
86 4476 > fish_title
28 4390 -> if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
...
56 56 --> not set -q INSIDE_EMACS
3150 4306 --> echo (status current-command) (__fish_pwd)
89 89 ---> status current-command
643 1067 ---> __fish_pwd
424 424 ----> pwd
335 585 > __fish_disable_bracketed_paste exit
250 250 -> printf "\e[?2004l"
136 1049 > fish_title exit
42 913 -> if not set -q INSIDE_EMACS
echo (status current-command) (__fish_pwd)
...
56 56 --> not set -q INSIDE_EMACS
410 815 --> echo (status current-command) (__fish_pwd)
57 57 ---> status current-command
152 348 ---> __fish_pwd
196 196 ----> pwd
382 382 > exit
139 247 > __fish_disable_bracketed_paste 0
108 108 -> printf "\e[?2004l"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment