Skip to content

Instantly share code, notes, and snippets.

@samstokes
Created June 14, 2011 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samstokes/1026086 to your computer and use it in GitHub Desktop.
Save samstokes/1026086 to your computer and use it in GitHub Desktop.
XMonad snippet for IRB prompt
-- === Utilities === {{{1
withLabels :: (a -> b) -> [a] -> [(b, a)]
withLabels label items = (label <$> items) `zip` items
labelled :: [a] -> (a -> b) -> [(b, a)]
labelled = flip withLabels
----- Ruby prompts ----- {{{3
irbGridSelect :: X ()
irbGridSelect = do
rubies <- io $ listRubies
ruby <- gridselect defaultGSConfig $ rubies `labelled` label
whenJust ruby irb
where label ruby = drop 5 ruby -- TODO this is a cheap hack!
irb ruby = safeSpawnX "bash" ["-i", unwords ["rvm", ruby, "exec", "irb"]]
listRubies :: IO [String]
listRubies = do
rubyDirs <- dir rubiesDir
return $ filter (/= "default") rubyDirs
where rubiesDir = ".rvm/rubies"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment