diff options
| author | aethrvmn <me@aethrvmn.gr> | 2025-08-31 14:21:34 +0000 |
|---|---|---|
| committer | aethrvmn <me@aethrvmn.gr> | 2025-08-31 14:21:34 +0000 |
| commit | bfd970a07c231b5781871c16cb4612eb4c6b8fd4 (patch) | |
| tree | 50a4ac5138d1f438e4d5bad3a3dd880a0784cd3e /home-manager/zsh | |
| parent | added flake (diff) | |
imported system/home-manager config
Diffstat (limited to '')
| -rw-r--r-- | home-manager/zsh/default.nix | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/home-manager/zsh/default.nix b/home-manager/zsh/default.nix new file mode 100644 index 0000000..d713873 --- /dev/null +++ b/home-manager/zsh/default.nix @@ -0,0 +1,125 @@ +{ config, pkgs, lib, ... }: let + nixosScript = '' + nixos() { + case $1 in + update | up) + if [ "$#" -gt 1 ]; then + echo "Error: 'nixos update' takes no additional arguments." + return 1 + fi + nh os switch $HOME/.nix --ask + ;; + upgrade) + if [ "$#" -gt 1 ]; then + echo "Error: 'nixos upgrade' takes no additional arguments." + return 1 + fi + nh os switch $HOME/.nix -u --ask + ;; + clean) + nh clean all --verbose + ;; + config) + hx ~/.nix/"$2" + ;; + *) + echo "Usage: nixos update | up || nixos upgrade || nixos config <path>" + ;; + esac + } + + nix() { + if [[ $1 == "develop" ]]; then + shift + local flake + case $1 in + python) + flake="$HOME/.nix#python" + shift + ;; + nim) + flake="$HOME/.nix#nim" + shift + ;; + js) + flake="$HOME/.nix#js" + shift + ;; + *) + flake="$1" + shift + ;; + esac + command nix develop "$flake" -c zsh + else + command nix "$@" + fi + } + + _nixos_autocomplete() { + _arguments \ + '1: :->subcmd' \ + '2: :->files' + + case $state in + subcmd) + local -a commands + commands=("update" "config") + _describe 'command' commands + ;; + files) + # Check if the subcommand is config. + if [[ $words[2] == "config" ]]; then + _files -W "$HOME/.nix" -g '*' + fi + ;; + esac + } + + compdef _nixos_autocomplete nixos + ''; +in { + programs.zsh = { + enable = true; + + autosuggestion.enable = true; + enableCompletion = true; + syntaxHighlighting.enable = true; + + shellAliases = { + ls = "eza --icons=always --color=always"; + ll = "eza -a --long --icons=always --color=always --no-time"; + lt = "eza -a --long --tree --icons=always --color=always --no-time"; + + cat = "bat"; + mk = "(){ mkdir -p $1 && cd $1 }"; + + grep = "grep --color=auto"; + + mv = "mv -i"; + cp = "cp -i"; + rm = "rm -i"; + + fetch = "fastfetch -c examples/7"; + + nix-shell = "nix-shell --run $SHELL"; + }; + + initContent = '' + ${nixosScript}; + eval "$(atuin init zsh)" + eval "$(starship init zsh)" + ''; + }; + + programs = { + starship = { + enable = true; + }; + + atuin = { + enable = true; + enableZshIntegration = true; + }; + }; +} |
