From fd3f4a7a646002a2f1516f4b24bba316b122fd2f Mon Sep 17 00:00:00 2001 From: Rachel Lambda Samuelsson Date: Thu, 22 Aug 2024 21:07:47 +0200 Subject: [PATCH] zsh :3 --- home-manager/shell.nix | 60 ++++++++++++++++++++++++++---------- nixos/shared/user-system.nix | 2 ++ 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/home-manager/shell.nix b/home-manager/shell.nix index 116b712..64d16b1 100644 --- a/home-manager/shell.nix +++ b/home-manager/shell.nix @@ -1,32 +1,41 @@ -{ common, ... }: +{ pkgs, common, ... }: { - programs.bash = { + programs.zsh = { enable = true; - enableCompletion = true; - historyFile = "/dev/null"; - sessionVariables = { - PS1 ="\\033[1m\\u\\033[0m@\\033[1m\\h\\033[0m: \\w\nλ "; - BROWSER = "firefox"; - XINITRC = "${common.homeDir}/bin/xinitrc"; - XAUTHORITY = "${common.homeDir}/.local/share/Xauthority"; - PASH_KEYID = "3E4A909C8FEF6E3783699C79DFC26EF8EDAD6D71"; - QT_AUTO_SCREEN_FACTOR = 1; - PATH = "${common.homeDir}/bin:$PATH"; - }; + enableCompletion = false; # manage completions ourself + dotDir = ".config/zsh"; shellAliases = { x = "startx"; rm = "rm -i"; cal = "cal -m"; }; + envExtra = '' + export PS1=$'%B%n%b@%B%m%b: %~\nλ ' + export BROWSER=firefox + export XINITRC="${common.homeDir}/bin/xinitrc" + export XAUTHORITY="${common.homeDir}/.local/share/Xauthority" + export PASH_KEYID="3E4A909C8FEF6E3783699C79DFC26EF8EDAD6D71" + export QT_AUTO_SCREEN_FACTOR=1 + export PATH="${common.homeDir}/bin:$PATH" + ''; initExtra = '' - source ~/.profile - set -o vi + autoload -Uz compinit + + compinit -C + (exec compinit &) + + _comp_options+=(globdots) + + setopt autocd + setopt noautomenu + setopt nomenucomplete run() { pkg="$1" [ "$pkg" = "''${pkg##*#}" ] && pkg="nixpkgs#$pkg" export NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_BROKEN=1 - nix run --impure "$pkg" + shift + nix run --impure "$pkg" -- "$@" } shell() { @@ -42,7 +51,26 @@ nix shell --impure "$@" } + # vi mode options + KEYTIMEOUT=1 + MODE_INDICATOR_VICMD='%K{10}%F{8}%B NORMAL %k%f%b' + MODE_INDICATOR_REPLACE='%K{9}%F{8}%B REPLACE %k%f%b' + MODE_INDICATOR_SEARCH='%K{13}%F{8}%B SEARCH %k%f%b' + MODE_INDICATOR_VISUAL='%K{12}%F{8}%B VISUAL %k%f%b' + MODE_INDICATOR_VLINE='%K{12}%F{8}%B V-LINE %k%f%b' ''; + plugins = [ + { + name = "zsh-vim-mode"; + file = "zsh-vim-mode.plugin.zsh"; + src = pkgs.fetchFromGitHub { + owner = "softmoth"; + repo = "zsh-vim-mode"; + rev = "1f9953b7d6f2f0a8d2cb8e8977baa48278a31eab"; + sha256 = "sha256-a+6EWMRY1c1HQpNtJf5InCzU7/RphZjimLdXIXbO6cQ="; + }; + } + ]; }; programs.direnv = { enable = true; diff --git a/nixos/shared/user-system.nix b/nixos/shared/user-system.nix index 309fee4..7d0813c 100644 --- a/nixos/shared/user-system.nix +++ b/nixos/shared/user-system.nix @@ -88,6 +88,8 @@ # [USER] users.users.rachel = { isNormalUser = true; + shell = pkgs.zsh; + ignoreShellProgramCheck = true; extraGroups = [ "wheel" "networkmanager"