aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Prompt
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@unibz.it>2008-02-16 12:40:05 +0100
committerAndrea Rossato <andrea.rossato@unibz.it>2008-02-16 12:40:05 +0100
commitcb871d8812a9966551211325495f564d98028ea3 (patch)
treeebda685243fe6f897fe141acd5ed015a640623e3 /XMonad/Prompt
parent722962c49ed952bc7ad1923822ce46b54b3b155f (diff)
downloadXMonadContrib-cb871d8812a9966551211325495f564d98028ea3.tar.gz
XMonadContrib-cb871d8812a9966551211325495f564d98028ea3.tar.xz
XMonadContrib-cb871d8812a9966551211325495f564d98028ea3.zip
Prompt.Shell: if there's just one completion and it is a directory add a trailing slash
darcs-hash:20080216114005-32816-f4b424bd543885bff361b75ad1cc7e7511260f6a.gz
Diffstat (limited to 'XMonad/Prompt')
-rw-r--r--XMonad/Prompt/Shell.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/XMonad/Prompt/Shell.hs b/XMonad/Prompt/Shell.hs
index 29dba38..6a26d4a 100644
--- a/XMonad/Prompt/Shell.hs
+++ b/XMonad/Prompt/Shell.hs
@@ -27,6 +27,7 @@ import Control.Monad
import Data.List
import System.Directory
import System.IO
+import System.Posix.Files
import XMonad.Util.Run
import XMonad hiding (config)
import XMonad.Prompt
@@ -78,8 +79,13 @@ unsafePrompt c config = mkXPrompt Shell config (getShellCompl [c]) run
getShellCompl :: [String] -> String -> IO [String]
getShellCompl cmds s | s == "" || last s == ' ' = return []
| otherwise = do
- f <- fmap lines $ runProcessWithInput "bash" [] ("compgen -A file " ++ s ++ "\n")
- return . map escape . uniqSort $ f ++ commandCompletionFunction cmds s
+ f <- fmap lines $ runProcessWithInput "bash" [] ("compgen -A file " ++ s ++ "\n")
+ files <- case f of
+ [x] -> do fs <- getFileStatus x
+ if isDirectory fs then return [x ++ "/"]
+ else return [x]
+ _ -> return f
+ return . map escape . uniqSort $ files ++ commandCompletionFunction cmds s
commandCompletionFunction :: [String] -> String -> [String]
commandCompletionFunction cmds str | '/' `elem` str = []