marleyos/modules/home/programs/fish/default.nix

133 lines
2.7 KiB
Nix
Raw Normal View History

2024-11-16 11:27:44 -08:00
{
lib,
config,
pkgs,
...
}:
let
inherit (lib) mkEnableOption mkIf;
inherit (lib.marleyos) enabled;
2024-11-16 11:27:44 -08:00
cfg = config.marleyos.programs.fish;
inherit (config.marleyos.theme) colors;
2024-11-16 11:27:44 -08:00
in
{
options.marleyos.programs.fish.enable = mkEnableOption "fish";
2024-11-16 11:27:44 -08:00
config = mkIf cfg.enable {
home.packages = with pkgs; [
# general
babelfish
# for extract()
gnutar
bzip2
bzip3
gzip
unzip
pax
unrar-free
];
2024-11-16 21:33:38 -08:00
# TODO: Set the greeting to `figlet -f Elite marleyOS`
2024-11-16 11:27:44 -08:00
programs.fish = {
enable = true;
2024-11-16 22:44:45 -08:00
rose-pine = mkIf colors.isRosePine enabled;
2024-11-16 11:27:44 -08:00
preferAbbrs = true;
plugins = with pkgs.fishPlugins; [
{
name = "z";
src = z;
}
{
name = "Puffer Fish";
src = puffer;
}
{
name = "Sponge";
src = sponge;
}
{
name = "autopair.fish";
src = autopair;
}
];
shellInit = # fish
''
set -g fish_key_bindings fish_vi_key_bindings
'';
shellAbbrs = {
cp = "cp -iv";
mkdir = "mkdir -pv";
mv = "mv -iv";
rm = "rm -r";
grep = "grep --color=auto";
};
functions = {
extract = {
argumentNames = "file";
body = # fish
''
set --erase argv[1]
if test -f "$file"
switch "$file"
case "*.tar.bz2"
tar -jxvf $argv $file
case "*.tar.gz"
tar -zxvf $argv $file
case "*.bz2"
bunzip2 $argv $file
case "*.bz3"
bunzip3 $argv $file
case "*.gz"
gunzip $argv $file
case "*.tar"
tar -xvf $argv $file
case "*.tbz2"
tar -jxvf $argv $file
case "*.tgz"
tar -zxvf $argv $file
case "*.zip" "*.ZIP"
unzip $argv $file
case "*pax"
cat $file | pax -r $argv
case "*.pax.Z"
uncompress $file --stdout | pax -r $argv
case "*.rar"
unrar-free $file
case "*.Z"
uncompress $argv $file
case "*"
echo "'$file' cannot be extracted via extract()."
end
else
echo "'$file' is not a valid file."
end
'';
};
};
};
};
}