#!/bin/bash # # Adapted from Junegunn Choi (junegunn.c@gmail.com) # https://github.com/junegunn/dotfiles/blob/master/install cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 check_command() { CMD=$1 FOUND=$(command -v $CMD) if [ "$FOUND" == "" ] ; then echo "You don't have $CMD." exit 1 else echo "Found $FOUND." fi } COMMANDS="git realpath curl" for cmd in $COMMANDS ; do check_command $cmd done install_rust_app() { REPO=$1 DIRNAME=$2 BINARY=$3 if [ ! -d "$DIRNAME" ] ; then git clone "$REPO" "$DIRNAME" pushd "$DIRNAME" 1>/dev/null else pushd "$DIRNAME" 1>/dev/null git pull fi cargo build --release cp -fv $PWD/target/release/$BINARY ~/bin/ cargo clean popd 1>/dev/null } BASE=$(pwd) EXA_VER= # RC files mkdir -pv bak for rc in *rc *profile tmux.conf bashrc.d mutt ; do if [ ! -r $rc ] ; then continue fi [ "$(realpath ~/."$rc")" == "$BASE/$rc" ] if [ $? -ne 0 ] ; then [ -e ~/."$rc" ] && mv -v ~/."$rc" bak/."$rc" ln -sfv "$BASE/$rc" ~/."$rc" fi done if [ "$(which cargo)" == "" ] ; then # Install Cargo, in order to install exa etc. (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh) || exit 1 source $HOME/.cargo/env else # Assume that if we have Cargo we have rustup too. rustup update fi mkdir -p ~/src/ # git-prompt # if [ ! -e ~/.git-prompt.sh ]; then # curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh # fi # scripts mkdir -p ~/bin for bin in $BASE/bin/*; do BIN_NAME=$(basename $bin) [ $(realpath ~/bin/$BIN_NAME) == $bin ] if [ $? -ne 0 ] ; then ln -svf "$bin" ~/bin fi done if [ "$(uname -s)" == 'Darwin' ]; then # Homebrew [ -z "$(which brew)" ] && ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew install \ fd ag wget git bat tmux bash-completion \ vim macvim jq else install_rust_app https://github.com/sharkdp/fd.git ~/src/fd fd fi git config --global user.email "paul@blacksun.org.uk" git config --global user.name "Paul Walker" if [ ! -d "$HOME/.asdf" ] ; then git clone https://github.com/asdf-vm/asdf.git ~/.asdf fi if [ ! -d ~/.tmux/plugins/tpm ] ; then git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm if [ "$TMUX" != "" ] ; then # If we're currently in tmux, source the new file. tmux source-file ~/.tmux.conf fi fi # Install nvm. (curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash) || exit 1 source ./bashrc.d/nvm.bash # We can't stop nvm appending to bashrc, but we don't need it - the variables nvm writes to .bashrc are already in # ~/.bashrc.d/nvm.bash cp bashrc bashrc-bk nvm install node && nvm use node && corepack enable cp bashrc-bk bashrc # ./install-vim