How to properly setup Fish and version the configuration?

Viewed 143

I'm switching to fish from zsh and I'm struggling to find the correct way to it setup for my taste. Also adding that I want to add it to my dotfiles repository. Should I version the whole ~/.config/fish folder?

Where should I put my environment variables? Should I just add them to the fish_variables config file? I was thinking on sourcing a file ~/variables.fish for the ones I don't want to version. Is this a good idea?

I use exa and ripgrep and I like to override grep and ls with them. Can I just set aliases for them overriding like I would with zsh/bash?

I want to use it inside neovim as well and I'm using the vi keybindings. Will this conflict with neovim? If so is there a way to make the vi keybindings active only outside of neovim?

It seems most of the stuff I use is provided by vanilla fish without plugins (which I'm quite happy about). Is there any tips or must have plugins I should install?

1 Answers

I have my ~/.config/fish in git, works well. I share my config over several machines, and to have host-specific settings and functions, I do this:

# machine-specific
set host_config ~/.config/fish/config.(hostname).fish
test -r $host_config; and source $host_config
set -e host_config

set host_funcdir ~/.config/fish/functions_(hostname)
test -d $host_funcdir; and set fish_function_path $host_funcdir $fish_function_path
set -e host_funcdir

I'm not a fan of universal variables. Contrary to the fish philosophy, I like configuration. I store global variables in the config.fish file.

fish aliases create functions behind the scenes, so I do that upfront. This is my ~/.config/fish/functions/ls.fish

function ls --wraps=exa
  exa --classify $argv
end

Using --wraps is helpful to tab-complete exa options while you're typing a ls command.

I don't know about neovim/fish integration.

I have oh-my-fish installed, but only for fish-logo

Related