2021-02-19 20:44:18 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2021-03-13 01:02:50 +01:00
|
|
|
let
|
|
|
|
cfg = config.my.home.zsh;
|
|
|
|
in
|
2021-02-19 19:44:09 +01:00
|
|
|
{
|
2023-02-22 17:00:26 +01:00
|
|
|
options.my.home.zsh = with lib; {
|
|
|
|
enable = my.mkDisableOption "zsh configuration";
|
2023-02-22 17:04:20 +01:00
|
|
|
|
2023-02-22 17:09:45 +01:00
|
|
|
launchTmux = mkEnableOption "auto launch tmux at shell start";
|
2021-03-13 01:02:50 +01:00
|
|
|
};
|
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
config = lib.mkIf cfg.enable {
|
2022-03-02 17:01:11 +01:00
|
|
|
home.packages = with pkgs; [
|
|
|
|
zsh-completions
|
|
|
|
];
|
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
programs.zsh = {
|
|
|
|
enable = true;
|
|
|
|
dotDir = ".config/zsh"; # Don't clutter $HOME
|
|
|
|
enableCompletion = true;
|
2021-02-19 19:44:09 +01:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
history = {
|
|
|
|
size = 500000;
|
|
|
|
save = 500000;
|
|
|
|
extended = false;
|
|
|
|
ignoreSpace = true;
|
|
|
|
ignoreDups = true;
|
|
|
|
share = false;
|
|
|
|
path = "${config.xdg.dataHome}/zsh/zsh_history";
|
|
|
|
};
|
2021-02-19 19:44:09 +01:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
plugins = with pkgs; [
|
|
|
|
{
|
|
|
|
name = "fast-syntax-highlighting";
|
|
|
|
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
|
|
|
|
src = pkgs.zsh-fast-syntax-highlighting;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "agkozak-zsh-prompt";
|
2022-04-11 15:15:36 +02:00
|
|
|
file = "share/zsh/site-functions/agkozak-zsh-prompt.plugin.zsh";
|
|
|
|
src = pkgs.agkozak-zsh-prompt;
|
2022-03-02 16:59:26 +01:00
|
|
|
}
|
|
|
|
];
|
2021-02-19 20:05:15 +01:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
# Modal editing is life, but CLI benefits from emacs gymnastics
|
|
|
|
defaultKeymap = "emacs";
|
2021-02-19 20:16:08 +01:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
# Make those happen early to avoid doing double the work
|
2023-02-22 17:04:20 +01:00
|
|
|
initExtraFirst = ''
|
|
|
|
${
|
|
|
|
lib.optionalString cfg.launchTmux ''
|
|
|
|
# Launch tmux unless already inside one
|
|
|
|
if [ -z "$TMUX" ]; then
|
|
|
|
exec tmux new-session
|
|
|
|
fi
|
|
|
|
''
|
|
|
|
}
|
|
|
|
'';
|
2021-09-30 15:34:16 +02:00
|
|
|
|
2023-02-08 15:43:39 +01:00
|
|
|
initExtra = ''
|
|
|
|
source ${./completion-styles.zsh}
|
|
|
|
source ${./extra-mappings.zsh}
|
|
|
|
source ${./options.zsh}
|
2023-02-08 15:44:20 +01:00
|
|
|
|
|
|
|
# Source local configuration
|
|
|
|
if [ -f "$ZDOTDIR/zshrc.local" ]; then
|
|
|
|
source "$ZDOTDIR/zshrc.local"
|
|
|
|
fi
|
2023-02-08 15:43:39 +01:00
|
|
|
'';
|
2021-02-19 21:56:21 +01:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
localVariables = {
|
|
|
|
# I like having the full path
|
|
|
|
AGKOZAK_PROMPT_DIRTRIM = 0;
|
|
|
|
# Because I *am* from EPITA
|
|
|
|
AGKOZAK_PROMPT_CHAR = [ "42sh$" "42sh#" ":" ];
|
|
|
|
# Easy on the eyes
|
|
|
|
AGKOZAK_COLORS_BRANCH_STATUS = "magenta";
|
|
|
|
# I don't like moving my eyes
|
|
|
|
AGKOZAK_LEFT_PROMPT_ONLY = 1;
|
|
|
|
};
|
2021-03-30 23:33:42 +02:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
shellAliases = {
|
2023-02-19 13:25:40 +01:00
|
|
|
# I like pretty colors
|
|
|
|
diff = "diff --color=auto";
|
|
|
|
grep = "grep --color=auto";
|
|
|
|
egrep = "egrep --color=auto";
|
|
|
|
fgrep = "fgrep --color=auto";
|
|
|
|
ls = "ls --color=auto";
|
|
|
|
|
2023-02-08 11:36:07 +01:00
|
|
|
# Well-known ls aliases
|
|
|
|
l = "ls -alh";
|
|
|
|
ll = "ls -l";
|
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
# Sometime `gpg-agent` errors out...
|
|
|
|
reset-agent = "gpg-connect-agent updatestartuptty /bye";
|
|
|
|
};
|
2021-04-07 19:15:03 +02:00
|
|
|
|
2023-02-12 17:43:55 +01:00
|
|
|
# Enable VTE integration
|
|
|
|
enableVteIntegration = true;
|
2022-03-02 16:59:26 +01:00
|
|
|
};
|
2021-02-19 19:58:59 +01:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
# Fuzzy-wuzzy
|
|
|
|
programs.fzf = {
|
|
|
|
enable = true;
|
|
|
|
enableZshIntegration = true;
|
|
|
|
};
|
2021-02-19 20:31:25 +01:00
|
|
|
|
2022-03-02 16:59:26 +01:00
|
|
|
programs.dircolors = {
|
|
|
|
enable = true;
|
|
|
|
};
|
2021-02-19 20:31:25 +01:00
|
|
|
};
|
2021-02-19 19:44:09 +01:00
|
|
|
}
|