dotfiles/home/apps/zsh.nix

111 lines
2.5 KiB
Nix
Raw Normal View History

{
2023-02-10 07:46:37 +01:00
config,
2023-09-03 00:48:39 +02:00
lib,
2023-02-10 07:46:37 +01:00
pkgs,
...
2024-05-07 18:20:52 +02:00
}:
let
2024-05-02 20:06:56 +02:00
inherit (pkgs.stdenv) isLinux;
2024-05-07 18:20:52 +02:00
srcs = pkgs.callPackage ../../_sources/generated.nix { };
zshPlugins =
plugins:
(map (plugin: rec {
name = src.name;
inherit (plugin) file src;
2024-05-07 18:20:52 +02:00
}) plugins);
in
{
2024-05-16 01:26:47 +02:00
programs.zsh = {
enable = true;
autosuggestion.enable = true;
enableCompletion = true;
initExtraFirst = ''
zvm_config() {
ZVM_INIT_MODE=sourcing
ZVM_CURSOR_STYLE_ENABLED=false
ZVM_VI_HIGHLIGHT_BACKGROUND=black
ZVM_VI_HIGHLIGHT_EXTRASTYLE=bold,underline
ZVM_VI_HIGHLIGHT_FOREGROUND=white
}
'';
initExtra =
''
function incognito() {
if [[ -n $ZSH_INCOGNITO ]]; then
add-zsh-hook precmd _atuin_precmd
add-zsh-hook preexec _atuin_preexec
unset ZSH_INCOGNITO
else
add-zsh-hook -d precmd _atuin_precmd
add-zsh-hook -d preexec _atuin_preexec
export ZSH_INCOGNITO=1
fi
}
2024-05-02 20:06:56 +02:00
2024-05-16 01:26:47 +02:00
onefetch_in_git_dir() {
if [[ -d '.git' ]]; then
${pkgs.onefetch}/bin/onefetch --no-merges --no-bots --no-color-palette --true-color=never --text-colors 1 1 3 4 4
2024-05-16 01:26:47 +02:00
fi
}
2024-03-14 22:12:11 +01:00
2024-05-16 01:26:47 +02:00
add-zsh-hook chpwd onefetch_in_git_dir
''
+ lib.optionalString isLinux ''
function open() {
nohup xdg-open "$*" > /dev/null 2>&1
}
'';
2024-03-14 22:12:11 +01:00
2024-05-16 01:26:47 +02:00
dotDir = ".config/zsh";
oh-my-zsh = {
enable = true;
plugins =
[
"colored-man-pages"
"colorize"
"git"
"kubectl"
]
++ lib.optionals pkgs.stdenv.isDarwin [
"dash"
"macos"
];
};
plugins = zshPlugins [
{
src = pkgs.zsh-vi-mode;
file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh";
}
{
src = pkgs.zsh-nix-shell;
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
}
{
src = pkgs.zsh-fast-syntax-highlighting.overrideAttrs (_: {
src = srcs.zsh-fast-syntax-highlighting.src;
});
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
}
];
2024-05-16 16:21:04 +02:00
sessionVariables = {
MANPAGER = "sh -c 'col -bx | bat -l man -p'";
};
2024-05-16 01:26:47 +02:00
shellAliases = {
cat = "bat";
ls = "eza";
ll = "eza -l";
la = "eza -a";
lt = "eza -T";
lla = "eza -la";
llt = "eza -lT";
cp = "cp -i";
mv = "mv -i";
rm = "rm -i";
};
2024-05-16 01:26:47 +02:00
history.path = "${config.xdg.configHome}/zsh/history";
};
}