aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Prompt
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@unibz.it>2008-02-29 10:50:14 +0100
committerAndrea Rossato <andrea.rossato@unibz.it>2008-02-29 10:50:14 +0100
commite3b7ad1d4eb46dbd44916b323fe793adae1cd721 (patch)
tree42638f19729251fda1b00c04b17012ad51e2fd0f /XMonad/Prompt
parent7fd4c6e5b96a0340eb4aa7601992e71ba0034af5 (diff)
downloadXMonadContrib-e3b7ad1d4eb46dbd44916b323fe793adae1cd721.tar.gz
XMonadContrib-e3b7ad1d4eb46dbd44916b323fe793adae1cd721.tar.xz
XMonadContrib-e3b7ad1d4eb46dbd44916b323fe793adae1cd721.zip
Ssh: complete known hosts with non standard ports too
darcs-hash:20080229095014-32816-be85541c5f65ba9467d327ec3e305c961811678b.gz
Diffstat (limited to 'XMonad/Prompt')
-rw-r--r--XMonad/Prompt/Ssh.hs14
1 files changed, 12 insertions, 2 deletions
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