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 "$@"