dotfiles/modules/programs/fish.nix

83 lines
2.4 KiB
Nix
Raw Normal View History

2022-07-15 13:11:54 +02:00
{ config
, lib
, pkgs
, inputs
, ...
}:
2022-03-22 19:33:01 +01:00
2022-07-15 13:11:54 +02:00
with lib;
2022-03-22 19:33:01 +01:00
let
2022-07-15 13:11:54 +02:00
cfg = config.my.programs.fish;
shellConfig = config.my.shell;
exportVariables =
lib.mapAttrsToList (n: v: ''set -x ${n} "${v}"'') shellConfig.variables;
exportedVariables = lib.concatStringsSep "\n" exportVariables;
in
{
2022-10-15 20:00:09 +02:00
options.my.programs.fish.enable = mkEnableOption "fish";
2022-07-15 13:11:54 +02:00
config = lib.mkIf cfg.enable {
2022-03-22 19:33:01 +01:00
# set as default shell
users.users.moritz.shell = pkgs.fish;
2022-10-06 20:32:21 +02:00
environment.systemPackages = with pkgs.fishPlugins; [ fzf-fish pisces ];
2022-03-22 19:33:01 +01:00
# needed for nix completions
programs.fish.enable = true;
2022-07-15 13:11:54 +02:00
2022-03-22 19:33:01 +01:00
home-manager.users.moritz = {
programs = {
fish = {
enable = true;
2022-07-15 13:11:54 +02:00
shellAbbrs = shellConfig.abbreviations;
2022-03-22 19:33:01 +01:00
2022-07-15 13:11:54 +02:00
shellAliases = shellConfig.aliases;
2022-03-22 19:33:01 +01:00
shellInit = ''
fzf_configure_bindings --git_log=\cg
# Vi Mode
fish_vi_key_bindings
# Emulates vim's cursor shape behavior
# Set the normal and visual mode cursors to a block
set fish_cursor_default block
# Set the insert mode cursor to a line
set fish_cursor_insert line
# Set the replace mode cursor to an underscore
set fish_cursor_replace_one underscore
# The following variable can be used to configure cursor shape in
# visual mode, but due to fish_cursor_default, is redundant here
set fish_cursor_visual block
# Variables
${exportedVariables}
'';
functions = {
2022-08-20 14:22:20 +02:00
gi = with pkgs; ''
2022-03-22 19:33:01 +01:00
set url https://www.gitignore.io/api
2022-08-20 14:22:20 +02:00
if test (count $argv) -eq 0
set choice ( curl -sL $url/list \
| string split "," \
| ${fzf}/bin/fzf -m \
| string join "," )
else
set choice (string join "," $argv[1..])
end
if ${gum}/bin/gum confirm "Overwrite current .gitignore?"
${curl}/bin/curl -sL $url/$choice > .gitignore
2022-03-22 19:33:01 +01:00
else
2022-08-20 14:22:20 +02:00
${curl}/bin/curl -sL $url/$choice >> .gitignore
2022-03-22 19:33:01 +01:00
end
'';
fish_greeting = "";
cheat = "cht.sh $argv | bat -p";
};
};
fzf.enableFishIntegration = true;
starship.enableFishIntegration = true;
};
};
};
}