aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Prompt
diff options
context:
space:
mode:
authorBrent Yorgey <byorgey@cis.upenn.edu>2009-12-29 18:13:46 +0100
committerBrent Yorgey <byorgey@cis.upenn.edu>2009-12-29 18:13:46 +0100
commitb5562cfe826899153df9e91a0d24a643575875a5 (patch)
tree69c61c45545efb91003d3ab0005bf2ccde668055 /XMonad/Prompt
parent79d492a9e2fed26ab0e0cbedbc6bec6c2da9cf59 (diff)
downloadXMonadContrib-b5562cfe826899153df9e91a0d24a643575875a5.tar.gz
XMonadContrib-b5562cfe826899153df9e91a0d24a643575875a5.tar.xz
XMonadContrib-b5562cfe826899153df9e91a0d24a643575875a5.zip
X.P.Ssh: add entries from .ssh/config to ssh prompt completion
Ignore-this: fa638a0af4cb71be91f6c90bdf6d5513 darcs-hash:20091229171346-1e371-fd97e53030a55a95ca1027610a73b4642404b871.gz
Diffstat (limited to 'XMonad/Prompt')
-rw-r--r--XMonad/Prompt/Ssh.hs20
1 files changed, 19 insertions, 1 deletions
diff --git a/XMonad/Prompt/Ssh.hs b/XMonad/Prompt/Ssh.hs
index 22d6336..122c137 100644
--- a/XMonad/Prompt/Ssh.hs
+++ b/XMonad/Prompt/Ssh.hs
@@ -65,7 +65,9 @@ sshComplList = uniqSort `fmap` liftM2 (++) sshComplListLocal sshComplListGlobal
sshComplListLocal :: IO [String]
sshComplListLocal = do
h <- getEnv "HOME"
- sshComplListFile $ h ++ "/.ssh/known_hosts"
+ s1 <- sshComplListFile $ h ++ "/.ssh/known_hosts"
+ s2 <- sshComplListConf $ h ++ "/.ssh/config"
+ return $ s1 ++ s2
sshComplListGlobal :: IO [String]
sshComplListGlobal = do
@@ -93,6 +95,22 @@ sshComplListFile' kh = do
$ filter nonComment
$ lines l
+sshComplListConf :: String -> IO [String]
+sshComplListConf kh = do
+ f <- doesFileExist kh
+ if f then sshComplListConf' kh
+ else return []
+
+sshComplListConf' :: String -> IO [String]
+sshComplListConf' kh = do
+ l <- readFile kh
+ return $ map (!!1)
+ $ filter isHost
+ $ map words
+ $ lines l
+ where
+ isHost ws = take 1 ws == ["Host"] && length ws > 1
+
fileExists :: String -> IO (Maybe String)
fileExists kh = do
f <- doesFileExist kh