dotfiles.nix/home/fish.nix

134 lines
3.4 KiB
Nix
Raw Normal View History

2024-07-21 04:25:16 +00:00
{ pkgs, ... }:
2024-07-18 14:16:04 +00:00
let
nixConfigDirectory = "~/dotfiles.nix";
in
{
2024-07-21 04:25:16 +00:00
imports = [ ./extras/fish/auto-theme.nix ];
programs.fish = {
enable = true;
2023-10-26 02:37:42 +00:00
2024-07-21 04:25:16 +00:00
autoTheme = {
enable = true;
light = "rose-pine-dawn";
dark = "rose-pine";
};
# see flake.nix and pkgs/default.nix
plugins = pkgs.fishPlugins.flakePlugins;
2023-10-26 02:37:42 +00:00
2024-07-21 04:25:16 +00:00
functions = {
# user functions
mkdcd = {
argumentNames = [ "target" ];
body = ''
if test -z "$target"
echo "mkdcd requires an argument" 1>&2
return 1
end
mkdir -p $target
cd $target
'';
2024-07-21 04:25:16 +00:00
};
2024-07-21 04:25:16 +00:00
from-dir = {
argumentNames = [ "dir" ];
body = ''
pushd $dir
set -e argv[1]
$argv
popd
'';
2024-07-21 04:25:16 +00:00
};
2024-07-21 04:25:16 +00:00
darwin-rebuild-edit-with = {
argumentNames = [
"editor"
"file"
];
body = ''
if test -z "$file"
set file flake.nix
end
2024-07-21 04:25:16 +00:00
from-nix $editor $file
'';
};
2022-01-23 01:32:58 +00:00
2024-07-21 04:25:16 +00:00
# TODO: use these to implement !! and .. abbreviations
# blocked on additional support for abbr in home-manager
# https://github.com/nix-community/home-manager/issues/3706
#
# taken from
# https://fishshell.com/docs/current/relnotes.html#fish-3-6-0-released-january-7-2023
# last-history-item.body = ''
# echo $history[1]
# '';
# multi-cd.body = ''
# echo cd (string repeat -n (math (string length -- $argv[1]) - 1) ../)
# '';
};
2024-07-18 14:16:04 +00:00
2024-07-21 04:25:16 +00:00
shellAbbrs = {
".." = "cd ..";
# 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 helix
drh = "darwin-rebuild-edit-with hx";
# edit darwin-rebuild config in zed
drz = "zed ${nixConfigDirectory}";
nb = "nix build";
nd = "nix develop";
nf = "nix flake";
nfc = "nix flake check";
nfi = "nix flake init";
nfs = "nix flake show";
nfu = "nix flake update";
nr = "nix run";
ns = "nix search nixpkgs";
nsh = "nix shell";
nrp = "nix repl --expr '{ pkgs = (import <nixpkgs> { }); }'";
g = "git";
ga = "git add";
gc = "git commit";
gd = "git diff";
gl = "git log";
gp = "git push";
stage = "git add .";
commit = "git commit";
push = "git push";
pull = "git pull";
};
shellAliases = {
# nix related
from-nix = "from-dir ${nixConfigDirectory}";
# other
":q" = "exit";
cat = "bat --style=plain --paging=never";
du = "dust";
http = "xh";
https = "xhs";
top = "btm";
htop = "btm --basic";
colortest = "terminal-colors -o";
};
2022-01-23 01:32:58 +00:00
# configuration that should be above `loginShellInit` and `interactiveShellInit`.
shellInit = ''
set -U fish_term24bit 1
'';
interactiveShellInit = ''
set -g fish_greeting (set_color red)"( ³)"(set_color yellow)" hello "(set_color blue)"( ³)"(set_color normal)
fish_vi_key_bindings
'';
};
2023-10-26 02:37:42 +00:00
home.sessionVariables.VIRTUAL_ENV_DISABLE_PROMPT = "true";
2022-01-23 01:32:58 +00:00
}