Skip to content

Instantly share code, notes, and snippets.

@osa1
Last active October 26, 2017 17:55
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 osa1/aa28bb5c94a74e96e870ddde846b2e9c to your computer and use it in GitHub Desktop.
Save osa1/aa28bb5c94a74e96e870ddde846b2e9c to your computer and use it in GitHub Desktop.
.ghci for fuzzy file loading
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
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