Skip to content

Instantly share code, notes, and snippets.

@greyblake
Last active March 12, 2021 16:56
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 greyblake/bd2e6dfa7b463958ccfa8b0df067720a to your computer and use it in GitHub Desktop.
Save greyblake/bd2e6dfa7b463958ccfa8b0df067720a to your computer and use it in GitHub Desktop.
Creates new rust project and runs `cargo watch` with vim in tmux
#!/bin/sh
PLAYGROUNDS_DIR="/tmp/rust-playgrounds"
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
PROJECT_DIR="${PLAYGROUNDS_DIR}/playground${TIMESTAMP}"
cargo new $PROJECT_DIR
cd $PROJECT_DIR
# Add dependencies
for CRATE in $@; do
sed "/^\[dependencies\]/a $CRATE = \"*\"" -i Cargo.toml
done
tmux new-session \; \
send-keys "nvim ./src/main.rs" C-m \; \
split-window -h \; \
send-keys "cargo watch -x run" C-m \; \
select-pane -L;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment