System/home-manager/common/programs/fish.nix

92 lines
2.6 KiB
Nix
Raw Normal View History

2023-05-11 11:32:43 -04:00
{ config, lib, pkgs, inputs, ... }:
with lib; {
config = mkMerge [
(mkIf config.nathan.programs.util.fish {
#########################
## Fish Configuration
#########################
programs.fish = {
enable = true;
# Setup our aliases
shellAliases = {
ls = "exa --icons";
la = "exa --icons -a";
lg = "exa --icons --git";
cat = "bat";
dig = "dog";
df = "duf";
idris2 = "rlwrap -s 1000 idris2 --no-banner";
};
# Custom configuration
interactiveShellInit = ''
# Setup any-nix-shell
any-nix-shell fish --info-right | source
# Load logger function
source ~/.config/fish/functions/cmdlogger.fish
# Load up vi keybindings
fish_vi_key_bindings
'';
functions = {
# Setup command logging to ~/.logs
cmdlogger = {
onEvent = "fish_preexec";
body = ''
mkdir -p ~/.logs
echo (date -u +"%Y-%m-%dT%H:%M:%SZ")" "(echo %self)" "(pwd)": "$argv >> ~/.logs/(hostname)-(date "+%Y-%m-%d").log
'';
};
};
};
programs.starship = {
enable = true;
settings = {
directory = {
truncation_length = 3;
fish_style_pwd_dir_length = 1;
};
git_commit = {
commit_hash_length = 6;
only_detached = false;
};
package = { symbol = ""; };
time = {
disabled = false;
format = "[$time]($style)";
time_format = "%I:%M %p";
};
};
};
programs.bat = {
enable = true;
config = {
theme = "zenburn";
style = "header,rule,snip,changes";
};
};
#########################
## Readline + fzf and other quality of life stuff
#########################
programs.readline = {
enable = true;
extraConfig = ''
set editing-mode vi
set show-all-if-ambiguous on
set editing-mode vi
set keymap vi-command
# these are for vi-command mode
"\e[A": history-search-backward
"\e[B": history-search-forward
j: history-search-forward
k: history-search-backward
set keymap vi-insert
# these are for vi-insert mode
"\e[A": history-search-backward
"\e[B": history-search-forward
'';
};
programs.fzf = { enable = true; };
})
];
}