Factor out fish module

This commit is contained in:
Nathan McCarty 2023-05-11 11:32:43 -04:00
parent 8dd5a33171
commit 345d9257c5
No known key found for this signature in database
4 changed files with 93 additions and 86 deletions

View File

@ -67,92 +67,6 @@ with lib; {
tmate tmate
]; ];
}) })
(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; };
})
(mkIf config.nathan.programs.util.json { (mkIf config.nathan.programs.util.json {
######################### #########################
## JSON Utilities ## JSON Utilities

View File

@ -0,0 +1,91 @@
{ 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; };
})
];
}

View File

@ -14,6 +14,7 @@ with nLib; {
../common/programs/terminal.nix ../common/programs/terminal.nix
../common/programs/git.nix ../common/programs/git.nix
../common/programs/ssh.nix ../common/programs/ssh.nix
../common/programs/fish.nix
./programs/core.nix ./programs/core.nix
./programs/emacs.nix ./programs/emacs.nix
./programs/devel.nix ./programs/devel.nix

View File

@ -14,6 +14,7 @@ with nLib; {
../common/programs/terminal.nix ../common/programs/terminal.nix
../common/programs/git.nix ../common/programs/git.nix
../common/programs/ssh.nix ../common/programs/ssh.nix
../common/programs/fish.nix
./programs/sway.nix ./programs/sway.nix
./programs/communications.nix ./programs/communications.nix
./programs/devel.nix ./programs/devel.nix