summaryrefslogblamecommitdiff
path: root/install_rust_tools
blob: e5e688dab48a05961fb684a1df35aba3fa68bda2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
           

                                











                                                 
                 



                                                                                                
                                                      








                                                                                           
#!/bin/bash
# dotfiles -- install_rust_tools
# author: johannst

if ! which cargo &> /dev/null; then
    echo "There is no cargo installed, checkout:"
    echo "    https://rustup.rs/"
    exit 1
fi

tools=()
tools+=("bat")
tools+=("exa")
tools+=("fd-find")
tools+=("ripgrep")
tools+=("zoxide")

for tool in ${tools[@]}; do
   installed_vers=$(cargo install --list | grep "^$tool" | awk '{ print $2 }' | sed 's/[v:]//g')
   [[ ! -z $installed_vers ]] && {
      echo "[+] $tool installed, checking version ..."
      update_vers=$(cargo search --limit 1 $tool | awk 'NR==1 { print $3 }' | sed 's/"//g')
      [[ $installed_vers == $update_vers ]] && { continue; }
      echo ">>> update $tool $installed_vers -> $update_vers? [yYnN]"
      read reply
      [[ $reply  =~ ^[^Yy]$ ]] && { continue; }
   }
   cargo install --force $tool
done