From e3b7ad1d4eb46dbd44916b323fe793adae1cd721 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Fri, 29 Feb 2008 10:50:14 +0100 Subject: Ssh: complete known hosts with non standard ports too darcs-hash:20080229095014-32816-be85541c5f65ba9467d327ec3e305c961811678b.gz --- XMonad/Prompt/Ssh.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'XMonad/Prompt') diff --git a/XMonad/Prompt/Ssh.hs b/XMonad/Prompt/Ssh.hs index 379de4c..a7c392f 100644 --- a/XMonad/Prompt/Ssh.hs +++ b/XMonad/Prompt/Ssh.hs @@ -48,7 +48,9 @@ import Data.Maybe data Ssh = Ssh instance XPrompt Ssh where - showXPrompt Ssh = "SSH to: " + showXPrompt Ssh = "SSH to: " + commandToComplete _ c = c + nextCompletion _ = getNextCompletion sshPrompt :: XPConfig -> X () sshPrompt c = do @@ -88,7 +90,7 @@ sshComplListFile kh = do sshComplListFile' :: String -> IO [String] sshComplListFile' kh = do l <- readFile kh - return $ map (takeWhile (/= ',') . concat . take 1 . words) + return $ map (getWithPort . takeWhile (/= ',') . concat . take 1 . words) $ filter nonComment $ lines l @@ -103,3 +105,11 @@ nonComment [] = False nonComment ('#':_) = False nonComment ('|':_) = False -- hashed, undecodeable nonComment _ = True + +getWithPort :: String -> String +getWithPort ('[':str) = host ++ " -p " ++ port + where (host,p) = break (==']') str + port = case p of + ']':':':x -> x + _ -> "22" +getWithPort str = str -- cgit v1.2.3