aboutsummaryrefslogtreecommitdiffstats
path: root/ShellPrompt.hs
diff options
context:
space:
mode:
authorgwern0 <gwern0@gmail.com>2007-10-08 00:02:36 +0200
committergwern0 <gwern0@gmail.com>2007-10-08 00:02:36 +0200
commit796d9cb6ba58700c1d98582e5cd5125c78048d58 (patch)
treea000cfe860bffe0c107f2e409a5bf41c62a561fb /ShellPrompt.hs
parent92b9d423dbe368ee28fc6c6259b669f23ef3a90b (diff)
downloadXMonadContrib-796d9cb6ba58700c1d98582e5cd5125c78048d58.tar.gz
XMonadContrib-796d9cb6ba58700c1d98582e5cd5125c78048d58.tar.xz
XMonadContrib-796d9cb6ba58700c1d98582e5cd5125c78048d58.zip
ShellPrompt.hs: add getShellCompl to export list
getShellCompl is useful for writing prompts in Config.hs or even full standalone prompts; and personally, if a small utility function like 'split' can be exported, how much more so something useful like getShellCompl? darcs-hash:20071007220236-f7719-7b0a4c794bdbce3b19a785bbe01f734e002114c2.gz
Diffstat (limited to 'ShellPrompt.hs')
-rw-r--r--ShellPrompt.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/ShellPrompt.hs b/ShellPrompt.hs
index 077fd8c..ecd8d56 100644
--- a/ShellPrompt.hs
+++ b/ShellPrompt.hs
@@ -3,7 +3,7 @@
-- Module : XMonadContrib.ShellPrompt
-- Copyright : (C) 2007 Andrea Rossato
-- License : BSD3
---
+--
-- Maintainer : andrea.rossato@unibz.it
-- Stability : unstable
-- Portability : unportable
@@ -16,6 +16,7 @@ module XMonadContrib.ShellPrompt (
-- * Usage
-- $usage
shellPrompt
+ , getShellCompl
, split
) where
@@ -55,7 +56,7 @@ shellPrompt :: XPConfig -> X ()
shellPrompt c = mkXPrompt Shell c getShellCompl spawn
getShellCompl :: String -> IO [String]
-getShellCompl s
+getShellCompl s
| s /= "" && last s /= ' ' = do
f <- fmap lines $ runProcessWithInput "/bin/bash" [] ("compgen -A file " ++ s ++ "\n")
c <- commandCompletionFunction s
@@ -69,7 +70,7 @@ commandCompletionFunction str
| otherwise = do
p <- getEnv "PATH" `catch` const (return [])
let ds = split ':' p
- fp d f = d ++ "/" ++ f
+ fp d f = d ++ "/" ++ f
es <- forM ds $ \d -> do
exists <- doesDirectoryExist d
if exists
@@ -88,7 +89,7 @@ split :: Eq a => a -> [a] -> [[a]]
split _ [] = []
split e l =
f : split e (rest ls)
- where
+ where
(f,ls) = span (/=e) l
rest s | s == [] = []
| otherwise = tail s