From 358b6ffcde9e3732ed08387fc176851e07c1862f Mon Sep 17 00:00:00 2001 From: Brian McKenna Date: Tue, 18 Feb 2014 14:37:59 -0700 Subject: [PATCH] Add cabal_sandbox_info function Reports whether the current working directory is within a sandbox. Useful to check before installing Cabal packages into the global registry. --- plugins/cabal/cabal.plugin.zsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/cabal/cabal.plugin.zsh b/plugins/cabal/cabal.plugin.zsh index 8d3c64587..9f76add7a 100644 --- a/plugins/cabal/cabal.plugin.zsh +++ b/plugins/cabal/cabal.plugin.zsh @@ -1,3 +1,14 @@ +function cabal_sandbox_info() { + cabal_files=(*.cabal(N)) + if [ $#cabal_files -gt 0 ]; then + if [ -f cabal.sandbox.config ]; then + echo "%{$fg[green]%}sandboxed%{$reset_color%}" + else + echo "%{$fg[red]%}not sandboxed%{$reset_color%}" + fi + fi +} + function _cabal_commands() { local ret=1 state _arguments ':subcommand:->subcommand' && ret=0