From 9b7d216ec095ccee541ebfa5f04249aa2964d054 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Tue, 25 Aug 2015 08:56:21 +0200 Subject: [PATCH] prompt for nix-shell and init.zsh hook for pretzo --- init.zsh | 3 +++ nix.plugin.zsh | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 init.zsh diff --git a/init.zsh b/init.zsh new file mode 100644 index 0000000..5ef4b43 --- /dev/null +++ b/init.zsh @@ -0,0 +1,3 @@ + +# Source module files. +source "${0:h}/nix.plugin.zsh" || return 1 diff --git a/nix.plugin.zsh b/nix.plugin.zsh index f90bb75..dfdb731 100644 --- a/nix.plugin.zsh +++ b/nix.plugin.zsh @@ -1,5 +1,24 @@ # Nix Install -# alias ni='nix-env -iA' +alias ni='nix-env -iA' # Nix Search -# alias ns='nix-env -qaP' +alias ns='nix-env -qaP' + +function prompt_nix_shell_precmd { + if [[ ${IN_NIX_SHELL} -eq 1 ]] then + if [[ -n ${IN_WHICH_NIX_SHELL} ]] then + NIX_SHELL_NAME=": ${IN_WHICH_NIX_SHELL}" + fi + NIX_PROMPT="%F{8}[%F{3}nix-shell${NIX_SHELL_NAME}%F{8}]%f" + if [[ $PROMPT != *"$NIX_PROMPT"* ]] then + PROMPT="$NIX_PROMPT $PROMPT" + fi + fi +} + +function prompt_nix_shell_setup { + autoload -Uz add-zsh-hook + add-zsh-hook precmd prompt_nix_shell_precmd +} + +prompt_nix_shell_setup "$@"