Skip to content

Instantly share code, notes, and snippets.

@geekoff7
Last active August 9, 2021 22:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekoff7/3118dc59b5be836e66ab29a03e5c1ea8 to your computer and use it in GitHub Desktop.
Save geekoff7/3118dc59b5be836e66ab29a03e5c1ea8 to your computer and use it in GitHub Desktop.
simple script install rust language programming and essential dev tools
#!/usr/bin/env sh
# ************ install rust programming language **************
curl https://sh.rustup.rs -sSf | sh
export PATH="$HOME/.cargo/bin:$PATH"
# ************** install stable rust component ****************
rustup component add rustfmt
rustup component add clippy
rustup component add rls
rustup component add rust-src
rustup component add rust-analysis
rustup component add llvm-tools-preview
# *********** install vscode extension rust language **********
if [ -x "$(command -v code)" ]; then
code --install-extension rust-lang.rust
code --install-extension polypus74.trusty-rusty-snippets
code --install-extension serayuzgur.crates
fi
# ****************** install cargo subcommands ******************
cargo install cargo-fix
cargo install cargo-edit
cargo install cargo-audit
cargo install cargo-env
cargo install cargo-expand
cargo install cargo-tree # or cargo-modules
cargo install cargo-update
cargo install cargo-watch
cargo install cargo-vendor
cargo install cargo-make
cargo install rusty-tags
# **************** install rust nightly version *****************
rustup toolchain install nightly
# set default rust compiler to nightly version
rustup default nightly
# ************** install nightly rust component *****************
rustup component add rustfmt
rustup component add clippy
rustup component add rls
rustup component add rust-src
rustup component add rust-analysis
rustup component add llvm-tools-preview
# ************* install racer for code completion rust **********
cargo install racer
# set environment variable RUST_SRC_PATH
if [ -f "$HOME/.bashrc" ]; then
echo "export RUST_SRC_PATH=\$(rustc --print sysroot)/lib/rustlib/src/rust/src" >> "$HOME/.bashrc"
fi
if [ -f "$HOME/.zshrc" ]; then
echo "export RUST_SRC_PATH=\$(rustc --print sysroot)/lib/rustlib/src/rust/src" >> "$HOME/.zshrc"
fi
export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"
# ****************************** other tools ***************************
cargo install bat # or fcat
cargo install lsd # or exa
cargo install fd-find
cargo install bingrep
cargo install ripgrep
cargo install watchexec
cargo install hyperfine
cargo install miniserve
cargo install topgrade
cargo install mdbook
# ********************** set alias update rust command *******************
if [ -f "$HOME/.bashrc" ]; then
echo 'alias uprust="rustup update && cargo install-update -a"' >> "$HOME/.bashrc"
fi
if [ -f "$HOME/.zshrc" ]; then
echo 'alias uprust="rustup update && cargo install-update -a"' >> "$HOME/.zshrc"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment