358b6ffcde9e3732ed08387fc176851e07c1862f

Author
Brian McKenna <brian@simpleenergy.com>
Committer
Brian McKenna <brian@simpleenergy.com>
Date

Message

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.

Diff

 1diff --git a/plugins/cabal/cabal.plugin.zsh b/plugins/cabal/cabal.plugin.zsh
 2index 8d3c64587155a75a48055fa28d649159d328a874..9f76add7a30a791add54a4b5af864b4d18172262 100644
 3--- a/plugins/cabal/cabal.plugin.zsh
 4+++ b/plugins/cabal/cabal.plugin.zsh
 5@@ -1,3 +1,14 @@
 6+function cabal_sandbox_info() {
 7+    cabal_files=(*.cabal(N))
 8+    if [ $#cabal_files -gt 0 ]; then
 9+        if [ -f cabal.sandbox.config ]; then
10+            echo "%{$fg[green]%}sandboxed%{$reset_color%}"
11+        else
12+            echo "%{$fg[red]%}not sandboxed%{$reset_color%}"
13+        fi
14+    fi
15+}
16+
17 function _cabal_commands() {
18     local ret=1 state
19     _arguments ':subcommand:->subcommand' && ret=0