Skip to content

Instantly share code, notes, and snippets.

@simonmichael
Last active March 1, 2021 14:18
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 simonmichael/42fa4828490ff71355b8c9029f036e4d to your computer and use it in GitHub Desktop.
Save simonmichael/42fa4828490ff71355b8c9029f036e4d to your computer and use it in GitHub Desktop.
symlinkghc - Symbolically link the ghc tools provided by the global stack resolver into PATH
#!/bin/sh
# Usage: symlinkghc
# Symbolically link the ghc tools provided by the global stack resolver
# (ghc ghci runghc runhaskell ghc-pkg haddock hp2ps hpc hsc2hs,
# ~/.stack/global-project/stack.yaml)
# into ~/.local/bin, so that they are always available at the command
# line for quick experiments. ~/.local/bin should be in your PATH.
# Similarly named executables/links in that directory will be overwritten.
# GHC will be downloaded if needed, eg if you just updated the global stack resolver.
# Caveat: these will see only the ghc package db by default, not new packages you have installed.
cd || exit
stack setup
STACKBIN=$(stack path --compiler-bin)
USERBIN="$HOME/.local/bin"
EXES="ghc ghci runghc runhaskell ghc-pkg haddock hp2ps hpc hsc2hs"
for EXE in $EXES; do ln -sf "$STACKBIN"/"$EXE" "$USERBIN"/"$EXE" done
echo "$EXES installed in $USERBIN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment