nixos-config/shared/zsh.nix

109 lines
3.2 KiB
Nix
Raw Normal View History

2023-06-19 13:22:15 +02:00
{ pkgs, config, lib, ... }:
2024-08-22 11:39:42 +02:00
let
switch = pkgs.writeShellScript "switch.sh" ''
OUT_PATH=/tmp/nixos-rebuild-nom-$(date +%s)
${lib.getExe pkgs.nix-output-monitor} build /etc/nixos\#nixosConfigurations.${config.networking.hostName}.config.system.build.toplevel -o $OUT_PATH
${pkgs.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set $OUT_PATH
$OUT_PATH/bin/switch-to-configuration switch
unlink $OUT_PATH
'';
garbage = pkgs.writeShellScript "garbage.sh" ''
nix-collect-garbage -d
echo Cleaning up boot entries...
/run/current-system/bin/switch-to-configuration boot
echo Done
'';
in
2023-04-21 20:03:23 +02:00
{
programs.command-not-found.enable = false;
programs.nix-index-database.comma.enable = true;
2023-04-21 20:13:57 +02:00
environment.systemPackages = with pkgs; [
bat
2023-09-12 11:09:32 +02:00
eza
2023-05-21 13:50:49 +02:00
duf
2023-04-24 10:57:32 +02:00
trash-cli
2023-05-21 13:50:49 +02:00
nix-output-monitor
iperf
2024-05-21 18:44:04 +02:00
jq
2024-10-13 22:47:55 +02:00
helix
2023-04-21 20:13:57 +02:00
];
2023-04-21 20:03:23 +02:00
users.defaultUserShell = pkgs.zsh;
2024-04-17 16:13:17 +02:00
programs.fzf = {
keybindings = true;
};
2024-08-22 11:39:42 +02:00
programs.zsh =
{
2023-04-21 20:03:23 +02:00
enable = true;
2024-08-22 11:39:42 +02:00
shellAliases = {
rm = "trash";
ls = "eza --icons";
l = "ls -l";
ll = "ls -la";
la = "ls -a";
less = "bat";
run0 = "run0 --setenv=PATH=$PATH --setenv=LOCALE_ARCHIVE=$LOCALE_ARCHIVE";
update = "cd /etc/nixos && nix flake update";
switch = "run0 ${switch}";
};
histSize = 100000;
histFile = "~/.local/share/zsh/history";
syntaxHighlighting.enable = true;
autosuggestions = {
enable = true;
highlightStyle = "fg=#00bbbb,bold";
};
shellInit = ''
zsh-newuser-install () {}
'';
2023-04-21 20:03:23 +02:00
2024-08-22 11:39:42 +02:00
interactiveShellInit =
''
export MCFLY_KEY_SCHEME=vim
export MCFLY_FUZZY=2
export MCFLY_DISABLE_MENU=TRUE
export MCFLY_RESULTS=30
export MCFLY_INTERFACE_VIEW=BOTTOM
export MCFLY_PROMPT=""
# fix for networkctl
zstyle ':completion:*:complete:networkctl:*' list-grouped true
source ${pkgs.agdsn-zsh-config}/etc/zsh/zshrc
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
unsetopt extendedglob
2024-01-11 14:09:56 +01:00
2023-09-19 15:34:29 +02:00
2024-08-22 11:39:42 +02:00
function svpn() {
unit=$(systemctl list-unit-files | grep "openconnect\|wg-quick\|wireguard\|openvpn\|openfortivpn" | cut -d "." -f1 | ${pkgs.fzf}/bin/fzf --preview 'systemctl status {}')
if [ $(systemctl is-active $unit) = "inactive" ]; then
systemctl start $unit
else
systemctl stop $unit
fi
}
2023-05-01 19:59:25 +02:00
2024-08-22 11:39:42 +02:00
prompt_dir() {
prompt_segment blue $CURRENT_FG '%c'
}
2023-05-16 10:40:34 +02:00
2024-08-22 11:39:42 +02:00
garbage() {
${pkgs.home-manager}/bin/home-manager expire-generations "-0 days"
run0 --setenv=PATH=$PATH --setenv=LOCALE_ARCHIVE=$LOCALE_ARCHIVE ${garbage}
}
2024-08-22 11:39:42 +02:00
sysdiff() {
echo System package diff:
${config.nix.package}/bin/nix store diff-closures $(command ls -d /nix/var/nix/profiles/system-* | tail -2)
}
'';
promptInit =
''
# if [[ "$(hostname)" == "thinkpad" ]]
# then
# cat ${../images/cat.sixel}
# fi
eval "$(${pkgs.mcfly}/bin/mcfly init zsh)"
eval "$(${pkgs.zoxide}/bin/zoxide init zsh)"
'';
};
2023-04-21 20:03:23 +02:00
}