Inside $HOME/.config/fish/config.fish
:
function multicd
echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../)
end
abbr --add dotdot --regex '^\.\.+$' --function multicd
function last_history_item; echo $history[1]; end
abbr -a !! --position anywhere --function last_history_item
function __pick_file
fd --type f | fzf
end
abbr -a !f --position anywhere --function __pick_file
function __pick_dir
fd --type d | fzf
end
abbr -a !d --position anywhere --function __pick_dir
function __pick_grep
set RG_PREFIX "rg --column --line-number --no-heading --color=always --smart-case"
true | fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q}" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3' \
| tr ':' '\n' | head -n1
end
abbr -a !g --position anywhere --function __pick_grep
To use type ...<space>
, !!<space>
, !f<space>
, !g<space>
, !d<space>
, anywhere in your shell.