mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-11 18:22:16 -07:00
Correct completions of utf8-named file in X.P.Shell
This commit is contained in:
@@ -24,7 +24,7 @@ module XMonad.Prompt.Shell
|
|||||||
, safePrompt
|
, safePrompt
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Codec.Binary.UTF8.String (decodeString, encodeString)
|
import Codec.Binary.UTF8.String (encodeString)
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Control.Monad (forM)
|
import Control.Monad (forM)
|
||||||
import Data.List (isPrefixOf)
|
import Data.List (isPrefixOf)
|
||||||
@@ -88,13 +88,14 @@ unsafePrompt c config = mkXPrompt Shell config (getShellCompl [c]) run
|
|||||||
getShellCompl :: [String] -> String -> IO [String]
|
getShellCompl :: [String] -> String -> IO [String]
|
||||||
getShellCompl cmds s | s == "" || last s == ' ' = return []
|
getShellCompl cmds s | s == "" || last s == ' ' = return []
|
||||||
| otherwise = do
|
| 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
|
files <- case f of
|
||||||
[x] -> do fs <- getFileStatus x
|
[x] -> do fs <- getFileStatus (encodeString x)
|
||||||
if isDirectory fs then return [x ++ "/"]
|
if isDirectory fs then return [x ++ "/"]
|
||||||
else return [x]
|
else return [x]
|
||||||
_ -> return f
|
_ -> return f
|
||||||
return . map decodeString . uniqSort $ files ++ commandCompletionFunction cmds s
|
return . uniqSort $ files ++ commandCompletionFunction cmds s
|
||||||
|
|
||||||
commandCompletionFunction :: [String] -> String -> [String]
|
commandCompletionFunction :: [String] -> String -> [String]
|
||||||
commandCompletionFunction cmds str | '/' `elem` str = []
|
commandCompletionFunction cmds str | '/' `elem` str = []
|
||||||
|
Reference in New Issue
Block a user