fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
6d0cd3d9b
master
1# localization: tier1 2 3# This file does some internal fish setup. 4# It is not recommended to remove or edit it. 5 6set -g IFS\n\ \t 7set -qg __fish_added_user_paths 8or set -g __fish_added_user_paths 9 10# 11# Set default search paths for completions and shellscript functions 12# unless they already exist 13# 14 15# Grab extra directories (as specified by the build process, usually for 16# third-party packages to ship completions &c. 17set -l __extra_completionsdir 18set -l __extra_functionsdir 19set -l __extra_confdir 20status get-file __fish_build_paths.fish| source 21 22# Compute the directories for vendor configuration. We want to include 23# all of XDG_DATA_DIRS, as well as the __extra_* dirs defined above. 24set -l xdg_data_dirs /usr/local/share/fish /usr/share/fish 25if test -n " $XDG_DATA_DIRS " 26set --path xdg_data_dirs$XDG_DATA_DIRS 27set xdg_data_dirs( string replace -r'([^/])/$' '$1' --$xdg_data_dirs ) /fish 28end 29 30set -g __fish_vendor_completionsdirs 31set -g __fish_vendor_functionsdirs 32set -g __fish_vendor_confdirs 33# Don't load vendor directories when running unit tests 34if not set -q FISH_UNIT_TESTS_RUNNING 35set __fish_vendor_completionsdirs$__fish_user_data_dir /vendor_completions.d$xdg_data_dirs /vendor_completions.d 36set __fish_vendor_functionsdirs$__fish_user_data_dir /vendor_functions.d$xdg_data_dirs /vendor_functions.d 37set __fish_vendor_confdirs$__fish_user_data_dir /vendor_conf.d$xdg_data_dirs /vendor_conf.d 38 39# Ensure that extra directories are always included. 40if not contains --$__extra_completionsdir $__fish_vendor_completionsdirs 41set -a __fish_vendor_completionsdirs$__extra_completionsdir 42end 43if not contains --$__extra_functionsdir $__fish_vendor_functionsdirs 44set -a __fish_vendor_functionsdirs$__extra_functionsdir 45end 46if not contains --$__extra_confdir $__fish_vendor_confdirs 47set -a __fish_vendor_confdirs$__extra_confdir 48end 49end 50 51# Set up function and completion paths. Make sure that the fish 52# default functions/completions are included in the respective path. 53 54if not set -q fish_function_path 55set fish_function_path$__fish_config_dir /functions$__fish_sysconf_dir /functions$__fish_vendor_functionsdirs 56end 57 58if not set -q fish_complete_path 59set fish_complete_path$__fish_config_dir /completions$__fish_sysconf_dir /completions$__fish_vendor_completionsdirs 60set -a fish_complete_path$__fish_cache_dir /generated_completions 61end 62 63# Add a handler for when fish_user_path changes, so we can apply the same changes to PATH 64function __fish_reconstruct_path -d"Update PATH when fish_user_paths changes" --on-variable fish_user_paths 65# Deduplicate $fish_user_paths 66# This should help with people appending to it in config.fish 67set -l new_user_path 68for pathin ( string split : --$fish_user_paths ) 69if not contains --$path $new_user_path 70set -a new_user_path$path 71end 72end 73 74if test ( count $new_user_path ) -lt ( count $fish_user_paths ) 75# This will end up calling us again, so we return 76set fish_user_paths$new_user_path 77return 78end 79 80set -l local_path$PATH 81 82for xin $__fish_added_user_paths 83set -l idx( contains --index --$x $local_path ) 84and set -e local_path[ $idx ] 85end 86 87set -g __fish_added_user_paths 88if set -q fish_user_paths 89# Explicitly split on ":" because $fish_user_paths might not be a path variable, 90# but $PATH definitely is. 91for xin ( string split":" --$fish_user_paths [ -1 .. 1 ]) 92if set -l idx( contains --index --$x $local_path ) 93set -e local_path[ $idx ] 94else 95set -ga __fish_added_user_paths$x 96end 97set -p local_path$x 98end 99end 100 101set -xg PATH$local_path 102end 103 104# 105# Launch debugger on SIGTRAP 106# 107function fish_sigtrap_handler --on-signal TRAP --no-scope-shadowing --description"TRAP handler: debug prompt" 108breakpoint 109end 110 111# 112# When a prompt is first displayed, make sure that interactive 113# mode-specific initializations have been performed. 114# This includes a `read` prompt, hence the fish_read event. 115# This handler removes itself after it is first called. 116# 117function __fish_on_interactive --on-event fish_prompt --on-event fish_read 118# We erase this *first* so it can't be called again, 119# e.g. if fish_greeting calls "read". 120functions -e __fish_on_interactive 121__fish_config_interactive 122end 123 124# Set the locale if it isn't explicitly set. Allowing the lack of locale env vars to imply the 125# C/POSIX locale causes too many problems. Do this before reading the snippets because they might be 126# in UTF-8 (with non-ASCII characters). 127not set -q LANG# (fast path - no need to load the file if we have $LANG) 128and __fish_set_locale 129 130# 131# Some things should only be done for login terminals 132# This used to be in etc/config.fish - keep it here to keep the semantics 133# 134if status is-login&& command -sq /usr/libexec/path_helper 135__fish_macos_set_env PATH /etc/paths'/etc/paths.d' 136if test -n " $MANPATH " 137__fish_macos_set_env MANPATH /etc/manpaths'/etc/manpaths.d' 138end 139functions -e __fish_macos_set_env 140end 141 142# Invoke this here to apply the current value of fish_user_path after 143# PATH is possibly set above. 144__fish_reconstruct_path 145 146if status is-interactive 147__fish_theme_migrate 148end 149if status is-interactive|| set -qgx __fish_force_load_default_theme 150fish_config theme choose default --no-override 151end 152 153# As last part of initialization, source the conf directories. 154# Implement precedence (User > Admin > Extra (e.g. vendors) > Fish) by basically doing "basename". 155set -l sourcelist 156for filein $__fish_config_dir /conf.d/*.fish$__fish_sysconf_dir /conf.d/*.fish$__fish_vendor_confdirs /*.fish 157set -l basename( string replace -r'^.*/' '' --$file ) 158contains --$basename $sourcelist 159and continue 160set sourcelist$sourcelist $basename 161# Also skip non-files or unreadable files. 162# This allows one to use e.g. symlinks to /dev/null to "mask" something (like in systemd). 163test -f $file -a -r $file 164and source $file 165end