mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-06 15:01:53 -07:00
Prompt.Shell: if there's just one completion and it is a directory add a trailing slash
This commit is contained in:
@@ -27,6 +27,7 @@ import Control.Monad
|
|||||||
import Data.List
|
import Data.List
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.IO
|
import System.IO
|
||||||
|
import System.Posix.Files
|
||||||
import XMonad.Util.Run
|
import XMonad.Util.Run
|
||||||
import XMonad hiding (config)
|
import XMonad hiding (config)
|
||||||
import XMonad.Prompt
|
import XMonad.Prompt
|
||||||
@@ -78,8 +79,13 @@ 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 " ++ s ++ "\n")
|
f <- fmap lines $ runProcessWithInput "bash" [] ("compgen -A file " ++ s ++ "\n")
|
||||||
return . map escape . uniqSort $ f ++ commandCompletionFunction cmds s
|
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 :: [String] -> String -> [String]
|
||||||
commandCompletionFunction cmds str | '/' `elem` str = []
|
commandCompletionFunction cmds str | '/' `elem` str = []
|
||||||
|
Reference in New Issue
Block a user