Files
dotfiles/home/dot_config/fish/config.fish.tmpl

87 lines
2.6 KiB
Cheetah

# Fish shell configuration
# Managed by chezmoi
# Disable greeting
set -g fish_greeting
# Display reminder banner for interactive shells
if status is-interactive
{{ template "scripts/reminder-banner.tmpl" dict "shell" "fish" }}
end
{{- if .wsl }}
if status is-login
and status is-interactive
keychain --quiet --agents ssh --eval ~/.ssh/id_rsa | source
end
{{- end }}
# Enable EXA for OpenCode
set -gx OPENCODE_ENABLE_EXA true
# Common shared configuration (environment variables, PATH, tool setup)
{{ template "scripts/commonrc.fish.tmpl" dict "data" . }}
# Chezmoi shell completion
{{ completion "fish" }}
# VS Code / Cursor shell integration
if test "$TERM_PROGRAM" = "vscode"
if command -q code
string replace -r '^' '' (code --locate-shell-integration-path fish) | source
else if command -q cursor
string replace -r '^' '' (cursor --locate-shell-integration-path fish) | source
end
end
# fzf.fish configuration (PatrickF1/fzf.fish via Fisher)
if functions -q fzf_configure_bindings
# Remap CTRL+V (variables) to Alt+Ctrl+V to avoid paste conflict
# Disable history (--history=) to let Atuin keep CTRL+R
fzf_configure_bindings --variables=\e\cv --history=
# Always include hidden files (dotfiles) in searches
set -g fzf_fd_opts --hidden
# Directory search: Ctrl+I toggles gitignored files
set -g fzf_directory_opts \
--header 'C-i: toggle ignored' \
--bind 'ctrl-i:reload(fd --type f --hidden --no-ignore)+change-prompt(+ignored > )'
end
# Load custom functions from ~/.config/fish/functions/
# (Fish does this automatically, no explicit sourcing needed)
# Custom keybindings
if functions -q fzf_search_abbr
bind \ea fzf_search_abbr # Alt+A: Search abbreviations/aliases
bind -M insert \ea fzf_search_abbr # Also bind in insert mode
end
# Alt+C: Replace line with 'cd <last-arg>' (useful after mkdir)
bind \ec fish_cd_last_arg
bind -M insert \ec fish_cd_last_arg
# Alt+D: Discover directories with fd+fzf (from git root or cwd)
bind \ed _fzf_discover_directory
bind -M insert \ed _fzf_discover_directory
# Alt+Shift+D: Discover directories from HOME with fd+fzf
bind \eD _fzf_discover_home
bind -M insert \eD _fzf_discover_home
# Load abbreviations
if test -f ~/.config/fish/conf.d/abbr.fish
source ~/.config/fish/conf.d/abbr.fish
end
# Initialize zoxide eagerly for cd tracking
if command -q zoxide
zoxide init fish | source
# Alias cd to use zoxide (keeps muscle memory, gets smart navigation)
function cd --description "zoxide-powered smart cd"
__zoxide_z $argv
end
end