From 6f456ceef83696b5fec6e47c2154b5591b73c6ca Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 16 Nov 2024 11:27:44 -0800 Subject: [PATCH] feat(home): Fish shell & neo --- homes/x86_64-linux/marley@nyx/default.nix | 4 + modules/home/programs/fish/default.nix | 131 ++++++++++++++++++++++ modules/home/programs/neo/default.nix | 32 ++++++ old/home/programs/fish.nix | 125 --------------------- 4 files changed, 167 insertions(+), 125 deletions(-) create mode 100644 modules/home/programs/fish/default.nix create mode 100644 modules/home/programs/neo/default.nix delete mode 100644 old/home/programs/fish.nix diff --git a/homes/x86_64-linux/marley@nyx/default.nix b/homes/x86_64-linux/marley@nyx/default.nix index aee072d..c6e3ef7 100644 --- a/homes/x86_64-linux/marley@nyx/default.nix +++ b/homes/x86_64-linux/marley@nyx/default.nix @@ -11,6 +11,10 @@ in gtk = enabled; qt = enabled; }; + programs = { + fish = enabled; + neo = enabled; + }; xorg = { xsession = enabled; }; diff --git a/modules/home/programs/fish/default.nix b/modules/home/programs/fish/default.nix new file mode 100644 index 0000000..f34b77b --- /dev/null +++ b/modules/home/programs/fish/default.nix @@ -0,0 +1,131 @@ +{ + lib, + config, + namespace, + pkgs, + ... +}: +let + inherit (lib) mkIf; + inherit (lib.${namespace}) mkEnableModule enabled; + + cfg = config.${namespace}.programs.fish; + inherit (config.${namespace}) theme; +in +{ + options.programs = mkEnableModule "fish"; + + config = mkIf cfg.enable { + home.packages = with pkgs; [ + # general + babelfish + + # for extract() + gnutar + bzip2 + bzip3 + gzip + unzip + pax + unrar-free + ]; + + programs.fish = { + enable = true; + + ${theme.colors.name} = enabled; + + 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 + ''; + }; + }; + }; + }; +} diff --git a/modules/home/programs/neo/default.nix b/modules/home/programs/neo/default.nix new file mode 100644 index 0000000..a52cdcf --- /dev/null +++ b/modules/home/programs/neo/default.nix @@ -0,0 +1,32 @@ +{ + lib, + config, + namespace, + pkgs, + ... +}: +let + inherit (lib) mkIf; + inherit (lib.${namespace}) mkEnableModule; + + cfg = config.${namespace}.programs.neo; +in +{ + options.programs = mkEnableModule "neo"; + + config = mkIf cfg.enable { + home.packages = with pkgs; [ + neo + ]; + + programs.fish.functions = mkIf config.programs.fish.enable { + neo = { + wraps = "neo"; + body = # fish + '' + command neo --charset=ascii $argv + ''; + }; + }; + }; +} diff --git a/old/home/programs/fish.nix b/old/home/programs/fish.nix deleted file mode 100644 index 412871c..0000000 --- a/old/home/programs/fish.nix +++ /dev/null @@ -1,125 +0,0 @@ -{ pkgs, ... }: -{ - home.packages = with pkgs; [ - # general - babelfish - - # for extract() - gnutar - bzip2 - bzip3 - gzip - unzip - pax - unrar-free - - # shell goodies - neo - ]; - - programs.fish = { - enable = true; - - rose-pine.enable = true; - - 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 - ''; - }; - - neo = { - wraps = "neo"; - body = # fish - '' - command neo --charset=ascii $argv - ''; - }; - }; - }; -}