Update
This commit is contained in:
parent
8583c61d95
commit
081dc5ccc1
@ -1,14 +1,63 @@
|
||||
set -q FZF_TMUX_HEIGHT; or set -U FZF_TMUX_HEIGHT "40%"
|
||||
set -q FZF_DEFAULT_OPTS; or set -U FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT"
|
||||
set -q FZF_LEGACY_KEYBINDINGS; or set -U FZF_LEGACY_KEYBINDINGS 1
|
||||
set -q FZF_DISABLE_KEYBINDINGS; or set -U FZF_DISABLE_KEYBINDINGS 0
|
||||
set -q FZF_PREVIEW_FILE_CMD; or set -U FZF_PREVIEW_FILE_CMD "head -n 10"
|
||||
set -q FZF_PREVIEW_DIR_CMD; or set -U FZF_PREVIEW_DIR_CMD "ls"
|
||||
|
||||
function fzf_uninstall -e fzf_uninstall
|
||||
# disabled until we figure out a sensible way to ensure user overrides
|
||||
# are not erased
|
||||
# set -l _vars (set | command grep -E "^FZF.*\$" | command awk '{print $1;}')
|
||||
# for var in $_vars
|
||||
# eval (set -e $var)
|
||||
# end
|
||||
if test "$FZF_DISABLE_KEYBINDINGS" -ne 1
|
||||
if test "$FZF_LEGACY_KEYBINDINGS" -eq 1
|
||||
bind \ct '__fzf_find_file'
|
||||
bind \cr '__fzf_reverse_isearch'
|
||||
bind \ec '__fzf_cd'
|
||||
bind \eC '__fzf_cd --hidden'
|
||||
bind \cg '__fzf_open'
|
||||
bind \co '__fzf_open --editor'
|
||||
|
||||
if ! test "$fish_key_bindings" = fish_default_key_bindings
|
||||
bind -M insert \ct '__fzf_find_file'
|
||||
bind -M insert \cr '__fzf_reverse_isearch'
|
||||
bind -M insert \ec '__fzf_cd'
|
||||
bind -M insert \eC '__fzf_cd --hidden'
|
||||
bind -M insert \cg '__fzf_open'
|
||||
bind -M insert \co '__fzf_open --editor'
|
||||
end
|
||||
else
|
||||
bind \co '__fzf_find_file'
|
||||
bind \cr '__fzf_reverse_isearch'
|
||||
bind \ec '__fzf_cd'
|
||||
bind \eC '__fzf_cd --hidden'
|
||||
bind \eO '__fzf_open'
|
||||
bind \eo '__fzf_open --editor'
|
||||
|
||||
if ! test "$fish_key_bindings" = fish_default_key_bindings
|
||||
bind -M insert \co '__fzf_find_file'
|
||||
bind -M insert \cr '__fzf_reverse_isearch'
|
||||
bind -M insert \ec '__fzf_cd'
|
||||
bind -M insert \eC '__fzf_cd --hidden'
|
||||
bind -M insert \eO '__fzf_open'
|
||||
bind -M insert \eo '__fzf_open --editor'
|
||||
end
|
||||
end
|
||||
|
||||
if not bind --user \t >/dev/null 2>/dev/null
|
||||
if set -q FZF_COMPLETE
|
||||
bind \t '__fzf_complete'
|
||||
if ! test "$fish_key_bindings" = fish_default_key_bindings
|
||||
bind -M insert \t '__fzf_complete'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function _fzf_uninstall -e fzf_uninstall
|
||||
bind --user \
|
||||
| string replace --filter --regex -- "bind (.+)( '?__fzf.*)" 'bind -e $1' \
|
||||
| source
|
||||
|
||||
set --names \
|
||||
| string replace --filter --regex '(^FZF)' 'set --erase $1' \
|
||||
| source
|
||||
|
||||
functions --erase _fzf_uninstall
|
||||
end
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
rbenv/fish-rbenv
|
||||
jethrokuan/fzf
|
||||
jorgebucaran/fish-spark
|
||||
|
||||
@ -58,7 +58,6 @@ function __fzf_complete -d 'fzf completion and print selection back to commandli
|
||||
|
||||
set -l query
|
||||
string join -- \n $complist \
|
||||
| sort \
|
||||
| eval (__fzfcmd) (string escape --no-quoted -- $initial_query) --print-query (__fzf_complete_opts) \
|
||||
| cut -f1 \
|
||||
| while read -l r
|
||||
|
||||
@ -2,12 +2,12 @@ function __fzf_get_dir -d 'Find the longest existing filepath from input string'
|
||||
set dir $argv
|
||||
|
||||
# Strip all trailing slashes. Ignore if $dir is root dir (/)
|
||||
if [ (string length $dir) -gt 1 ]
|
||||
if test (string length $dir) -gt 1
|
||||
set dir (string replace -r '/*$' '' $dir)
|
||||
end
|
||||
|
||||
# Iteratively check if dir exists and strip tail end of path
|
||||
while [ ! -d "$dir" ]
|
||||
while test ! -d "$dir"
|
||||
# If path is absolute, this can keep going until ends up at /
|
||||
# If path is relative, this can keep going until entire input is consumed, dirname returns "."
|
||||
set dir (dirname "$dir")
|
||||
|
||||
@ -39,7 +39,7 @@ function __fzf_open -d "Open files and directories."
|
||||
-o -type d -print \
|
||||
-o -type l -print 2> /dev/null | sed 's@^\./@@'"
|
||||
|
||||
eval "$FZF_OPEN_COMMAND | "(__fzfcmd) $preview_cmd "-m $FZF_DEFAULT_OPTS $FZF_OPEN_OPTS --query \"$fzf_query\"" | read -l select
|
||||
set -l select (eval "$FZF_OPEN_COMMAND | "(__fzfcmd) $preview_cmd "-m $FZF_DEFAULT_OPTS $FZF_OPEN_OPTS --query \"$fzf_query\"" | string escape)
|
||||
|
||||
# set how to open
|
||||
set -l open_cmd
|
||||
@ -54,7 +54,7 @@ function __fzf_open -d "Open files and directories."
|
||||
|
||||
set -l open_status 0
|
||||
if not test -z "$select"
|
||||
commandline "$open_cmd \"$select\"" ;and commandline -f execute
|
||||
commandline "$open_cmd $select"; and commandline -f execute
|
||||
set open_status $status
|
||||
end
|
||||
|
||||
|
||||
@ -2,14 +2,14 @@ function __fzf_parse_commandline -d 'Parse the current command line token and re
|
||||
# eval is used to do shell expansion on paths
|
||||
set -l commandline (eval "printf '%s' "(commandline -t))
|
||||
|
||||
if [ -z $commandline ]
|
||||
if test -z $commandline
|
||||
# Default to current directory with no --query
|
||||
set dir '.'
|
||||
set fzf_query ''
|
||||
else
|
||||
set dir (__fzf_get_dir $commandline)
|
||||
|
||||
if [ "$dir" = "." -a (string sub -l 1 $commandline) != '.' ]
|
||||
if test "$dir" = "." -a (string sub -l 1 $commandline) != '.'
|
||||
# if $dir is "." but commandline is not a relative path, this means no file path found
|
||||
set fzf_query $commandline
|
||||
else
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
function __fzf_reverse_isearch
|
||||
history merge
|
||||
history -z | eval (__fzfcmd) --read0 --tiebreak=index --toggle-sort=ctrl-r $FZF_DEFAULT_OPTS $FZF_REVERSE_ISEARCH_OPTS -q '(commandline)' | perl -pe 'chomp if eof' | read -lz result
|
||||
history -z | eval (__fzfcmd) --read0 --print0 --tiebreak=index --toggle-sort=ctrl-r $FZF_DEFAULT_OPTS $FZF_REVERSE_ISEARCH_OPTS -q '(commandline)' | read -lz result
|
||||
and commandline -- $result
|
||||
commandline -f repaint
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
function __fzfcmd
|
||||
set -q FZF_TMUX; or set FZF_TMUX 0
|
||||
set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%
|
||||
if [ $FZF_TMUX -eq 1 ]
|
||||
if test $FZF_TMUX -eq 1
|
||||
echo "fzf-tmux -d$FZF_TMUX_HEIGHT"
|
||||
else
|
||||
echo "fzf"
|
||||
|
||||
0
local/bin/.keep
Normal file
0
local/bin/.keep
Normal file
0
ruby/bin/.keep
Normal file
0
ruby/bin/.keep
Normal file
Loading…
Reference in New Issue
Block a user