summary refs log tree commit diff stats
path: root/hm/zsh/default.nix
blob: a8e557114ddbb669e72a5fbe1b3f9c7d18277990 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
  config,
  pkgs,
  self,
  ...
}: {
  programs.zsh = {
    enable = true;

    syntaxHighlighting.enable = true;
    autosuggestion.enable = true;
    enableCompletion = true;

    autocd = true;
    dotDir = ".config/zsh";

    history = {
      path = "${config.xdg.stateHome}/zsh/zsh_history";
      ignoreSpace = false;
      save = 90000;
      size = 90000;
    };

    historySubstringSearch.enable = true;

    sessionVariables = {
      WALLPAPER = "${self}/files/wallpaper.jpg";
    };

    shellAliases = {
      vim = "nvim";
      ls = "lsd";
      l = "ls -l";
      la = "ls -a";
      lla = "ls -la";
      lt = "ls --tree";
      rebackup = "restic -r /mnt/storage/backups --password-file ~/srv/restic_pswd backup";
      repreconf = "restic -r /mnt/storage/backups --password-file ~/srv/restic_pswd";
      b-del = "sudo btrfs subv delet /srv/snapshots/home";
      b-shot = "sudo btrfs subvolume snapshot -r /home /srv/snapshots/home";
      b-home = ''[ -d /srv/snapshots/home ] && sudo btrfs subvolume delete /srv/snapshots/home; sudo btrfs subvolume snapshot -r /home /srv/snapshots/home; sudo restic -r /mnt/storage/backups --password-file ~/srv/restic_pswd --cache-dir /srv/.restic-cache backup /srv/snapshots/home;'';
      r-clean = ''
        sudo restic -r /mnt/storage/backups --password-file ~/srv/restic_pswd --cache-dir /srv/.restic-cache forget \
                                           --keep-weekly  7  \
                                           --keep-daily   7  \
                                           --keep-monthly 6  \
                                           --keep-yearly  10 \
                                           --keep-hourly  5  \
                                           --keep-tag prs
      '';
      r-prune = "sudo restic -r /mnt/storage/backups --password-file ~/srv/restic_pswd --cache-
    dir /srv/.restic-cache prune";
      r-check = "sudo restic -r /mnt/storage/backups --cache-dir /srv/.restic-cache --password-
    file ~/srv/.restic_pswd check";
      zconf = "nvim ~/.config/zsh/.zshrc";
      zenv = "nvim ~/.config/zsh/.zshenv";
      o = "xdg-open";
      wget = "wget --hsts-file=${config.xdg.dataHome}/wget-hsts";
      addagpl = "curl https://www.gnu.org/licenses/agpl-3.0.txt > COPYING";
      addgpl = "curl https://www.gnu.org/licenses/gpl-3.0.txt > COPYING";
      addapache = "curl https://www.apache.org/licenses/LICENSE-2.0.txt > LICENSE";
    };

    initExtraFirst =
      builtins.readFile ./config/instant-prompt.zsh
      + "source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
    # +
    initExtra =
      ''
        export ZSH=${pkgs.oh-my-zsh}/share/oh-my-zsh/
          export fpath=("$XDG_DATA_HOME/zsh/site-functions" $fpath)
          HISTFILE="$XDG_STATE_HOME/zsh/history"

          plugins=(git)



          source $ZSH/oh-my-zsh.sh
      ''
      + builtins.readFile ./config/p10k.zsh
      + builtins.readFile ./config/functions.zsh;
  };
}