{ description = "jiriks74's ZSH configuration"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils, ... } @ inputs: let inherit (self) outputs; # Supported systems for your flake packages, shell, etc. systems = [ "aarch64-linux" "i686-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; # This is a function that generates an attribute by calling a function you # pass to it, with each system as an argument forAllSystems = nixpkgs.lib.genAttrs systems; in { formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); homeManagerModules = { default = { config, lib, pkgs, ... }: { home.packages = with pkgs; [ nix-zsh-completions asciinema # Terminal recording libnotify # Notifications websocat # For asciinema v2 streams tldr lsd bat eza trash-cli fzf # enhancd fd # enhancd # rofi # for fd gnutar # ex bzip3 # ex unzip # ex p7zip # ex unrar # ex gzip # ex ]; programs = { # nix-index = { # enable = true; # enableZshIntegration = true; # }; # thefuck = { # enable = true; # enableZshIntegration = true; # }; direnv = { enable = true; enableZshIntegration = true; nix-direnv.enable = true; }; zsh = { enable = true; enableCompletion = true; zplug = { enable = true; plugins = [ { name = "romkatv/powerlevel10k"; tags = ["as:theme" "depth:1"]; } # Installations with additional options. For the list of options, please refer to Zplug README. {name = "z-shell/F-Sy-H";} # Feature-rich Syntax Highlighting for Zsh # { name = "zsh-users/zsh-syntax-highlighting"; } {name = "zsh-users/zsh-completions";} # Adds some missing completions to zsh {name = "zsh-users/zsh-autosuggestions";} # Simple plugin installation {name = "MichaelAquilina/zsh-you-should-use";} # Did you forget to use an alias? {name = "davidde/git";} # Aliases for git { name = "babarot/enhancd"; tags = ["use:init.sh"]; } # Includes simmilar functionality to zsh-z {name = "supercrabtree/k";} # Directory listings for Zsh with git features. { name = "plugins/command-not-found"; tags = ["from:oh-my-zsh"]; } { name = "gko/ssh-connect"; tags = ["use:ssh-connect.sh"]; } # List of most used ssh connections {name = "agkozak/zsh-z";} # Jump arount your filesystem with ease {name = "sineto/web-search";} {name = "zsh-users/zaw";} # Desctiptions for command outputs (afaik)zplug "plugins/git", from:oh-my-zsh # { name = "plugins/dirhistory"; tags = [ "from:oh-my-zsh" ]; } ]; }; initExtraFirst = '' if [[ "''${ZSH_PROFILE}" -eq 1 ]]; then zmodload zsh/zprof # Profiling. Enable `zprof` at the end of initExtra too. else # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" fi fi ''; initExtra = '' # Remove nix from path if we are in a container (distrobox) if [ -v DISTROBOX_ENTER_PATH ]; then export PATH=$(echo $PATH | tr ':' '\n' | grep -vE '/nix/|/run/wrappers|\.nix-profile|/etc/profiles/per-user/jirka/bin|/run/current-system/sw/bin' | tr '\n' ':') export PATH=$(echo $PATH | sed 's/:$//') fi # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh export YSU_MESSAGE_POSITION="after" # you-should-use plugin export ASCIINEMA_API_URL=https://asciinema.stefka.eu if [ -v ASCIINEMA_REC ]; then _zsh_autosuggest_disable fi # Basic auto/tab complete: autoload -U compinit zstyle ':completion:*' menu select zmodload zsh/complist compinit _comp_options+=(globdots) # Include hidden files. # Custom ZSH Binds bindkey '^ ' autosuggest-accept bindkey "^[[H" beginning-of-line bindkey "^[[F" end-of-line bindkey "^[[1;5C" forward-word bindkey "^[[1;5D" backward-word bindkey "^[[3~" delete-char # Extracting ex () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.tar.xz) tar xJf $1 ;; *.bz2) bunzip3 $1 ;; *.rar) unrar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1;; *.7z) 7z x $1 ;; *) echo "'$1' cannot be extracted via ex()" ;; esac else echo "'$1' is not a valid file" fi } # Kitty binds if [ "$TERM" = "xterm-kitty" ]; then alias ssh="kitty +kitten ssh" alias icat="kitty +kitten icat" alias d="kitty +kitten diff" alias get="kitty +kitten transfer" alias put="kitty +kitten transfer --direction=upload" alias kclip="kitty +kitten clipboard" fi # Special aliases that may not work with Nix config # Command line head / tail shortcuts alias H="| head"; alias T="| tail"; alias G="| grep"; alias L="| less"; alias M="| most"; alias LL="2>&1 | less"; alias CA="2>&1 | cat -A"; alias NE="2> /dev/null"; alias NUL="> /dev/null 2>&1"; alias P="2>&1| pygmentize -l pytb"; if [[ "''${ZSH_PROFILE}" -eq 1 ]]; then zprof fi ''; shellAliases = { # update = "sudo nixos-rebuild switch"; ls = "lsd"; # ls, the common ones I use a lot shortened for rapid fire usage l = "ls -lFh"; #size,show type,human readable la = "ls -lAFh"; #long list,show almost all,show type,human readable lr = "ls -tRFh"; #sorted by date,recursive,show type,human readable lt = "ls -ltFh"; #long list,sorted by date,show type,human readable ll = "ls -l"; #long list ldot = "ls -ld .*"; lS = "ls -1FSsh"; lart = "ls -1Fcart"; lrt = "ls -1Fcrt"; grep = "grep --color"; sgrep = "grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} "; t = "tail -f"; dud = "du -d 1 -h"; duf = "du -sh *"; # fd="find . -type d -name"; ff = "find . -type f -name"; h = "history"; hgrep = "fc -El 0 | grep"; help = "man"; p = "ps -f"; sortnr = "sort -n -r"; unexport = "unset"; # Use trash instead of rm if available rm = "trash"; cp = "cp -i"; mv = "mv -i"; cls = "clear"; sshc = "ssh-connect"; }; history = { # ignoreAllDups = true; path = "${config.xdg.cacheHome}/zhistory"; save = 10000; size = 10000; # share = true; }; }; }; home.file = { # ".zprofile".source = ./zprofile; }; }; }; }; }