# ____ ____ # / __/___ / __/ # / /_/_ / / /_ # / __/ / /_/ __/ # /_/ /___/_/ key-bindings.fish # # - $FZF_TMUX_OPTS # - $FZF_CTRL_T_COMMAND # - $FZF_CTRL_T_OPTS # - $FZF_CTRL_R_OPTS # - $FZF_ALT_C_COMMAND # - $FZF_ALT_C_OPTS # Key bindings # ------------ # For compatibility with fish versions down to 3.1.2, the script does not use: # - The -f/--function switch of command: set # - The process substitution syntax: $(cmd) # - Ranges that omit start/end indexes: $var[$start..] $var[..$end] $var[..] function fzf_key_bindings function __fzf_defaults # $argv[1]: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS # $argv[2..]: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS test -n "$FZF_TMUX_HEIGHT"; or set -l FZF_TMUX_HEIGHT 40% string join ' ' -- \ "--height $FZF_TMUX_HEIGHT --min-height=20+ --bind=ctrl-z:ignore" $argv[1] \ (test -r "$FZF_DEFAULT_OPTS_FILE"; and string join -- ' ' <$FZF_DEFAULT_OPTS_FILE) \ $FZF_DEFAULT_OPTS $argv[2..-1] end function __fzfcmd test -n "$FZF_TMUX_HEIGHT"; or set -l FZF_TMUX_HEIGHT 40% if test -n "$FZF_TMUX_OPTS" echo "fzf-tmux $FZF_TMUX_OPTS -- " else if test "$FZF_TMUX" = "1" echo "fzf-tmux -d$FZF_TMUX_HEIGHT -- " else echo "fzf" end end function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath, fzf query, and optional -option= prefix' set -l dir '.' set -l query set -l commandline (commandline -t | string unescape -n) # Strip -option= from token if present set -l prefix (string match -r -- '^-[^\s=]+=' $commandline) set commandline (string replace -- "$prefix" '' $commandline) # Enable home directory expansion of leading ~/ set commandline (string replace -r -- '^~/' '\$HOME/' $commandline) # Escape special characters, except for the $ sign of valid variable names, # so that the original string with expanded variables is returned after eval. set commandline (string escape -n -- $commandline) set commandline (string replace -r -a -- '\\\\\$(?=[\w])' '\$' $commandline) # eval is used to do shell expansion on paths eval set commandline $commandline # Combine multiple consecutive slashes into one. set commandline (string replace -r -a -- '/+' '/' $commandline) if test -n "$commandline" # Strip trailing slash, unless $dir is root dir (/) set dir (string replace -r -- '(?