diff --git a/install b/install index f1095d0..b8f15f3 100755 --- a/install +++ b/install @@ -5,6 +5,21 @@ 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 @@ -33,7 +48,7 @@ for rc in *rc *profile tmux.conf bashrc.d mutt ; do if [ ! -r $rc ] ; then continue fi - [ $(realpath ~/."$rc") == $BASE/$rc ] + [ "$(realpath ~/."$rc")" == "$BASE/$rc" ] if [ $? -ne 0 ] ; then [ -e ~/."$rc" ] && mv -v ~/."$rc" bak/."$rc" ln -sfv "$BASE/$rc" ~/."$rc" @@ -44,36 +59,28 @@ 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 cargo install bat exa sd -GIT=$(which git) -if [ "$GIT" != "" ] ; then - mkdir -p ~/src/ - install_rust_app https://github.com/sharkdp/fd.git ~/src/fd fd - install_rust_app https://github.com/dandavison/delta.git ~/src/delta delta -else - echo "You don't have git; can't install fd and a lot of Vim plugins are going to fail too." -fi +mkdir -p ~/src/ +install_rust_app https://github.com/sharkdp/fd.git ~/src/fd fd +install_rust_app https://github.com/dandavison/delta.git ~/src/delta delta -GIT=$(which git) -if [ "$GIT" != "" ] ; then - mkdir -p ~/src/ - pushd ~/src/ - if [ ! -d fd ] ; then - git clone https://github.com/sharkdp/fd.git - cd fd - else - cd fd - git pull - fi - cargo build --release - ln -sfv $PWD/target/release/fd ~/bin - popd -else - echo "You don't have git; can't install fd and a lot of Vim plugins are going to fail too." -fi +# pushd ~/src/ +# if [ ! -d fd ] ; then +# git clone https://github.com/sharkdp/fd.git +# cd fd +# else +# cd fd +# git pull +# fi +# cargo build --release +# ln -sfv $PWD/target/release/fd ~/bin +# popd # git-prompt # if [ ! -e ~/.git-prompt.sh ]; then @@ -90,7 +97,7 @@ for bin in $BASE/bin/*; do fi done -if [ "$(uname -s)" = 'Darwin' ]; then +if [ "$(uname -s)" == 'Darwin' ]; then # Homebrew [ -z "$(which brew)" ] && ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" @@ -120,7 +127,9 @@ if [ ! -d ~/.tmux/plugins/tpm ] ; then fi # Install nvm. -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash +(curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/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