nixos-config/modules/programs/zsh/default.nix

117 lines
3.6 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2021-07-29 20:21:51 +00:00
let
cfg = config.ptw.programs.zsh;
in {
options.ptw.programs.zsh = {
enable = lib.mkEnableOption "Enable and configure zsh using HomeManager";
2021-07-29 20:21:51 +00:00
};
config = lib.mkIf cfg.enable {
environment = {
systemPackages = [ pkgs.zsh ];
shells = [ pkgs.zsh ];
pathsToLink = [ "/share/zsh" ];
2021-07-29 20:21:51 +00:00
};
# Otherwise the user won't appear on the GDM login screen
programs.zsh.enable = true;
home-manager.users."${config.ptw.system.singleUser}".programs.zsh = {
enable = true;
history.ignoreSpace = true;
2021-12-06 22:04:27 +00:00
shellAliases = let
home = "/home/${config.ptw.system.singleUser}/Development/Personal/nixos-config";
2022-05-22 18:42:32 +00:00
nixosSwitch = "nixos-rebuild --flake .#${config.ptw.system.hostName} switch --use-remote-sudo";
2021-12-06 22:04:27 +00:00
in {
ls = "ls --color=always";
".." = "cd ..";
"..." = "cd ../../";
dev = "cd $HOME/Development";
home = "cd $HOME";
reload = "$SHELL -l";
gs = "git status";
gd = "git diff";
gds = "git diff --staged";
c = "clear";
suspend = "systemctl suspend";
2021-12-06 22:04:27 +00:00
nixos-rebuild-switch = "pushd; cd ${home}; sudo ${nixosSwitch}; popd";
2022-05-22 18:42:32 +00:00
nixos-rebuild-switch-fast = "pushd; cd ${home}; ${nixosSwitch} --fast; popd";
waifu2x = "flatpak run com.github.nihui.waifu2x-ncnn-vulkan";
};
initExtra = ''
2021-07-29 20:21:51 +00:00
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
bindkey "\e[3~" delete-char
'';
history.share = true;
2022-04-23 18:12:59 +00:00
initExtraFirst = let
enableDirenv = lib.optionalString
config.ptw.programs.direnv.enable
"eval \"$(${pkgs.direnv}/bin/direnv hook zsh)\"";
in ''
${enableDirenv}
# TODO: Maybe move this somewhere else
2021-08-30 09:20:31 +00:00
wcurl() {
[[ -z "$1" ]] && echo "Error: No URL specified" && exit 1
local filename="$(basename $1)"
curl -fLo "$filename" "$1"
}
'';
plugins = [
{
name = "pure.zsh";
file = "pure.zsh";
src = pkgs.fetchFromGitHub {
owner = "sindresorhus";
repo = "pure";
rev = "v1.17.0";
sha256 = "0qfs7rvpyd8jb7x4ziqrkh0b6g9ldds8sn6qbqgrir80vdk90gpa";
};
}
{
name = "zsh-history-substring-search";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-history-substring-search";
rev = "0f80b8eb3368b46e5e573c1d91ae69eb095db3fb";
sha256 = "0y8va5kc2ram38hbk2cibkk64ffrabfv1sh4xm7pjspsba9n5p1y";
};
}
{
name = "completion";
file = "init.zsh";
src = pkgs.fetchFromGitHub {
owner = "zimfw";
repo = "completion";
rev = "db079f405397a9dc9af93883e47d8adff817e3b1";
sha256 = "1vakjj8l10discmzrzjq6nd0bg0jf4chxhwpiq7ldkirzy7lmm9c";
};
}
{
name = "zsh-completions";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-completions";
rev = "d4511c23659381b56dec8be8c8553b7ff3dc5fd8";
sha256 = "1y8wkmhgkkyfz91y1f8crh6cg912n87gmcchc8xhnwji11n1mqrq";
};
}
{
name = "zsh-syntax-highlighting";
src = pkgs.fetchFromGitHub {
owner = "zsh-users";
repo = "zsh-syntax-highlighting";
2022-03-19 14:19:11 +00:00
rev = "c5ce0014677a0f69a10b676b6038ad127f40c6b1";
sha256 = "sha256-UqeK+xFcKMwdM62syL2xkV8jwkf/NWfubxOTtczWEwA=";
};
}
];
};
2021-07-29 20:21:51 +00:00
};
}