From 361e727a7844e5fd2ea7eaa0d6b1d4fc0a5c0b68 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Fri, 11 Nov 2011 22:56:55 +0100 Subject: Correct completions of utf8-named file in X.P.Shell Ignore-this: 9aa10143f313b06afdb11e61777a7d20 darcs-hash:20111111215655-1499c-778c2896f89bf1085217059c72b05857c04931a2.gz --- XMonad/Prompt/Shell.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'XMonad/Prompt') diff --git a/XMonad/Prompt/Shell.hs b/XMonad/Prompt/Shell.hs index 9ed9293..da55f48 100644 --- a/XMonad/Prompt/Shell.hs +++ b/XMonad/Prompt/Shell.hs @@ -24,7 +24,7 @@ module XMonad.Prompt.Shell , safePrompt ) where -import Codec.Binary.UTF8.String (decodeString, encodeString) +import Codec.Binary.UTF8.String (encodeString) import Control.Exception import Control.Monad (forM) import Data.List (isPrefixOf) @@ -88,13 +88,14 @@ 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 " ++ encodeString s ++ "\n") + f <- fmap lines $ runProcessWithInput "bash" [] ("compgen -A file -- " + ++ s ++ "\n") files <- case f of - [x] -> do fs <- getFileStatus x + [x] -> do fs <- getFileStatus (encodeString x) if isDirectory fs then return [x ++ "/"] else return [x] _ -> return f - return . map decodeString . uniqSort $ files ++ commandCompletionFunction cmds s + return . uniqSort $ files ++ commandCompletionFunction cmds s commandCompletionFunction :: [String] -> String -> [String] commandCompletionFunction cmds str | '/' `elem` str = [] -- cgit v1.2.3