From 422bad0c67c53cb44263fb2e17c209c2230d0a6a Mon Sep 17 00:00:00 2001 From: linxray Date: Sun, 4 May 2014 11:11:20 +0200 Subject: This patch makes the Ssh extension works with **user** arguments in ssh, .e.g ssh admin@localhost. Ignore-this: 297673e11d3049c4f127aac3e172d361 darcs-hash:20140504091120-3bc24-8ce1f3e7c4978a3dcd62bb9d532ac33642457075.gz --- XMonad/Prompt/Ssh.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'XMonad') diff --git a/XMonad/Prompt/Ssh.hs b/XMonad/Prompt/Ssh.hs index aa1b9fd..5bd731c 100644 --- a/XMonad/Prompt/Ssh.hs +++ b/XMonad/Prompt/Ssh.hs @@ -29,6 +29,7 @@ import Control.Exception as E import Control.Monad import Data.Maybe +import Data.List(elemIndex) econst :: Monad m => a -> IOException -> m a econst = const . return @@ -53,8 +54,11 @@ data Ssh = Ssh instance XPrompt Ssh where showXPrompt Ssh = "SSH to: " - commandToComplete _ c = c - nextCompletion _ = getNextCompletion + commandToComplete _ c = maybe c (\(u,h) -> h) (parseHost c) + nextCompletion t c l = maybe next (\(u,h) -> u ++ "@" ++ next) hostPared + where + hostPared = parseHost c + next = getNextCompletion (maybe c (\(u,h) -> h) hostPared) l sshPrompt :: XPConfig -> X () sshPrompt c = do @@ -135,3 +139,6 @@ getWithPort ('[':str) = host ++ " -p " ++ port ']':':':x -> x _ -> "22" getWithPort str = str + +parseHost :: String -> Maybe (String, String) +parseHost a = elemIndex '@' a >>= (\c-> Just ( (take c a), (drop (c+1) a) ) ) -- cgit v1.2.3