Last active
October 26, 2017 17:55
-
-
Save osa1/aa28bb5c94a74e96e870ddde846b2e9c to your computer and use it in GitHub Desktop.
.ghci for fuzzy file loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.IO.Temp (withSystemTempFile) | |
import System.Process (runProcess, waitForProcess) | |
:{ | |
let loadFuzzy _ = do | |
withSystemTempFile "fzf_out" $ \f h -> do | |
p <- runProcess "fzf" [] Nothing Nothing Nothing (Just h) Nothing | |
_ <- waitForProcess p | |
out <- readFile f | |
return (":load " ++ init out) | |
:} | |
:def loadf loadFuzzy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.IO (withFile, IOMode (WriteMode)) | |
import System.Process (runProcess, waitForProcess) | |
:{ | |
let loadFuzzy _ = do | |
let f = "/tmp/fzf_out" | |
withFile f WriteMode $ \h -> do | |
p <- runProcess "fzf" [] Nothing Nothing Nothing (Just h) Nothing | |
_ <- waitForProcess p | |
out <- readFile f | |
return (":load " ++ init out) | |
:} | |
:def l loadFuzzy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment