{ lib, config, pkgs, ... }:
with lib;
let
  cfg = config.modules.cli.ghq;
in
{
  options.modules.cli.ghq = {
    enable = mkEnableOption "enable ghq";
  };
  config = mkIf cfg.enable {
    home.packages = with pkgs; [
      ghq
      fzf
    ];

    programs.git.extraConfig = {
      ghq = {
        root = "~/code";
      };
    };
    
    home.shellAliases = {
      # thanks jdauliac for the tip
      g = "cd $(${pkgs.ghq}/bin/ghq root)/$(${pkgs.ghq}/bin/ghq list | ${pkgs.fzf}/bin/fzf)";
    };
  };
}
