#!/bin/sh ## A poor man's offline Rust playground. # # A simple cargo extension to setup and start a simple Rust project. # # Usage: # # cargo play [] # # where `` is the name of the project. If no name is provided a temporary # directory will be used instead. # # Requires: # - neovim # - entr (http://eradman.com/entrproject/) # - cargo # # TODO: # - add ability to pass `cargo init` arguments # - make `entr` detect new files PLAY="" BASE="$GIT/play" # Check whether the script was invoked as a cargo command (i.e., `cargo play`). [ "$1" = "play" ] && shift if [ -z "$1" ] ; then PLAY=$(mktemp -d --tmpdir "rustplay_XXXXX") else PLAY="$BASE/$1" mkdir -p "$PLAY" shift fi cd "$PLAY" || exit 1 cargo init # Start neovim with automatic compilation on save on a side terminal nvim '+vertical split | terminal ls src/* | entr -cs "cargo run"' '+wincmd p' src/main.rs