diff options
author | linxray <linxray@gmail.com> | 2014-05-04 11:11:20 +0200 |
---|---|---|
committer | linxray <linxray@gmail.com> | 2014-05-04 11:11:20 +0200 |
commit | 422bad0c67c53cb44263fb2e17c209c2230d0a6a (patch) | |
tree | bd1c1e0169f56ef4758b034e9df7f11dda159948 /XMonad | |
parent | 26bb0fbf421e7281667f983c874c71efd4505989 (diff) | |
download | XMonadContrib-422bad0c67c53cb44263fb2e17c209c2230d0a6a.tar.gz XMonadContrib-422bad0c67c53cb44263fb2e17c209c2230d0a6a.tar.xz XMonadContrib-422bad0c67c53cb44263fb2e17c209c2230d0a6a.zip |
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
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Prompt/Ssh.hs | 11 |
1 files changed, 9 insertions, 2 deletions
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) ) ) |