Skip to content

Instantly share code, notes, and snippets.

@adamwespiser
Created May 8, 2021 05:38
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 adamwespiser/cf369a88e068a35246df5f51261fb97c to your computer and use it in GitHub Desktop.
Save adamwespiser/cf369a88e068a35246df5f51261fb97c to your computer and use it in GitHub Desktop.
Drops you into a tmux session with two windows, one window editing a skeleton Haskell module, the the other one a ghcid session with the module loaded
#!/bin/bash
set -e
if [ $# -eq 0 ]
then
echo "No arguments supplied"
exit 1;
fi
dir=$HOME/projects/hask-play
cd $dir
date_tag=$(date "+%Y%m%d")
module="$1_${date_tag}"
file="${module}".hs
session="$1"
window1="vim"
window2="ghcid"
if test -f "${dir}/${file}"; then
echo "${file} already exists: use a different name"
exit 1;
fi
ghcid_cmd="ghcid -c \"stack ghci ${file}\""
cat << ENDOFFILE > "${dir}/$file"
{- stack
--resolver lts-17.10
--install-ghc exec ghci
--package "text"
-}
{-# Language LambdaCase #-}
{- ${ghcid_cmd} -}
module ${module} where
import Prelude
main :: IO ()
main = undefined
ENDOFFILE
tmux new-session -d -s $session -n "${window1}" -c $dir
tmux send-keys -t "=${session}:=${window1}" "vi ${file}" Enter
tmux new-window -d -t "=${session}" -n "${window2}" -c $dir
tmux send-keys -t "=${session}:=${window2}" "${ghcid_cmd}" Enter
tmux attach-session -t "${session}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment