diff --git a/home-manager/shell.nix b/home-manager/shell.nix index 1961914..45fdf89 100644 --- a/home-manager/shell.nix +++ b/home-manager/shell.nix @@ -12,7 +12,7 @@ cd = "z"; }; envExtra = '' - PROMPT=$'%B%n%b@%B%m%b: %~ %F{red}''${vcs_info_msg_0_}%f\nλ ' + PROMPT=$'%B%n%b@%B%m%b: %~\nλ ' 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' @@ -39,36 +39,23 @@ setopt nomenucomplete setopt TRANSIENT_RPROMPT - run() { - pkg="$1" - [ "$pkg" = "''${pkg##*#}" ] && pkg="nixpkgs#$pkg" - export NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_BROKEN=1 + nix-subcommand() { + cmd="$1" shift - nix run --impure "$pkg" -- "$@" - } - - shell() { - i="$#" - while [ "$i" -gt 0 ]; do - pkg="$1" - [ "$pkg" = "''${pkg##*#}" ] && pkg="nixpkgs#$pkg" + pkgs=() + for pkg in "$@"; do shift - set -- "$@" "$pkg" - : $(( i -= 1 )) + [ "$pkg" = -- ] && break + [ "$pkg" = "''${pkg##*#}" ] && pkg="nixpkgs#$pkg" + pkgs+="$pkg" done export NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_BROKEN=1 - nix shell --impure "$@" + nix "$cmd" --impure "''${pkgs[@]}" -- "$@" } - autoload -Uz add-zsh-hook vcs_info - setopt prompt_subst - add-zsh-hook precmd vcs_info - - zstyle ':vcs_info:*' check-for-changes true - zstyle ':vcs_info:*' unstagedstr '*' - zstyle ':vcs_info:*' stagedstr '+' - zstyle ':vcs_info:git:*' formats '(%b%u%c)' - zstyle ':vcs_info:git:*' actionformats '(%b|%a%u%c)' + shell() { nix-subcommand "shell" "$@" } + run() { nix-subcommand "run" "$@" } + build() { nix-subcommand "build" "$@" } ''; plugins = [ {