{ config, pkgs, lib, ... }: { # Fish Shell # https://rycee.gitlab.io/home-manager/options.html#opt-programs.fish.enable programs.fish.enable = true; # Add Fish plugins home.packages = with pkgs.fishPlugins; [ done ]; programs.fish.plugins = [ { name = "fisher"; src = pkgs.fetchFromGitHub { owner = "jorgebucaran"; repo = "fisher"; rev = "93dafd242b52a0dc6bea54130d0ea041830c7fd6"; sha256 = "0qbqlydh7b928473f7c4gy68sr1wnwyhcvvqzcik1vx5hdbka7ad"; }; } ]; home.file.".config/fish/fish_plugins".text = '' jorgebucaran/autopair.fish jorgebucaran/replay.fish jorgebucaran/getopts.fish americanhanko/fish-spin joseluisq/gitnow fishpkg/fish-humanize-duration oh-my-fish/plugin-bang-bang matthewess/fish-autovenv jethrokuan/z Gazorby/fish-abbreviation-tips ''; # Fish functions ----------------------------------------------------------------------------- {{{ programs.fish.functions = { # User functions mkdcd = { argumentNames = [ "target" ]; body = '' mkdir -p $target cd $target ''; }; unz = { argumentNames = [ "target" ]; body = '' # strip extensions string match \*.zip $target; and set target (string split -r -m1 . $target)[1] unzip -d $target $target ''; }; # Helpers # Toggles `$term_background` between "light" and "dark". Other Fish functions trigger when this # variable changes. We use a universal variable so that all instances of Fish have the same # value for the variable. toggle-background.body = '' if test "$term_background" = light set -U term_background dark else set -U term_background light end ''; # Set `$term_background` based on whether macOS is light or dark mode. Other Fish functions # trigger when this variable changes. We use a universal variable so that all instances of Fish # have the same value for the variable. set-background-to-macOS.body = '' if is-dark-mode set -U term_background dark else set -U term_background light end ''; # Set `$term_background` based on an env var. set-background-to-env = { argumentNames = [ "env_var" ]; body = '' switch $$env_var case 1 set -U term_background dark case 0 set -U term_background light end ''; }; # Sets Fish Shell to light or dark colorscheme based on `$term_background`. set-shell-colors = { body = '' # Use correct theme for `btm` if test "$term_background" = light alias btm "btm --color default-light" else alias btm "btm --color default" end # Set LS_COLORS set -xg LS_COLORS (${pkgs.vivid}/bin/vivid generate one-$term_background) # Set color variables if test "$term_background" = light set emphasized_text brgreen # base01 set normal_text bryellow # base00 set secondary_text brcyan # base1 set background_light white # base2 set background brwhite # base3 else set emphasized_text brcyan # base1 set normal_text brblue # base0 set secondary_text brgreen # base01 set background_light black # base02 set background brblack # base03 end # Set Fish colors that change when background changes set -g fish_color_command $emphasized_text --bold # color of commands set -g fish_color_param $normal_text # color of regular command parameters set -g fish_color_comment $secondary_text # color of comments set -g fish_color_autosuggestion $secondary_text # color of autosuggestions set -g fish_pager_color_prefix $emphasized_text --bold # color of the pager prefix string set -g fish_pager_color_description $selection_text # color of the completion description set -g fish_pager_color_selected_prefix $background set -g fish_pager_color_selected_completion $background set -g fish_pager_color_selected_description $background ''; onVariable = "term_background"; }; init-shell-colors.body = '' set -g fish_color_quote cyan # color of commands set -g fish_color_redirection brmagenta # color of IO redirections set -g fish_color_end blue # color of process separators like ';' and '&' set -g fish_color_error red # color of potential errors set -g fish_color_match --reverse # color of highlighted matching parenthesis set -g fish_color_search_match --background=yellow set -g fish_color_selection --reverse # color of selected text (vi mode) set -g fish_color_operator green # color of parameter expansion operators like '*' and '~' set -g fish_color_escape red # color of character escapes like '\n' and and '\x70' set -g fish_color_cancel red # color of the '^C' indicator on a canceled command ''; from-dir = { argumentNames = [ "dir" ]; body = '' pushd $dir set -e argv[1] $argv popd ''; }; }; # }}} # Fish configuration ------------------------------------------------------------------------- {{{ # Aliases programs.fish.shellAliases = let nixConfigDir = "${config.home.homeDirectory}/dotfiles.nix"; in with pkgs; { # Nix related from-nix = "from-dir ${nixConfigDir}"; # darwin-rebuild build drb = "from-nix darwin-rebuild build --flake ."; # darwin-rebuild switch full drsf = "from-nix darwin-rebuild switch --flake ."; # darwin-rebuild switch (no homebrew) drs = "from-nix darwin-rebuild switch --flake . --override-input homebrew-enabled github:boolean-option/false"; # edit darwin-rebuild config in codium drc = "codium ${nixConfigDir}"; # edit darwin-rebuild config in vim drv = "vim ${nixConfigDir}"; # edit darwin-rebuild config in kakoune drk = "from-nix kak flake.nix"; flakeup = "nix flake update ${nixConfigDir}/"; nb = "nix build"; nd = "nix develop"; nf = "nix flake"; nr = "nix run"; ns = "nix search nixpkgs"; nsh = "nix shell"; nrp = "nix repl --expr '{pkgs=(import {});}'"; # Other ".." = "cd .."; ":q" = "exit"; cat = "${bat}/bin/bat"; du = "${du-dust}/bin/dust"; g = "${gitAndTools.git}/bin/git"; ls = "${exa}/bin/exa"; ll = "ls -l --time-style long-iso --icons"; la = "ll -a"; ps = "${procs}/bin/procs"; code = "${vscodium}/bin/codium"; http = "${xh}/bin/xh"; https = "${xh}/bin/xhs"; top = "${bottom}/bin/btm"; htop = "${bottom}/bin/btm"; tb = "toggle-background"; sb = "set-background-to-macOS"; }; # Configuration that should be above `loginShellInit` and `interactiveShellInit`. programs.fish.shellInit = '' set -U fish_term24bit 1 ${lib.optionalString pkgs.stdenv.isDarwin "set-background-to-macOS"} ''; programs.fish.interactiveShellInit = '' set -g fish_greeting "ヽ(´ᗜ`)ノ welcome ヽ(´ᗜ`)ノ" fish_vi_key_bindings set VIRTUAL_ENV_DISABLE_PROMPT true bind -M insert ! __history_previous_command bind -M insert '$' __history_previous_command_arguments ${pkgs.thefuck}/bin/thefuck --alias | source # Run function to set colors that are dependent on `$term_background` and to register them so # they are triggered when the relevent event happens or variable changes. set-shell-colors # Set Fish colors that aren't dependent the `$term_background`. init-shell-colors ''; # }}} # Starship Prompt # https://rycee.gitlab.io/home-manager/options.html#opt-programs.starship.enable programs.starship.enable = true; # Starship settings -------------------------------------------------------------------------- {{{ programs.starship.settings = { # See docs here: https://starship.rs/config/ # Symbols config configured in Flake. battery.display = [ { threshold = 25; } # display battery information if charge is <= 25% ]; directory.fish_style_pwd_dir_length = 1; # turn on fish directory truncation directory.truncation_length = 2; # number of directories not to truncate # hostname.style = "bold green"; # don't like the default memory_usage.disabled = true; # because it includes cached memory it's reported as full a lot # username.style_user = "bold blue"; # don't like the default }; # }}} # dark-mode-notify configuration # {{{ launchd.enable = true; launchd.agents.dark-mode-notify = { enable = true; config = { Label = "ke.bou.dark-mode-notify"; KeepAlive = true; StandardErrorPath = null; StandardOutPath = null; ProgramArguments = [ "${pkgs.dark-mode-notify}/bin/dark-mode-notify" "${pkgs.fish}/bin/fish" "-c" "set-background-to-env DARKMODE" ]; }; }; # }}} }