config/modules/shell-config/default.nix

88 lines
2.2 KiB
Nix
Raw Normal View History

2022-02-05 21:42:36 +02:00
{ pkgs, config, ... }:
let
component = name: builtins.readFile (builtins.toString ../../config/zsh/components + "/${name}.zsh");
snippets = map component [
"console-256color"
"fuzzy-tab"
"magic-space"
"navigation"
] ++ [
"source ${pkgs.fzf}/share/fzf/key-bindings.zsh"
"ZSH_HIGHLIGHT_DIRS_BLACKLIST=(/* /ipfs /ipns)"
''
command_not_found_handler() {
${pkgs.comma}/bin/comma "$@"
}
''
2022-02-05 21:42:36 +02:00
];
in {
environment.shellAliases = {
cat = "bat";
df = "duf";
doas = "doas ";
du = "dua";
ip = "ip -c";
ls = "lsd";
sudo = "sudo ";
tree = "lsd --tree";
uctl = "systemctl --user";
vim = "hx";
2022-02-05 21:42:36 +02:00
nix-repl = "nix repl '<repl>'";
# thanks gytis
manix-view = ''manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --ansi --preview="manix '{}' | sed 's/type: /> type: /g' | bat -l Markdown --color=always --plain"'';
};
programs = {
command-not-found.enable = false;
2022-02-05 21:42:36 +02:00
zsh = {
enable = true;
histFile = "$HOME/.cache/zsh_history";
histSize = 15000;
setOptions = [
"autocd"
"autopushd"
"globcomplete"
"globstarshort"
"histexpiredupsfirst"
"histfcntllock"
"histignoredups"
"histnofunctions"
"histnostore"
"histreduceblanks"
"histverify"
"interactivecomments"
"monitor"
"nobadpattern"
2022-04-22 21:26:13 +03:00
"nonomatch"
2022-02-05 21:42:36 +02:00
"promptsubst"
"sharehistory"
"zle"
];
vteIntegration = true;
promptInit = builtins.readFile ../../config/zsh/prompt.zsh;
interactiveShellInit = builtins.concatStringsSep "\n" snippets;
enableCompletion = true;
autosuggestions.enable = true;
syntaxHighlighting = {
enable = true;
highlighters = [ "main" "pattern" ];
styles = {
"precommand" = "fg=33";
"arg0" = "fg=39";
"single-hyphen-option" = "fg=229";
"double-hyphen-option" = "fg=228";
"path" = "none";
};
# these are aliases, highlight them properly regardless
patterns = {
"doas" = "fg=33";
"sudo" = "fg=33";
};
};
};
};
}