refactor(home:fish): split config
This commit is contained in:
parent
8f903a742a
commit
546ee5f965
5 changed files with 83 additions and 28 deletions
26
home/modules/console/shell/fish/aliases.nix
Normal file
26
home/modules/console/shell/fish/aliases.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ lib, config, osConfig, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf getExe;
|
||||
inherit (pkgs) bat eza dust;
|
||||
|
||||
cfg = config.ooknet.shell.fish;
|
||||
admin = osConfig.ooknet.host.admin;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (cfg.enable || admin.shell == "fish") {
|
||||
programs.fish = {
|
||||
shellAliases = {
|
||||
cat = "${getExe bat}";
|
||||
ls = "${getExe eza} -a --icons --group-directories-first";
|
||||
lst = "${getExe eza} -T -L 5 --icons --group-directories-first";
|
||||
du = "${getExe dust}";
|
||||
};
|
||||
shellAbbrs = {
|
||||
f = "cd $FLAKE";
|
||||
fe = "$EDITOR $FLAKE";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
18
home/modules/console/shell/fish/binds.nix
Normal file
18
home/modules/console/shell/fish/binds.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{ lib, config, osConfig, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
cfg = config.ooknet.shell.fish;
|
||||
admin = osConfig.ooknet.host.admin;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (cfg.enable || admin.shell == "fish") {
|
||||
programs.fish.functions = {
|
||||
fish_user_key_bindings = ''
|
||||
bind --preset -M insert \cf fe
|
||||
bind --preset -M insert \ec fzf_cd_widget
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,41 +1,23 @@
|
|||
{ lib, config, osConfig, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf any;
|
||||
inherit (lib) mkIf;
|
||||
cfg = config.ooknet.shell.fish;
|
||||
admin = osConfig.ooknet.host.admin;
|
||||
hasPackage = pname: any (p: p ? pname && p.pname == pname) config.home.packages;
|
||||
hasEza = hasPackage "eza";
|
||||
hasBat = hasPackage "bat";
|
||||
in
|
||||
|
||||
{
|
||||
imports = [
|
||||
./plugins.nix
|
||||
./binds.nix
|
||||
./aliases.nix
|
||||
];
|
||||
|
||||
config = mkIf (cfg.enable || admin.shell == "fish") {
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
shellAbbrs = {
|
||||
fe = "cd $FLAKE; $EDITOR $FLAKE";
|
||||
f = "cd $FLAKE";
|
||||
s = "cd $SCRIPTS";
|
||||
tree = mkIf hasEza "eza -T --icons --group-directories-first";
|
||||
ls = mkIf hasEza "eza -a --icons --group-directories-first";
|
||||
lsd = mkIf hasEza "eza -al --icons --group-directories-first";
|
||||
lst = mkIf hasEza "eza -T -L 5 --icons --group-directories-first";
|
||||
lsta = mkIf hasEza "eza -T --icons --group-directories-first";
|
||||
cat = mkIf hasBat "bat";
|
||||
};
|
||||
functions = {
|
||||
fish_greeting = "";
|
||||
fish_flake_edit = ''
|
||||
cd $FLAKE
|
||||
hx $FLAKE
|
||||
'';
|
||||
fish_hello_world = ''
|
||||
echo "Hello World"; string repeat -N \n --count=(math (count (fish_prompt)) - 1); commandline -f repaint
|
||||
'';
|
||||
|
||||
fish_user_key_bindings = ''
|
||||
bind --preset -M insert \cf fish_flake_edit
|
||||
bind --preset -M insert \ec fzf_cd_widget
|
||||
'';
|
||||
};
|
||||
interactiveShellInit =
|
||||
# Use vim bindings and cursors
|
||||
|
|
|
|||
29
home/modules/console/shell/fish/plugins.nix
Normal file
29
home/modules/console/shell/fish/plugins.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{ lib, config, pkgs, osConfig, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
cfg = config.ooknet.shell.fish;
|
||||
admin = osConfig.ooknet.host.admin;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (cfg.enable || admin.shell == "fish") {
|
||||
programs.fish = {
|
||||
plugins = [
|
||||
{
|
||||
name = "done";
|
||||
src = pkgs.fishPlugins.done.src;
|
||||
}
|
||||
{
|
||||
name = "autopair";
|
||||
src = pkgs.fishPlugins.autopair.src;
|
||||
}
|
||||
{
|
||||
name = "colored-man-pages";
|
||||
src = pkgs.fishPlugins.colored-man-pages.src;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue