about summary refs log blame commit diff stats
path: root/home-manager/config/zsh/default.nix
blob: e7cd98a10bb973645a487fa9639f5e4f8a7b1d5a (plain) (tree)
1
2
3
4
5
6
7
8
9
10

         
      
     


                                                                                                                                                             
















                                                     
                                               
                                            



                                              


                                              
                                                   


                                                                                                                                                  
                                       







































































                                                                                                                                                        
                                                































                                                                      
{
  config,
  pkgs,
  lib,
  ...
}: {
  # TODO ADD THIS ADDON
  # next one only works if your alias is only a command, e.g. if you `alias='cat some_file.txt &2> /dev/null'`, running `cat some_file.txt` won't trigger it.
  # TODO find something better for this use case
  # zsh-you-should-use # ZSH plugin that reminds you to use existing aliases for commands you just typed
  programs.zsh = {
    enable = true;
    enableAutosuggestions = true;
    enableCompletion = true;
    enableSyntaxHighlighting = true;

    autocd = true;

    dotDir = ".config/zsh";

    history = {
      extended = true;
      ignoreDups = false;
      expireDuplicatesFirst = false;
      ignoreSpace = false; # TODO I might change that

      path = "${config.xdg.dataHome}/zsh/history";
      save = 9000000; # number of lines to save
      size = 9000000; # number of lines to keep
      share = true; # share between sessions
    };
    historySubstringSearch = {
      enable = true;
      searchDownKey = "^[[B"; # DOWN Arrow key
      searchUpKey = "^[[A"; # UP Arrow key
    };

    loginExtra =
      builtins.readFile ./config/zsh-prompt.sh
      + builtins.readFile ./config/custom_cursor.sh
      + ''
        eval $(ssh-agent -s) > /dev/null # start ssh agent
        export ENHANCHED_NEOFETCH="$(pacman -Qn | wc -l) (pacman), $(pacman -Qm | wc -l) (aur), $(($(cargo install --list | wc -l ) / 2)) (cargo)"
      ''
      + lib.concatStringsSep "setopt" [
        "AUTO_CD"
        "AUTO_PUSHD"
        "CHASE_DOTS"

        "ALWAYS_TO_END"

        "EXTENDED_HISTORY"
        "HIST_ALLOW_CLOBBER"
        "HIST_VERIFY"
        "HIST_FCNTL_LOCK"

        "DVORAK"
        "CORRECT"

        "PROMPT_SUBST"
        "TRANSIENT_RPROMPT" # maybe?

        "COMBINING_CHARS"
        "VI"
      ];

    initExtraFirst = builtins.readFile ./config/zsh-init.sh;

    shellAliases = {
      ls = "ls -a --color=auto";
      ll = ". ll";
      pip = "pip --require-virtualenv";
      hisea = "history info | grep";

      mocp = "mocp -M ${config.xdg.configHome}/moc";
      yarn = "yarn --use-yarnrc ${config.xdg.configHome}/yarn/config";
    };
    sessionVariables = {
      # managed by home-manager xdg
      #      XDG_DATA_HOME = "$HOME/.local/share";
      #      XDG_STATE_HOME = "$HOME/.local/state";
      #      XDG_CACHE_HOME = "$HOME/.cache";
      #      XDG_CONFIG_HOME = "$HOME/.config";
      #      XDG_BIN_HOME = "\${HOME}/.local/bin";

      # HISTSIZE = "9000000"; # This Should already be set by the shell
      TIMEFMT = "'$fg[green]%J$reset_color' time: $fg[blue]%*Es$reset_color, cpu: $fg[blue]%P$reset_color"; # no idea what this does or why it is needed
      REPORTTIME = "10";

      PATH = [
        "\${PATH}:/home/dt/repos/shell/scripts"
        "/home/dt/.local/bin"
        "/home/dt/.local/share/cargo/bin/"
      ];
      EDITOR = "nvim";
      IVIEWER = "imv";
      READER = "zathura";
      VISUAL = "nvim";
      CODEEDITOR = "nvim";
      TERMINAL = "alacritty";
      BROWSER = "firefox";
      COLORTERM = "truecolor";
      PAGER = "less -R";
      WM = "river";
      AWMWALLPAPER = "/home/dt/media/pictures/tes/wallpapers-linux_cast/Dedicated_Colorschemes/nord/Abstract-Nord.png";

      # FUNCNEST for more functions in functions
      FUNCNEST = "2000";

      WALLPAPERDIR = "$HOME/media/pictures/wallpapers/";
      LESS = "R";
      MANPAGER = "less -R --use-color -Dd+r -Du+b";
      LIBVIRT_DEFAULT_URI = "qemu:///system";
      BEMENU_SCALE = "1.5";
      BEMENU_BACKEND = "wayland";
      BEMENU_OPTS = "--fn 'Source Code Pro 10' -c -l 30 -B 1 -W 0.9 --hf #ffffff";

      # Clean the home dir {{{
      _JAVA_OPTIONS = lib.concatStringsSep " " [
        ''-Djava.util.prefs.userRoot="${config.xdg.configHome}/java"''
        ''-Djavafx.cachedir="${config.xdg.cacheHome}/openjfx"''
      ];
      GRADLE_USER_HOME = "${config.xdg.dataHome}/gradle";
      CARGO_HOME = "${config.xdg.dataHome}/cargo";
      GNUPGHOME = "${config.xdg.dataHome}/gnupg";
      GOPATH = "${config.xdg.dataHome}/go";
      GTK2_RC_FILES = "${config.xdg.configHome}/gtk-2.0/gtkrc";
      LESSHISFILE = "${config.xdg.cacheHome}/less/history";
      LESSKEYIN = "${config.xdg.configHome}/less/lesskey";
      RUSTUP_HOME = "${config.xdg.dataHome}/rustup";
      NPM_CONFIG_USERCONFIG = "${config.xdg.configHome}/npm/npmrc";
      NUGET_PACKAGES = "${config.xdg.cacheHome}/NuGetPackages";
      PYTHONSTARTUP = "${config.xdg.configHome}/python/pythonrc";
      XAUTHORITY = "${config.xdg.stateHome}/Xauthority";
      COMPDUMPFILE = "${config.xdg.dataHome}/zsh/.zcompdump}";
      IPYTHONDIR = "${config.xdg.configHome}/ipython";
      PARALLEL_HOME = "${config.xdg.configHome}/parallel";
      STACK_XDG = "1";
      # }}}

      # Export Wayland env Vars {{{
      QT_QPA_PLATFORM = "wayland";
      QT_QPA_PLATFORMTHEME = "qt5ct"; # needs qt5ct
      CLUTTER_BACKEND = "wayland";
      SDL_VIDEODRIVER = "wayland"; # might brake some things
      MOZ_ENABLE_WAYLAND = "1";
      # }}}
    };
  };
}
# vim: ts=2