vitorpy's Dotfiles

current setup

+750 -23
+6 -1
.gitconfig
··· 1 1 [user] 2 2 email = 12871+vitorpy@users.noreply.github.com 3 3 name = Vitor Py Braga 4 + signingKey = 04983CBC2428686A 4 5 [commit] 5 - gpgsign = false 6 + gpgsign = true 6 7 [alias] 7 8 logs = log --show-signature 8 9 [includeIf "gitdir:~/tito/"] ··· 11 12 defaultBranch = main 12 13 [core] 13 14 excludesFile = ~/.gitignore 15 + [push] 16 + autoSetupRemote = true 17 + [diff "lockb"] 18 + textconv = bun
+184
fish/completions/bun.fish
··· 1 + # This is terribly complicated 2 + # It's because: 3 + # 1. bun run has to have dynamic completions 4 + # 2. there are global options 5 + # 3. bun {install add remove} gets special options 6 + # 4. I don't know how to write fish completions well 7 + # Contributions very welcome!! 8 + 9 + function __fish__get_bun_bins 10 + string split ' ' (bun getcompletes b) 11 + end 12 + 13 + function __fish__get_bun_scripts 14 + set -lx SHELL bash 15 + set -lx MAX_DESCRIPTION_LEN 40 16 + string trim (string split '\n' (string split '\t' (bun getcompletes z))) 17 + end 18 + 19 + function __fish__get_bun_packages 20 + if test (commandline -ct) != "" 21 + set -lx SHELL fish 22 + string split ' ' (bun getcompletes a (commandline -ct)) 23 + end 24 + end 25 + 26 + function __history_completions 27 + set -l tokens (commandline --current-process --tokenize) 28 + history --prefix (commandline) | string replace -r \^$tokens[1]\\s\* "" | string replace -r \^$tokens[2]\\s\* "" | string split ' ' 29 + end 30 + 31 + function __fish__get_bun_bun_js_files 32 + string split ' ' (bun getcompletes j) 33 + end 34 + 35 + set -l bun_install_boolean_flags yarn production optional development no-save dry-run force no-cache silent verbose global 36 + set -l bun_install_boolean_flags_descriptions "Write a yarn.lock file (yarn v1)" "Don't install devDependencies" "Add dependency to optionalDependencies" "Add dependency to devDependencies" "Don't install devDependencies" "Don't install anything" "Always request the latest versions from the registry & reinstall all dependencies" "Ignore manifest cache entirely" "Don't output anything" "Excessively verbose logging" "Use global folder" 37 + 38 + set -l bun_builtin_cmds_without_run dev create help bun upgrade discord install remove add init pm x 39 + set -l bun_builtin_cmds_accepting_flags create help bun upgrade discord run init link unlink pm x 40 + 41 + function __bun_complete_bins_scripts --inherit-variable bun_builtin_cmds_without_run -d "Emit bun completions for bins and scripts" 42 + # Do nothing if we already have a builtin subcommand, 43 + # or any subcommand other than "run". 44 + if __fish_seen_subcommand_from $bun_builtin_cmds_without_run 45 + or not __fish_use_subcommand && not __fish_seen_subcommand_from run 46 + return 47 + end 48 + # Do we already have a bin or script subcommand? 49 + set -l bins (__fish__get_bun_bins) 50 + if __fish_seen_subcommand_from $bins 51 + return 52 + end 53 + # Scripts have descriptions appended with a tab separator. 54 + # Strip off descriptions for the purposes of subcommand testing. 55 + set -l scripts (__fish__get_bun_scripts) 56 + if __fish_seen_subcommand_from $(string split \t -f 1 -- $scripts) 57 + return 58 + end 59 + # Emit scripts. 60 + for script in $scripts 61 + echo $script 62 + end 63 + # Emit binaries and JS files (but only if we're doing `bun run`). 64 + if __fish_seen_subcommand_from run 65 + for bin in $bins 66 + echo "$bin"\t"package bin" 67 + end 68 + for file in (__fish__get_bun_bun_js_files) 69 + echo "$file"\t"Bun.js" 70 + end 71 + end 72 + end 73 + 74 + 75 + # Clear existing completions 76 + complete -e -c bun 77 + 78 + # Dynamically emit scripts and binaries 79 + complete -c bun -f -a "(__bun_complete_bins_scripts)" 80 + 81 + # Complete flags if we have no subcommand or a flag-friendly one. 82 + set -l flag_applies "__fish_use_subcommand; or __fish_seen_subcommand_from $bun_builtin_cmds_accepting_flags" 83 + complete -c bun \ 84 + -n $flag_applies --no-files -s 'u' -l 'origin' -r -d 'Server URL. Rewrites import paths' 85 + complete -c bun \ 86 + -n $flag_applies --no-files -s 'p' -l 'port' -r -d 'Port number to start server from' 87 + complete -c bun \ 88 + -n $flag_applies --no-files -s 'd' -l 'define' -r -d 'Substitute K:V while parsing, e.g. --define process.env.NODE_ENV:\"development\"' 89 + complete -c bun \ 90 + -n $flag_applies --no-files -s 'e' -l 'external' -r -d 'Exclude module from transpilation (can use * wildcards). ex: -e react' 91 + complete -c bun \ 92 + -n $flag_applies --no-files -l 'use' -r -d 'Use a framework (ex: next)' 93 + complete -c bun \ 94 + -n $flag_applies --no-files -l 'hot' -r -d 'Enable hot reloading in Bun\'s JavaScript runtime' 95 + 96 + # Complete dev and create as first subcommand. 97 + complete -c bun \ 98 + -n "__fish_use_subcommand" -a 'dev' -d 'Start dev server' 99 + complete -c bun \ 100 + -n "__fish_use_subcommand" -a 'create' -f -d 'Create a new project from a template' 101 + 102 + # Complete "next" and "react" if we've seen "create". 103 + complete -c bun \ 104 + -n "__fish_seen_subcommand_from create" -a 'next' -d 'new Next.js project' 105 + 106 + complete -c bun \ 107 + -n "__fish_seen_subcommand_from create" -a 'react' -d 'new React project' 108 + 109 + # Complete "upgrade" as first subcommand. 110 + complete -c bun \ 111 + -n "__fish_use_subcommand" -a 'upgrade' -d 'Upgrade bun to the latest version' -x 112 + # Complete "-h/--help" unconditionally. 113 + complete -c bun \ 114 + -s "h" -l "help" -d 'See all commands and flags' -x 115 + 116 + # Complete "-v/--version" if we have no subcommand. 117 + complete -c bun \ 118 + -n "not __fish_use_subcommand" -l "version" -s "v" -d 'Bun\'s version' -x 119 + 120 + # Complete additional subcommands. 121 + complete -c bun \ 122 + -n "__fish_use_subcommand" -a 'discord' -d 'Open bun\'s Discord server' -x 123 + 124 + 125 + complete -c bun \ 126 + -n "__fish_use_subcommand" -a 'bun' -d 'Generate a new bundle' 127 + 128 + 129 + complete -c bun \ 130 + -n "__fish_seen_subcommand_from bun" -F -d 'Bundle this' 131 + 132 + complete -c bun \ 133 + -n "__fish_seen_subcommand_from create; and __fish_seen_subcommand_from react next" -F -d "Create in directory" 134 + 135 + 136 + complete -c bun \ 137 + -n "__fish_use_subcommand" -a 'init' -F -d 'Start an empty Bun project' 138 + 139 + complete -c bun \ 140 + -n "__fish_use_subcommand" -a 'install' -f -d 'Install packages from package.json' 141 + 142 + complete -c bun \ 143 + -n "__fish_use_subcommand" -a 'add' -F -d 'Add a package to package.json' 144 + 145 + complete -c bun \ 146 + -n "__fish_use_subcommand" -a 'remove' -F -d 'Remove a package from package.json' 147 + 148 + 149 + for i in (seq (count $bun_install_boolean_flags)) 150 + complete -c bun \ 151 + -n "__fish_seen_subcommand_from install add remove" -l "$bun_install_boolean_flags[$i]" -d "$bun_install_boolean_flags_descriptions[$i]" 152 + end 153 + 154 + complete -c bun \ 155 + -n "__fish_seen_subcommand_from install add remove" -l 'cwd' -d 'Change working directory' 156 + 157 + complete -c bun \ 158 + -n "__fish_seen_subcommand_from install add remove" -l 'cache-dir' -d 'Choose a cache directory (default: $HOME/.bun/install/cache)' 159 + 160 + complete -c bun \ 161 + -n "__fish_seen_subcommand_from add" -d 'Popular' -a '(__fish__get_bun_packages)' 162 + 163 + complete -c bun \ 164 + -n "__fish_seen_subcommand_from add" -d 'History' -a '(__history_completions)' 165 + 166 + complete -c bun \ 167 + -n "__fish_seen_subcommand_from pm; and not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts) cache;" -a 'bin ls cache hash hash-print hash-string' -f 168 + 169 + complete -c bun \ 170 + -n "__fish_seen_subcommand_from pm; and __fish_seen_subcommand_from cache; and not __fish_seen_subcommand_from (__fish__get_bun_bins) (__fish__get_bun_scripts);" -a 'rm' -f 171 + 172 + # Add built-in subcommands with descriptions. 173 + complete -c bun -n "__fish_use_subcommand" -a "create" -f -d "Create a new project from a template" 174 + complete -c bun -n "__fish_use_subcommand" -a "build bun" --require-parameter -F -d "Transpile and bundle one or more files" 175 + complete -c bun -n "__fish_use_subcommand" -a "upgrade" -d "Upgrade Bun" 176 + complete -c bun -n "__fish_use_subcommand" -a "run" -d "Run a script or package binary" 177 + complete -c bun -n "__fish_use_subcommand" -a "install" -d "Install dependencies from package.json" -f 178 + complete -c bun -n "__fish_use_subcommand" -a "remove" -d "Remove a dependency from package.json" -f 179 + complete -c bun -n "__fish_use_subcommand" -a "add" -d "Add a dependency to package.json" -f 180 + complete -c bun -n "__fish_use_subcommand" -a "init" -d "Initialize a Bun project in this directory" -f 181 + complete -c bun -n "__fish_use_subcommand" -a "link" -d "Register or link a local npm package" -f 182 + complete -c bun -n "__fish_use_subcommand" -a "link" -d "Unregister a local npm package" -f 183 + complete -c bun -n "__fish_use_subcommand" -a "pm" -d "Additional package management utilities" -f 184 + complete -c bun -n "__fish_use_subcommand" -a "x" -d "Execute a package binary, installing if needed" -f
+8
fish/completions/fzf_configure_bindings.fish
··· 1 + complete fzf_configure_bindings --no-files 2 + complete fzf_configure_bindings --long help --short h --description "Print help" --condition "not __fish_seen_argument --help -h" 3 + complete fzf_configure_bindings --long directory --description "Change the key binding for Search Directory" --condition "not __fish_seen_argument --directory" 4 + complete fzf_configure_bindings --long git_log --description "Change the key binding for Search Git Log" --condition "not __fish_seen_argument --git_log" 5 + complete fzf_configure_bindings --long git_status --description "Change the key binding for Search Git Status" --condition "not __fish_seen_argument --git_status" 6 + complete fzf_configure_bindings --long history --description "Change the key binding for Search History" --condition "not __fish_seen_argument --history" 7 + complete fzf_configure_bindings --long processes --description "Change the key binding for Search Processes" --condition "not __fish_seen_argument --processes" 8 + complete fzf_configure_bindings --long variables --description "Change the key binding for Search Variables" --condition "not __fish_seen_argument --variables"
+28
fish/conf.d/fzf.fish
··· 1 + # fzf.fish is only meant to be used in interactive mode. If not in interactive mode and not in CI, skip the config to speed up shell startup 2 + if not status is-interactive && test "$CI" != true 3 + exit 4 + end 5 + 6 + # Because of scoping rules, to capture the shell variables exactly as they are, we must read 7 + # them before even executing _fzf_search_variables. We use psub to store the 8 + # variables' info in temporary files and pass in the filenames as arguments. 9 + # This variable is global so that it can be referenced by fzf_configure_bindings and in tests 10 + set --global _fzf_search_vars_command '_fzf_search_variables (set --show | psub) (set --names | psub)' 11 + 12 + 13 + # Install the default bindings, which are mnemonic and minimally conflict with fish's preset bindings 14 + fzf_configure_bindings 15 + 16 + # Doesn't erase autoloaded _fzf_* functions because they are not easily accessible once key bindings are erased 17 + function _fzf_uninstall --on-event fzf_uninstall 18 + _fzf_uninstall_bindings 19 + 20 + set --erase _fzf_search_vars_command 21 + functions --erase _fzf_uninstall _fzf_migration_message _fzf_uninstall_bindings fzf_configure_bindings 22 + complete --erase fzf_configure_bindings 23 + 24 + set_color cyan 25 + echo "fzf.fish uninstalled." 26 + echo "You may need to manually remove fzf_configure_bindings from your config.fish if you were using custom key bindings." 27 + set_color normal 28 + end
-1
fish/conf.d/rustup.fish
··· 1 - . "$HOME/.cargo/env.fish"
+3 -3
fish/conf.d/virtualfish-loader.fish
··· 1 - set -g VIRTUALFISH_VERSION 2.5.6 2 - set -g VIRTUALFISH_PYTHON_EXEC /home/vpb/.local/share/pipx/venvs/virtualfish/bin/python 3 - source /home/vpb/.local/share/pipx/venvs/virtualfish/lib/python3.12/site-packages/virtualfish/virtual.fish 1 + set -g VIRTUALFISH_VERSION 2.5.8 2 + set -g VIRTUALFISH_PYTHON_EXEC /usr/bin/python 3 + source /home/vitorpy/.local/lib/python3.12/site-packages/virtualfish/virtual.fish 4 4 emit virtualfish_did_setup_plugins
+13 -10
fish/config.fish
··· 1 1 /home/linuxbrew/.linuxbrew/bin/brew shellenv | source 2 2 3 + fish_add_path /home/vpb/.local/bin 4 + 3 5 if status is-interactive 4 6 set fish_greeting 7 + set EDITOR nvim 8 + 5 9 # Commands to run in interactive sessions can go here 6 10 starship init fish | source 7 11 direnv hook fish | source 12 + nvm use latest 8 13 end 9 14 10 - fish_add_path /home/vpb/.local/bin 11 15 12 - fish_add_path /home/vpb/.rvm/bin 13 - rvm default 16 + # Created by `pipx` on 2024-04-12 12:49:16 17 + set PATH $PATH /home/vitorpy/.local/bin 14 18 15 - fish_add_path /home/vpb/.local/share/solana/install/active_release/bin 16 - fish_add_path /home/vpb/.foundry/bin 19 + # bun 20 + set --export BUN_INSTALL "$HOME/.bun" 21 + set --export PATH $BUN_INSTALL/bin $PATH 17 22 18 - fish_add_path /home/vpb/.cargo/bin 23 + set ANTHROPIC_API_KEY "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" 19 24 20 - nvm use latest 21 - pyenv init - | source 22 - 23 - fish_add_path -a /home/vpb/.config/.foundry/bin 25 + # The next line updates PATH for the Google Cloud SDK. 26 + if [ -f '/home/vitorpy/google-cloud-sdk/path.fish.inc' ]; . '/home/vitorpy/google-cloud-sdk/path.fish.inc'; end
+21
fish/config.fish.backup
··· 1 + /home/linuxbrew/.linuxbrew/bin/brew shellenv | source 2 + 3 + fish_add_path /home/vpb/.local/bin 4 + 5 + if status is-interactive 6 + set fish_greeting 7 + set EDITOR nvim 8 + 9 + # Commands to run in interactive sessions can go here 10 + starship init fish | source 11 + direnv hook fish | source 12 + nvm use latest 13 + end 14 + 15 + 16 + # Created by `pipx` on 2024-04-12 12:49:16 17 + set PATH $PATH /home/vitorpy/.local/bin 18 + 19 + # bun 20 + set --export BUN_INSTALL "$HOME/.bun" 21 + set --export PATH $BUN_INSTALL/bin $PATH
+1
fish/fish_plugins
··· 1 1 jorgebucaran/fisher 2 2 edc/bass 3 3 jorgebucaran/nvm.fish 4 + patrickf1/fzf.fish
+3 -2
fish/fish_variables
··· 5 5 SETUVAR _fisher_edc_2F_bass_files:\x7e/\x2econfig/fish/functions/__bass\x2epy\x1e\x7e/\x2econfig/fish/functions/bass\x2efish 6 6 SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish 7 7 SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:\x7e/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_list\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e\x7e/\x2econfig/fish/functions/nvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e\x7e/\x2econfig/fish/completions/nvm\x2efish 8 - SETUVAR _fisher_plugins:jorgebucaran/fisher\x1eedc/bass\x1ejorgebucaran/nvm\x2efish 8 + SETUVAR _fisher_patrickf1_2F_fzf_2E_fish_files:\x7e/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_changed_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_diff_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e\x7e/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e\x7e/\x2econfig/fish/completions/fzf_configure_bindings\x2efish 9 + SETUVAR _fisher_plugins:jorgebucaran/fisher\x1eedc/bass\x1ejorgebucaran/nvm\x2efish\x1epatrickf1/fzf\x2efish 9 10 SETUVAR _fisher_upgraded_to_4_4:\x1d 10 11 SETUVAR fish_color_autosuggestion:555\x1ebrblack 11 12 SETUVAR fish_color_cancel:\x2dr ··· 35 36 SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline 36 37 SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan 37 38 SETUVAR fish_pager_color_selected_background:\x2dr 38 - SETUVAR fish_user_paths:/home/vpb/\x2elocal/bin\x1e/home/vpb/\x2ervm/bin\x1e/home/vpb/\x2epyenv/bin\x1e/home/vpb/\x2efoundry/bin\x1e/home/vpb/\x2ecargo/bin\x1e/home/vpb/\x2elocal/share/solana/install/active_release/bin\x1e/home/vpb/\x2econfig/\x2efoundry/bin 39 + SETUVAR fish_user_paths:/home/vitorpy/\x2ecargo/bin\x1e/home/vpb/\x2elocal/bin\x1e/home/vpb/\x2ervm/bin\x1e/home/vpb/\x2epyenv/bin\x1e/home/vpb/\x2efoundry/bin\x1e/home/vpb/\x2ecargo/bin\x1e/home/vpb/\x2elocal/share/solana/install/active_release/bin\x1e/home/vpb/\x2econfig/\x2efoundry/bin
+43
fish/functions/_fzf_configure_bindings_help.fish
··· 1 + function _fzf_configure_bindings_help --description "Prints the help message for fzf_configure_bindings." 2 + echo "\ 3 + USAGE: 4 + fzf_configure_bindings [--COMMAND=[KEY_SEQUENCE]...] 5 + 6 + DESCRIPTION 7 + fzf_configure_bindings installs key bindings for fzf.fish's commands and erases any bindings it 8 + previously installed. It installs bindings for both default and insert modes. fzf.fish executes 9 + it without options on fish startup to install the out-of-the-box key bindings. 10 + 11 + By default, commands are bound to a mnemonic key sequence, shown below. Each command's binding 12 + can be configured using a namesake corresponding option: 13 + COMMAND | DEFAULT KEY SEQUENCE | CORRESPONDING OPTION 14 + Search Directory | Ctrl+Alt+F (F for file) | --directory 15 + Search Git Log | Ctrl+Alt+L (L for log) | --git_log 16 + Search Git Status | Ctrl+Alt+S (S for status) | --git_status 17 + Search History | Ctrl+R (R for reverse) | --history 18 + Search Processes | Ctrl+Alt+P (P for process) | --processes 19 + Search Variables | Ctrl+V (V for variable) | --variables 20 + Override a command's binding by specifying its corresponding option with the desired key 21 + sequence. Disable a command's binding by specifying its corresponding option with no value. 22 + 23 + Because fzf_configure_bindings erases bindings it previously installed, it can be cleanly 24 + executed multiple times. Once the desired fzf_configure_bindings command has been found, add it 25 + to your config.fish in order to persist the customized bindings. 26 + 27 + In terms of validation, fzf_configure_bindings fails if passed unknown options. It expects an 28 + equals sign between an option's name and value. However, it does not validate key sequences. 29 + 30 + Pass -h or --help to print this help message and exit. 31 + 32 + EXAMPLES 33 + Default bindings but bind Search Directory to Ctrl+F and Search Variables to Ctrl+Alt+V 34 + \$ fzf_configure_bindings --directory=\cf --variables=\e\cv 35 + Default bindings but disable Search History 36 + \$ fzf_configure_bindings --history= 37 + An agglomeration of different options 38 + \$ fzf_configure_bindings --git_status=\cg --history=\ch --variables= --processes= 39 + 40 + SEE Also 41 + To learn more about fish key bindings, see bind(1) and fish_key_reader(1). 42 + " 43 + end
+15
fish/functions/_fzf_extract_var_info.fish
··· 1 + # helper function for _fzf_search_variables 2 + function _fzf_extract_var_info --argument-names variable_name set_show_output --description "Extract and reformat lines pertaining to \$variable_name from \$set_show_output." 3 + # Extract only the lines about the variable, all of which begin with either 4 + # $variable_name: ...or... $variable_name[ 5 + string match --regex "^\\\$$variable_name(?::|\[).*" <$set_show_output | 6 + 7 + # Strip the variable name prefix, including ": " for scope info lines 8 + string replace --regex "^\\\$$variable_name(?:: )?" '' | 9 + 10 + # Distill the lines of values, replacing... 11 + # [1]: |value| 12 + # ...with... 13 + # [1] value 14 + string replace --regex ": \|(.*)\|" ' $1' 15 + end
+49
fish/functions/_fzf_preview_changed_file.fish
··· 1 + # helper for _fzf_search_git_status 2 + # arg should be a line from git status --short, e.g. 3 + # MM functions/_fzf_preview_changed_file.fish 4 + # D README.md 5 + # R LICENSE -> "New License" 6 + function _fzf_preview_changed_file --argument-names path_status --description "Show the git diff of the given file." 7 + # remove quotes because they'll be interpreted literally by git diff 8 + # no need to requote when referencing $path because fish does not perform word splitting 9 + # https://fishshell.com/docs/current/fish_for_bash_users.html 10 + set -f path (string unescape (string sub --start 4 $path_status)) 11 + # first letter of short format shows index, second letter shows working tree 12 + # https://git-scm.com/docs/git-status/2.35.0#_short_format 13 + set -f index_status (string sub --length 1 $path_status) 14 + set -f working_tree_status (string sub --start 2 --length 1 $path_status) 15 + 16 + set -f diff_opts --color=always 17 + 18 + if test $index_status = '?' 19 + _fzf_report_diff_type Untracked 20 + _fzf_preview_file $path 21 + else if contains {$index_status}$working_tree_status DD AU UD UA DU AA UU 22 + # Unmerged statuses taken directly from git status help's short format table 23 + # Unmerged statuses are mutually exclusive with other statuses, so if we see 24 + # these, then safe to assume the path is unmerged 25 + _fzf_report_diff_type Unmerged 26 + git diff $diff_opts -- $path 27 + else 28 + if test $index_status != ' ' 29 + _fzf_report_diff_type Staged 30 + 31 + # renames are only detected in the index, never working tree, so only need to test for it here 32 + # https://stackoverflow.com/questions/73954214 33 + if test $index_status = R 34 + # diff the post-rename path with the original path, otherwise the diff will show the entire file as being added 35 + set -f orig_and_new_path (string split --max 1 -- ' -> ' $path) 36 + git diff --staged $diff_opts -- $orig_and_new_path[1] $orig_and_new_path[2] 37 + # path currently has the form of "original -> current", so we need to correct it before it's used below 38 + set path $orig_and_new_path[2] 39 + else 40 + git diff --staged $diff_opts -- $path 41 + end 42 + end 43 + 44 + if test $working_tree_status != ' ' 45 + _fzf_report_diff_type Unstaged 46 + git diff $diff_opts -- $path 47 + end 48 + end 49 + end
+43
fish/functions/_fzf_preview_file.fish
··· 1 + # helper function for _fzf_search_directory and _fzf_search_git_status 2 + function _fzf_preview_file --description "Print a preview for the given file based on its file type." 3 + # because there's no way to guarantee that _fzf_search_directory passes the path to _fzf_preview_file 4 + # as one argument, we collect all the arguments into one single variable and treat that as the path 5 + set -f file_path $argv 6 + 7 + if test -L "$file_path" # symlink 8 + # notify user and recurse on the target of the symlink, which can be any of these file types 9 + set -l target_path (realpath "$file_path") 10 + 11 + set_color yellow 12 + echo "'$file_path' is a symlink to '$target_path'." 13 + set_color normal 14 + 15 + _fzf_preview_file "$target_path" 16 + else if test -f "$file_path" # regular file 17 + if set --query fzf_preview_file_cmd 18 + # need to escape quotes to make sure eval receives file_path as a single arg 19 + eval "$fzf_preview_file_cmd '$file_path'" 20 + else 21 + bat --style=numbers --color=always "$file_path" 22 + end 23 + else if test -d "$file_path" # directory 24 + if set --query fzf_preview_dir_cmd 25 + # see above 26 + eval "$fzf_preview_dir_cmd '$file_path'" 27 + else 28 + # -A list hidden files as well, except for . and .. 29 + # -F helps classify files by appending symbols after the file name 30 + command ls -A -F "$file_path" 31 + end 32 + else if test -c "$file_path" 33 + _fzf_report_file_type "$file_path" "character device file" 34 + else if test -b "$file_path" 35 + _fzf_report_file_type "$file_path" "block device file" 36 + else if test -S "$file_path" 37 + _fzf_report_file_type "$file_path" socket 38 + else if test -p "$file_path" 39 + _fzf_report_file_type "$file_path" "named pipe" 40 + else 41 + echo "$file_path doesn't exist." >&2 42 + end 43 + end
+18
fish/functions/_fzf_report_diff_type.fish
··· 1 + # helper for _fzf_preview_changed_file 2 + # prints out something like 3 + # ╭────────╮ 4 + # │ Staged │ 5 + # ╰────────╯ 6 + function _fzf_report_diff_type --argument-names diff_type --description "Print a distinct colored header meant to preface a git patch." 7 + # number of "-" to draw is the length of the string to box + 2 for padding 8 + set -f repeat_count (math 2 + (string length $diff_type)) 9 + set -f line (string repeat --count $repeat_count ─) 10 + set -f top_border ╭$line╮ 11 + set -f btm_border ╰$line╯ 12 + 13 + set_color yellow 14 + echo $top_border 15 + echo "│ $diff_type │" 16 + echo $btm_border 17 + set_color normal 18 + end
+6
fish/functions/_fzf_report_file_type.fish
··· 1 + # helper function for _fzf_preview_file 2 + function _fzf_report_file_type --argument-names file_path file_type --description "Explain the file type for a file." 3 + set_color red 4 + echo "Cannot preview '$file_path': it is a $file_type." 5 + set_color normal 6 + end
+33
fish/functions/_fzf_search_directory.fish
··· 1 + function _fzf_search_directory --description "Search the current directory. Replace the current token with the selected file paths." 2 + # Directly use fd binary to avoid output buffering delay caused by a fd alias, if any. 3 + # Debian-based distros install fd as fdfind and the fd package is something else, so 4 + # check for fdfind first. Fall back to "fd" for a clear error message. 5 + set -f fd_cmd (command -v fdfind || command -v fd || echo "fd") 6 + set -f --append fd_cmd --color=always $fzf_fd_opts 7 + 8 + set -f fzf_arguments --multi --ansi $fzf_directory_opts 9 + set -f token (commandline --current-token) 10 + # expand any variables or leading tilde (~) in the token 11 + set -f expanded_token (eval echo -- $token) 12 + # unescape token because it's already quoted so backslashes will mess up the path 13 + set -f unescaped_exp_token (string unescape -- $expanded_token) 14 + 15 + # If the current token is a directory and has a trailing slash, 16 + # then use it as fd's base directory. 17 + if string match --quiet -- "*/" $unescaped_exp_token && test -d "$unescaped_exp_token" 18 + set --append fd_cmd --base-directory=$unescaped_exp_token 19 + # use the directory name as fzf's prompt to indicate the search is limited to that directory 20 + set --prepend fzf_arguments --prompt="Directory $unescaped_exp_token> " --preview="_fzf_preview_file $expanded_token{}" 21 + set -f file_paths_selected $unescaped_exp_token($fd_cmd 2>/dev/null | _fzf_wrapper $fzf_arguments) 22 + else 23 + set --prepend fzf_arguments --prompt="Directory> " --query="$unescaped_exp_token" --preview='_fzf_preview_file {}' 24 + set -f file_paths_selected ($fd_cmd 2>/dev/null | _fzf_wrapper $fzf_arguments) 25 + end 26 + 27 + 28 + if test $status -eq 0 29 + commandline --current-token --replace -- (string escape -- $file_paths_selected | string join ' ') 30 + end 31 + 32 + commandline --function repaint 33 + end
+36
fish/functions/_fzf_search_git_log.fish
··· 1 + function _fzf_search_git_log --description "Search the output of git log and preview commits. Replace the current token with the selected commit hash." 2 + if not git rev-parse --git-dir >/dev/null 2>&1 3 + echo '_fzf_search_git_log: Not in a git repository.' >&2 4 + else 5 + if not set --query fzf_git_log_format 6 + # %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below 7 + set -f fzf_git_log_format '%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)' 8 + end 9 + 10 + set -f preview_cmd 'git show --color=always --stat --patch {1}' 11 + if set --query fzf_diff_highlighter 12 + set preview_cmd "$preview_cmd | $fzf_diff_highlighter" 13 + end 14 + 15 + set -f selected_log_lines ( 16 + git log --no-show-signature --color=always --format=format:$fzf_git_log_format --date=short | \ 17 + _fzf_wrapper --ansi \ 18 + --multi \ 19 + --scheme=history \ 20 + --prompt="Git Log> " \ 21 + --preview=$preview_cmd \ 22 + --query=(commandline --current-token) \ 23 + $fzf_git_log_opts 24 + ) 25 + if test $status -eq 0 26 + for line in $selected_log_lines 27 + set -f abbreviated_commit_hash (string split --field 1 " " $line) 28 + set -f full_commit_hash (git rev-parse $abbreviated_commit_hash) 29 + set -f --append commit_hashes $full_commit_hash 30 + end 31 + commandline --current-token --replace (string join ' ' $commit_hashes) 32 + end 33 + end 34 + 35 + commandline --function repaint 36 + end
+41
fish/functions/_fzf_search_git_status.fish
··· 1 + function _fzf_search_git_status --description "Search the output of git status. Replace the current token with the selected file paths." 2 + if not git rev-parse --git-dir >/dev/null 2>&1 3 + echo '_fzf_search_git_status: Not in a git repository.' >&2 4 + else 5 + set -f preview_cmd '_fzf_preview_changed_file {}' 6 + if set --query fzf_diff_highlighter 7 + set preview_cmd "$preview_cmd | $fzf_diff_highlighter" 8 + end 9 + 10 + set -f selected_paths ( 11 + # Pass configuration color.status=always to force status to use colors even though output is sent to a pipe 12 + git -c color.status=always status --short | 13 + _fzf_wrapper --ansi \ 14 + --multi \ 15 + --prompt="Git Status> " \ 16 + --query=(commandline --current-token) \ 17 + --preview=$preview_cmd \ 18 + --nth="2.." \ 19 + $fzf_git_status_opts 20 + ) 21 + if test $status -eq 0 22 + # git status --short automatically escapes the paths of most files for us so not going to bother trying to handle 23 + # the few edges cases of weird file names that should be extremely rare (e.g. "this;needs;escaping") 24 + set -f cleaned_paths 25 + 26 + for path in $selected_paths 27 + if test (string sub --length 1 $path) = R 28 + # path has been renamed and looks like "R LICENSE -> LICENSE.md" 29 + # extract the path to use from after the arrow 30 + set --append cleaned_paths (string split -- "-> " $path)[-1] 31 + else 32 + set --append cleaned_paths (string sub --start=4 $path) 33 + end 34 + end 35 + 36 + commandline --current-token --replace -- (string join ' ' $cleaned_paths) 37 + end 38 + end 39 + 40 + commandline --function repaint 41 + end
+39
fish/functions/_fzf_search_history.fish
··· 1 + function _fzf_search_history --description "Search command history. Replace the command line with the selected command." 2 + # history merge incorporates history changes from other fish sessions 3 + # it errors out if called in private mode 4 + if test -z "$fish_private_mode" 5 + builtin history merge 6 + end 7 + 8 + if not set --query fzf_history_time_format 9 + # Reference https://devhints.io/strftime to understand strftime format symbols 10 + set -f fzf_history_time_format "%m-%d %H:%M:%S" 11 + end 12 + 13 + # Delinate time from command in history entries using the vertical box drawing char (U+2502). 14 + # Then, to get raw command from history entries, delete everything up to it. The ? on regex is 15 + # necessary to make regex non-greedy so it won't match into commands containing the char. 16 + set -f time_prefix_regex '^.*? │ ' 17 + # Delinate commands throughout pipeline using null rather than newlines because commands can be multi-line 18 + set -f commands_selected ( 19 + builtin history --null --show-time="$fzf_history_time_format │ " | 20 + _fzf_wrapper --read0 \ 21 + --print0 \ 22 + --multi \ 23 + --scheme=history \ 24 + --prompt="History> " \ 25 + --query=(commandline) \ 26 + --preview="string replace --regex '$time_prefix_regex' '' -- {} | fish_indent --ansi" \ 27 + --preview-window="bottom:3:wrap" \ 28 + $fzf_history_opts | 29 + string split0 | 30 + # remove timestamps from commands selected 31 + string replace --regex $time_prefix_regex '' 32 + ) 33 + 34 + if test $status -eq 0 35 + commandline --replace -- $commands_selected 36 + end 37 + 38 + commandline --function repaint 39 + end
+32
fish/functions/_fzf_search_processes.fish
··· 1 + function _fzf_search_processes --description "Search all running processes. Replace the current token with the pid of the selected process." 2 + # Directly use ps command because it is often aliased to a different command entirely 3 + # or with options that dirty the search results and preview output 4 + set -f ps_cmd (command -v ps || echo "ps") 5 + # use all caps to be consistent with ps default format 6 + # snake_case because ps doesn't seem to allow spaces in the field names 7 + set -f ps_preview_fmt (string join ',' 'pid' 'ppid=PARENT' 'user' '%cpu' 'rss=RSS_IN_KB' 'start=START_TIME' 'command') 8 + set -f processes_selected ( 9 + $ps_cmd -A -opid,command | \ 10 + _fzf_wrapper --multi \ 11 + --prompt="Processes> " \ 12 + --query (commandline --current-token) \ 13 + --ansi \ 14 + # first line outputted by ps is a header, so we need to mark it as so 15 + --header-lines=1 \ 16 + # ps uses exit code 1 if the process was not found, in which case show an message explaining so 17 + --preview="$ps_cmd -o '$ps_preview_fmt' -p {1} || echo 'Cannot preview {1} because it exited.'" \ 18 + --preview-window="bottom:4:wrap" \ 19 + $fzf_processes_opts 20 + ) 21 + 22 + if test $status -eq 0 23 + for process in $processes_selected 24 + set -f --append pids_selected (string split --no-empty --field=1 -- " " $process) 25 + end 26 + 27 + # string join to replace the newlines outputted by string split with spaces 28 + commandline --current-token --replace -- (string join ' ' $pids_selected) 29 + end 30 + 31 + commandline --function repaint 32 + end
+47
fish/functions/_fzf_search_variables.fish
··· 1 + # This function expects the following two arguments: 2 + # argument 1 = output of (set --show | psub), i.e. a file with the scope info and values of all variables 3 + # argument 2 = output of (set --names | psub), i.e. a file with all variable names 4 + function _fzf_search_variables --argument-names set_show_output set_names_output --description "Search and preview shell variables. Replace the current token with the selected variable." 5 + if test -z "$set_names_output" 6 + printf '%s\n' '_fzf_search_variables requires 2 arguments.' >&2 7 + 8 + commandline --function repaint 9 + return 22 # 22 means invalid argument in POSIX 10 + end 11 + 12 + # Exclude the history variable from being piped into fzf because 13 + # 1. it's not included in $set_names_output 14 + # 2. it tends to be a very large value => increases computation time 15 + # 3._fzf_search_history is a much better way to examine history anyway 16 + set -f all_variable_names (string match --invert history <$set_names_output) 17 + 18 + set -f current_token (commandline --current-token) 19 + # Use the current token to pre-populate fzf's query. If the current token begins 20 + # with a $, remove it from the query so that it will better match the variable names 21 + set -f cleaned_curr_token (string replace -- '$' '' $current_token) 22 + 23 + set -f variable_names_selected ( 24 + printf '%s\n' $all_variable_names | 25 + _fzf_wrapper --preview "_fzf_extract_var_info {} $set_show_output" \ 26 + --prompt="Variables> " \ 27 + --preview-window="wrap" \ 28 + --multi \ 29 + --query=$cleaned_curr_token \ 30 + $fzf_variables_opts 31 + ) 32 + 33 + if test $status -eq 0 34 + # If the current token begins with a $, do not overwrite the $ when 35 + # replacing the current token with the selected variable. 36 + # Uses brace expansion to prepend $ to each variable name. 37 + commandline --current-token --replace ( 38 + if string match --quiet -- '$*' $current_token 39 + string join " " \${$variable_names_selected} 40 + else 41 + string join " " $variable_names_selected 42 + end 43 + ) 44 + end 45 + 46 + commandline --function repaint 47 + end
+21
fish/functions/_fzf_wrapper.fish
··· 1 + function _fzf_wrapper --description "Prepares some environment variables before executing fzf." 2 + # Make sure fzf uses fish to execute preview commands, some of which 3 + # are autoloaded fish functions so don't exist in other shells. 4 + # Use --function so that it doesn't clobber SHELL outside this function. 5 + set -f --export SHELL (command --search fish) 6 + 7 + # If neither FZF_DEFAULT_OPTS nor FZF_DEFAULT_OPTS_FILE are set, then set some sane defaults. 8 + # See https://github.com/junegunn/fzf#environment-variables 9 + set --query FZF_DEFAULT_OPTS FZF_DEFAULT_OPTS_FILE 10 + if test $status -eq 2 11 + # cycle allows jumping between the first and last results, making scrolling faster 12 + # layout=reverse lists results top to bottom, mimicking the familiar layouts of git log, history, and env 13 + # border shows where the fzf window begins and ends 14 + # height=90% leaves space to see the current command and some scrollback, maintaining context of work 15 + # preview-window=wrap wraps long lines in the preview window, making reading easier 16 + # marker=* makes the multi-select marker more distinguishable from the pointer (since both default to >) 17 + set --export FZF_DEFAULT_OPTS '--cycle --layout=reverse --border --height=90% --preview-window=wrap --marker="*"' 18 + end 19 + 20 + fzf $argv 21 + end
-4
fish/functions/bat.fish
··· 1 - function bat --wraps=batcat --description 'alias bat=batcat' 2 - batcat $argv 3 - 4 - end
+2 -2
fish/functions/cat.fish
··· 1 - function cat --wraps=batcat --description 'alias cat=batcat' 2 - batcat $argv 1 + function cat --wraps=bat --description 'alias cat=bat' 2 + bat $argv 3 3 4 4 end
+46
fish/functions/fzf_configure_bindings.fish
··· 1 + # Always installs bindings for insert and default mode for simplicity and b/c it has almost no side-effect 2 + # https://gitter.im/fish-shell/fish-shell?at=60a55915ee77a74d685fa6b1 3 + function fzf_configure_bindings --description "Installs the default key bindings for fzf.fish with user overrides passed as options." 4 + # no need to install bindings if not in interactive mode or running tests 5 + status is-interactive || test "$CI" = true; or return 6 + 7 + set -f options_spec h/help 'directory=?' 'git_log=?' 'git_status=?' 'history=?' 'processes=?' 'variables=?' 8 + argparse --max-args=0 --ignore-unknown $options_spec -- $argv 2>/dev/null 9 + if test $status -ne 0 10 + echo "Invalid option or a positional argument was provided." >&2 11 + _fzf_configure_bindings_help 12 + return 22 13 + else if set --query _flag_help 14 + _fzf_configure_bindings_help 15 + return 16 + else 17 + # Initialize with default key sequences and then override or disable them based on flags 18 + # index 1 = directory, 2 = git_log, 3 = git_status, 4 = history, 5 = processes, 6 = variables 19 + set -f key_sequences \e\cf \e\cl \e\cs \cr \e\cp \cv # \c = control, \e = escape 20 + set --query _flag_directory && set key_sequences[1] "$_flag_directory" 21 + set --query _flag_git_log && set key_sequences[2] "$_flag_git_log" 22 + set --query _flag_git_status && set key_sequences[3] "$_flag_git_status" 23 + set --query _flag_history && set key_sequences[4] "$_flag_history" 24 + set --query _flag_processes && set key_sequences[5] "$_flag_processes" 25 + set --query _flag_variables && set key_sequences[6] "$_flag_variables" 26 + 27 + # If fzf bindings already exists, uninstall it first for a clean slate 28 + if functions --query _fzf_uninstall_bindings 29 + _fzf_uninstall_bindings 30 + end 31 + 32 + for mode in default insert 33 + test -n $key_sequences[1] && bind --mode $mode $key_sequences[1] _fzf_search_directory 34 + test -n $key_sequences[2] && bind --mode $mode $key_sequences[2] _fzf_search_git_log 35 + test -n $key_sequences[3] && bind --mode $mode $key_sequences[3] _fzf_search_git_status 36 + test -n $key_sequences[4] && bind --mode $mode $key_sequences[4] _fzf_search_history 37 + test -n $key_sequences[5] && bind --mode $mode $key_sequences[5] _fzf_search_processes 38 + test -n $key_sequences[6] && bind --mode $mode $key_sequences[6] "$_fzf_search_vars_command" 39 + end 40 + 41 + function _fzf_uninstall_bindings --inherit-variable key_sequences 42 + bind --erase -- $key_sequences 43 + bind --erase --mode insert -- $key_sequences 44 + end 45 + end 46 + end
+4
fish/functions/mosh.fish
··· 1 + function mosh --wraps='TERM=xterm-256color /usr/bin/mosh' --description 'alias mosh=TERM=xterm-256color /usr/bin/mosh' 2 + TERM=xterm-256color /usr/bin/mosh $argv 3 + 4 + end
+4
fish/functions/ssh.fish
··· 1 + function ssh --wraps='TERM=xterm-256color /usr/bin/ssh' --description 'alias ssh=TERM=xterm-256color /usr/bin/ssh' 2 + TERM=xterm-256color /usr/bin/ssh $argv 3 + 4 + end
+4
fish/functions/vim.fish
··· 1 + function vim --wraps=nvim --description 'alias vim=nvim' 2 + nvim $argv 3 + 4 + end