Skip to content

Instantly share code, notes, and snippets.

@dfrommi
Last active October 18, 2020 12:19
Show Gist options
  • Select an option

  • Save dfrommi/453f4e2c6635d2965802ac84b88519f5 to your computer and use it in GitHub Desktop.

Select an option

Save dfrommi/453f4e2c6635d2965802ac84b88519f5 to your computer and use it in GitHub Desktop.
Modular Fish-Shell Configuration #fish #config

Modular Fish-Shell Configuration

Fish shell configuration is split into functions, completions and initalization code. But it's easy to split it further on a per feature basis.

The default fish configuration structure looks something like this:

~/.config/fish/
  - functions/
  - completions/
  - conf.d/

This structure is repeated per feature, what I call krill.

~/.config/fish/
  - functions/
  - completions/
  - conf.d/
  - krill
    - git_tools
      - functions/
      - completions/
      - conf.d/
    - touchbar
      - functions/
      - conf.d/

To inform fish about the additional directories, the following code has to be executed on startup, for example by putting it in the file ~/.config/fish/conf.d/_krill.fish:

set krill_path $HOME/.config/fish/krill

set fish_function_path (find $krill_path -depth 2 -type d -name functions) $fish_function_path
set fish_complete_path (find $krill_path -depth 2 -type d -name completions) $fish_complete_path

for file in (find $krill_path -path "*/conf.d/*.fish" -depth 3 -type f)
    builtin source $file 2> /dev/null
end

And that's it. Now the additional functions, completions and initialization code is known to fish and can be used.

set krill_path $HOME/.config/fish/krill
set fish_function_path (find $krill_path -depth 2 -type d -name functions) $fish_function_path
set fish_complete_path (find $krill_path -depth 2 -type d -name completions) $fish_complete_path
for file in (find $krill_path -path "*/conf.d/*.fish" -depth 3 -type f)
builtin source $file 2> /dev/null
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment