Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.