[fish] big change
This commit is contained in:
parent
7dac57412d
commit
578c6b3208
5 changed files with 107 additions and 16 deletions
|
@ -1,5 +1,3 @@
|
|||
# Credits to https://github.com/BrewingWeasel/fishbang
|
||||
|
||||
function last_history_item
|
||||
echo $history[1]
|
||||
end
|
||||
|
@ -57,7 +55,3 @@ abbr -a !^ --position anywhere --function first_history_arg # !^ returns the fir
|
|||
abbr -a !\$ --position anywhere --function last_history_arg # !$ returns the last argument of the last command
|
||||
abbr -a !\* --position anywhere --function history_args # !* returns all arguments of the last command
|
||||
abbr -a bang_nth_arg --position anywhere --regex '!:([0-9]*)' --function nth_history_arg # !$ returns the last argument of the last command
|
||||
|
||||
bind -M insert enter expand-abbr execute
|
||||
bind -M default enter expand-abbr execute
|
||||
bind enter expand-abbr execute
|
||||
|
|
|
@ -5,9 +5,7 @@ end
|
|||
|
||||
set -g fish_greeting
|
||||
fish_vi_key_bindings
|
||||
bind -M insert \t complete-and-search
|
||||
bind -M insert --key btab complete
|
||||
|
||||
bind -M insert \t "__fzf_complete"
|
||||
|
||||
# XDG directories
|
||||
set -x XDG_CONFIG_HOME "$HOME/.config"
|
||||
|
@ -35,6 +33,7 @@ end
|
|||
# Common paths
|
||||
fish_add_path /usr/sbin
|
||||
fish_add_path /sbin
|
||||
fish_add_path $HOME/opt/*/bin
|
||||
fish_add_path $HOME/.local/share/nvim/mason/bin
|
||||
fish_add_path $HOME/.local/bin
|
||||
fish_add_path $HOME/go/bin
|
||||
|
@ -46,7 +45,6 @@ if test (uname) = "Darwin"
|
|||
eval (/opt/homebrew/bin/brew shellenv)
|
||||
end
|
||||
|
||||
# Set up fzf
|
||||
set -U FZF_DEFAULT_OPTS "--bind 'bs:backward-delete-char/eof'"
|
||||
fzf --fish | source
|
||||
|
||||
# Added by LM Studio CLI (lms)
|
||||
set -gx PATH $PATH /Users/afonso/.lmstudio/bin
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
# This file contains fish universal variable definitions.
|
||||
# VERSION: 3.0
|
||||
SETUVAR FZF_CTRL_R_OPTS:\x2d\x2dreverse
|
||||
SETUVAR FZF_TMUX_OPTS:\x2dp
|
||||
SETUVAR __fish_initialized:3400
|
||||
SETUVAR FZF_COMPLETE:2
|
||||
SETUVAR FZF_DEFAULT_OPTS:\x2d\x2dbind\x20\x27bs\x3abackward\x2ddelete\x2dchar/eof\x27
|
||||
SETUVAR __fish_initialized:3800
|
||||
SETUVAR _fisher_brewingweasel_2F_fishbang_files:\x7e/\x2econfig/fish/conf\x2ed/fishbang\x2efish
|
||||
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
|
||||
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ebrewingweasel/fishbang
|
||||
SETUVAR _fisher_upgraded_to_4_4:\x1d
|
||||
SETUVAR fifc_keybinding:\x09
|
||||
SETUVAR fifc_open_keybinding:ctrl\x2do
|
||||
SETUVAR fish_color_autosuggestion:brblack
|
||||
SETUVAR fish_color_cancel:\x2dr
|
||||
SETUVAR fish_color_command:blue
|
||||
|
@ -25,10 +31,11 @@ SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrbl
|
|||
SETUVAR fish_color_status:red
|
||||
SETUVAR fish_color_user:brgreen
|
||||
SETUVAR fish_color_valid_path:\x2d\x2dunderline
|
||||
SETUVAR fish_complete_path:vertical\x1e/opt/homebrew/Cellar/fish/3\x2e7\x2e1/share/fish/completions\x1e/opt/homebrew/Cellar/fish/4\x2e0\x2e1/share/fish/completions
|
||||
SETUVAR fish_key_bindings:fish_vi_key_bindings
|
||||
SETUVAR fish_pager_color_completion:normal
|
||||
SETUVAR fish_pager_color_description:yellow\x1e\x2di
|
||||
SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
|
||||
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
||||
SETUVAR fish_pager_color_selected_background:\x2dr
|
||||
SETUVAR fish_user_paths:/Users/afonso/\x2eghcup/bin\x1e/Users/afonso/\x2ecargo/bin\x1e/Users/afonso/go/bin\x1e/Users/afonso/\x2elocal/bin\x1e/Users/afonso/\x2elocal/share/nvim/mason/bin\x1e/sbin\x1e/usr/sbin\x1e/Users/afonso/\x2egem/bin\x1e/opt/homebrew/opt/texlive/bin\x1e/opt/homebrew/bin
|
||||
SETUVAR fish_user_paths:/Users/afonso/opt/fish/bin\x1e/Users/afonso/opt/neovim/bin\x1e/Users/afonso/\x2eghcup/bin\x1e/Users/afonso/\x2ecargo/bin\x1e/Users/afonso/go/bin\x1e/Users/afonso/\x2elocal/bin\x1e/Users/afonso/\x2elocal/share/nvim/mason/bin\x1e/sbin\x1e/usr/sbin\x1e/Users/afonso/\x2egem/bin\x1e/opt/homebrew/opt/texlive/bin\x1e/opt/homebrew/bin
|
||||
|
|
92
.config/fish/functions/__fzf_complete.fish
Normal file
92
.config/fish/functions/__fzf_complete.fish
Normal file
|
@ -0,0 +1,92 @@
|
|||
function __fzf_complete -d 'fzf completion and print selection back to commandline'
|
||||
# As of 2.6, fish's "complete" function does not understand
|
||||
# subcommands. Instead, we use the same hack as __fish_complete_subcommand and
|
||||
# extract the subcommand manually.
|
||||
set -l cmd (commandline -co) (commandline -ct)
|
||||
|
||||
switch $cmd[1]
|
||||
case env sudo
|
||||
for i in (seq 2 (count $cmd))
|
||||
switch $cmd[$i]
|
||||
case '-*'
|
||||
case '*=*'
|
||||
case '*'
|
||||
set cmd $cmd[$i..-1]
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set -l cmd_lastw $cmd[-1]
|
||||
set cmd (string join -- ' ' $cmd)
|
||||
|
||||
set -l initial_query ''
|
||||
test -n "$cmd_lastw"; and set initial_query --query="$cmd_lastw"
|
||||
|
||||
set -l complist (complete -C$cmd)
|
||||
set -l result
|
||||
|
||||
# do nothing if there is nothing to select from
|
||||
test -z "$complist"; and return
|
||||
|
||||
set -l compwc (echo $complist | wc -w)
|
||||
if test $compwc -eq 1
|
||||
# if there is only one option dont open fzf
|
||||
set result "$complist"
|
||||
else
|
||||
|
||||
set -l query
|
||||
string join -- \n $complist \
|
||||
| eval fzf --height=90% (string escape --no-quoted -- $initial_query) --print-query (__fzf_complete_opts) \
|
||||
| cut -f1 \
|
||||
| while read -l r
|
||||
# first line is the user entered query
|
||||
if test -z "$query"
|
||||
set query $r
|
||||
# rest of lines are selected candidates
|
||||
else
|
||||
set result $result $r
|
||||
end
|
||||
end
|
||||
|
||||
# exit if user canceled
|
||||
if test -z "$query" ;and test -z "$result"
|
||||
commandline -f repaint
|
||||
return
|
||||
end
|
||||
|
||||
# if user accepted but no candidate matches, use the input as result
|
||||
if test -z "$result"
|
||||
set result $query
|
||||
end
|
||||
end
|
||||
|
||||
set prefix (string sub -s 1 -l 1 -- (commandline -t))
|
||||
for i in (seq (count $result))
|
||||
set -l r $result[$i]
|
||||
switch $prefix
|
||||
case "'"
|
||||
commandline -t -- (string escape -- $r)
|
||||
case '"'
|
||||
if string match '*"*' -- $r >/dev/null
|
||||
commandline -t -- (string escape -- $r)
|
||||
else
|
||||
commandline -t -- '"'$r'"'
|
||||
end
|
||||
case '~'
|
||||
commandline -t -- (string sub -s 2 (string escape -n -- $r))
|
||||
case '*'
|
||||
commandline -t -- $r
|
||||
end
|
||||
[ $i -lt (count $result) ]; and commandline -i ' '
|
||||
end
|
||||
|
||||
commandline -f repaint
|
||||
end
|
||||
|
||||
function __fzf_complete_opts
|
||||
if set -q FZF_DEFAULT_OPTS
|
||||
echo $FZF_DEFAULT_OPTS
|
||||
end
|
||||
echo --cycle --reverse --inline-info --no-multi --bind tab:down,btab:up
|
||||
end
|
Loading…
Add table
Reference in a new issue